9 AsyncResponseStream *stream = req->beginResponseStream(
"text/plain; version=0.0.4; charset=utf-8");
17 #ifdef USE_BINARY_SENSOR 69 stream->print(F(
"#TYPE esphome_sensor_value gauge\n"));
70 stream->print(F(
"#TYPE esphome_sensor_failed gauge\n"));
75 if (!std::isnan(obj->
state)) {
77 stream->print(F(
"esphome_sensor_failed{id=\""));
79 stream->print(F(
"\",name=\""));
81 stream->print(F(
"\"} 0\n"));
83 stream->print(F(
"esphome_sensor_value{id=\""));
85 stream->print(F(
"\",name=\""));
87 stream->print(F(
"\",unit=\""));
89 stream->print(F(
"\"} "));
91 stream->print(F(
"\n"));
94 stream->print(F(
"esphome_sensor_failed{id=\""));
96 stream->print(F(
"\",name=\""));
98 stream->print(F(
"\"} 1\n"));
104 #ifdef USE_BINARY_SENSOR 106 stream->print(F(
"#TYPE esphome_binary_sensor_value gauge\n"));
107 stream->print(F(
"#TYPE esphome_binary_sensor_failed gauge\n"));
114 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
116 stream->print(F(
"\",name=\""));
118 stream->print(F(
"\"} 0\n"));
120 stream->print(F(
"esphome_binary_sensor_value{id=\""));
122 stream->print(F(
"\",name=\""));
124 stream->print(F(
"\"} "));
125 stream->print(obj->
state);
126 stream->print(F(
"\n"));
129 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
131 stream->print(F(
"\",name=\""));
133 stream->print(F(
"\"} 1\n"));
140 stream->print(F(
"#TYPE esphome_fan_value gauge\n"));
141 stream->print(F(
"#TYPE esphome_fan_failed gauge\n"));
142 stream->print(F(
"#TYPE esphome_fan_speed gauge\n"));
143 stream->print(F(
"#TYPE esphome_fan_oscillation gauge\n"));
148 stream->print(F(
"esphome_fan_failed{id=\""));
150 stream->print(F(
"\",name=\""));
152 stream->print(F(
"\"} 0\n"));
154 stream->print(F(
"esphome_fan_value{id=\""));
156 stream->print(F(
"\",name=\""));
158 stream->print(F(
"\"} "));
159 stream->print(obj->
state);
160 stream->print(F(
"\n"));
163 stream->print(F(
"esphome_fan_speed{id=\""));
165 stream->print(F(
"\",name=\""));
167 stream->print(F(
"\"} "));
168 stream->print(obj->
speed);
169 stream->print(F(
"\n"));
173 stream->print(F(
"esphome_fan_oscillation{id=\""));
175 stream->print(F(
"\",name=\""));
177 stream->print(F(
"\"} "));
179 stream->print(F(
"\n"));
186 stream->print(F(
"#TYPE esphome_light_state gauge\n"));
187 stream->print(F(
"#TYPE esphome_light_color gauge\n"));
188 stream->print(F(
"#TYPE esphome_light_effect_active gauge\n"));
194 stream->print(F(
"esphome_light_state{id=\""));
196 stream->print(F(
"\",name=\""));
198 stream->print(F(
"\"} "));
200 stream->print(F(
"\n"));
203 float brightness, r, g, b, w;
206 stream->print(F(
"esphome_light_color{id=\""));
208 stream->print(F(
"\",name=\""));
210 stream->print(F(
"\",channel=\"brightness\"} "));
211 stream->print(brightness);
212 stream->print(F(
"\n"));
213 stream->print(F(
"esphome_light_color{id=\""));
215 stream->print(F(
"\",name=\""));
217 stream->print(F(
"\",channel=\"r\"} "));
219 stream->print(F(
"\n"));
220 stream->print(F(
"esphome_light_color{id=\""));
222 stream->print(F(
"\",name=\""));
224 stream->print(F(
"\",channel=\"g\"} "));
226 stream->print(F(
"\n"));
227 stream->print(F(
"esphome_light_color{id=\""));
229 stream->print(F(
"\",name=\""));
231 stream->print(F(
"\",channel=\"b\"} "));
233 stream->print(F(
"\n"));
234 stream->print(F(
"esphome_light_color{id=\""));
236 stream->print(F(
"\",name=\""));
238 stream->print(F(
"\",channel=\"w\"} "));
240 stream->print(F(
"\n"));
243 if (effect ==
"None") {
244 stream->print(F(
"esphome_light_effect_active{id=\""));
246 stream->print(F(
"\",name=\""));
248 stream->print(F(
"\",effect=\"None\"} 0\n"));
250 stream->print(F(
"esphome_light_effect_active{id=\""));
252 stream->print(F(
"\",name=\""));
254 stream->print(F(
"\",effect=\""));
255 stream->print(effect.c_str());
256 stream->print(F(
"\"} 1\n"));
263 stream->print(F(
"#TYPE esphome_cover_value gauge\n"));
264 stream->print(F(
"#TYPE esphome_cover_failed gauge\n"));
271 stream->print(F(
"esphome_cover_failed{id=\""));
273 stream->print(F(
"\",name=\""));
275 stream->print(F(
"\"} 0\n"));
277 stream->print(F(
"esphome_cover_value{id=\""));
279 stream->print(F(
"\",name=\""));
281 stream->print(F(
"\"} "));
283 stream->print(F(
"\n"));
285 stream->print(F(
"esphome_cover_tilt{id=\""));
287 stream->print(F(
"\",name=\""));
289 stream->print(F(
"\"} "));
290 stream->print(obj->
tilt);
291 stream->print(F(
"\n"));
295 stream->print(F(
"esphome_cover_failed{id=\""));
297 stream->print(F(
"\",name=\""));
299 stream->print(F(
"\"} 1\n"));
306 stream->print(F(
"#TYPE esphome_switch_value gauge\n"));
307 stream->print(F(
"#TYPE esphome_switch_failed gauge\n"));
312 stream->print(F(
"esphome_switch_failed{id=\""));
314 stream->print(F(
"\",name=\""));
316 stream->print(F(
"\"} 0\n"));
318 stream->print(F(
"esphome_switch_value{id=\""));
320 stream->print(F(
"\",name=\""));
322 stream->print(F(
"\"} "));
323 stream->print(obj->
state);
324 stream->print(F(
"\n"));
330 stream->print(F(
"#TYPE esphome_lock_value gauge\n"));
331 stream->print(F(
"#TYPE esphome_lock_failed gauge\n"));
336 stream->print(F(
"esphome_lock_failed{id=\""));
338 stream->print(F(
"\",name=\""));
340 stream->print(F(
"\"} 0\n"));
342 stream->print(F(
"esphome_lock_value{id=\""));
344 stream->print(F(
"\",name=\""));
346 stream->print(F(
"\"} "));
347 stream->print(obj->
state);
348 stream->print(F(
"\n"));
Base class for all switches.
bool state
The current on/off state of the fan.
void handleRequest(AsyncWebServerRequest *req) override
This class represents the communication layer between the front-end MQTT layer and the hardware outpu...
bool oscillating
The current oscillation state of the fan.
void switch_row_(AsyncResponseStream *stream, switch_::Switch *obj)
Return the switch Values state as prometheus data point.
bool is_on() const
Get the binary true/false state of these light color values.
Base class for all cover devices.
std::string value_accuracy_to_string(float value, int8_t accuracy_decimals)
Create a string from a value and an accuracy in decimals.
LightColorValues current_values
The current values of the light as outputted to the light.
std::string get_effect_name()
Return the name of the current effect, or if no effect is active "None".
LockState state
The current reported state of the lock.
virtual FanTraits get_traits()=0
std::string relabel_id_(EntityBase *obj)
const std::vector< fan::Fan * > & get_fans()
void switch_type_(AsyncResponseStream *stream)
Return the type for prometheus.
bool supports_oscillation() const
Return if this fan supports oscillation.
float tilt
The current tilt value of the cover from 0.0 to 1.0.
std::string get_object_id() const
virtual CoverTraits get_traits()=0
const std::vector< lock::Lock * > & get_locks()
float state
This member variable stores the last state that has passed through all filters.
This class represents the color state for a light object.
void light_row_(AsyncResponseStream *stream, light::LightState *obj)
Return the Light Values state as prometheus data point.
virtual bool has_state() const
Return whether this binary sensor has outputted a state.
void binary_sensor_type_(AsyncResponseStream *stream)
Return the type for prometheus.
const std::vector< switch_::Switch * > & get_switches()
int speed
The current fan speed level.
void sensor_row_(AsyncResponseStream *stream, sensor::Sensor *obj)
Return the sensor state as prometheus data point.
std::string get_unit_of_measurement()
Get the unit of measurement, using the manual override if set.
std::map< EntityBase *, std::string > relabel_map_name_
bool state
The current reported state of the binary sensor.
const std::vector< sensor::Sensor * > & get_sensors()
Application App
Global storage of Application pointer - only one Application can exist.
void light_type_(AsyncResponseStream *stream)
Return the type for prometheus.
const std::vector< binary_sensor::BinarySensor * > & get_binary_sensors()
void binary_sensor_row_(AsyncResponseStream *stream, binary_sensor::BinarySensor *obj)
Return the sensor state as prometheus data point.
const std::vector< cover::Cover * > & get_covers()
void lock_row_(AsyncResponseStream *stream, lock::Lock *obj)
Return the lock Values state as prometheus data point.
void lock_type_(AsyncResponseStream *stream)
Return the type for prometheus.
float position
The position of the cover from 0.0 (fully closed) to 1.0 (fully open).
void fan_type_(AsyncResponseStream *stream)
Return the type for prometheus.
void sensor_type_(AsyncResponseStream *stream)
Return the type for prometheus.
const std::vector< light::LightState * > & get_lights()
void cover_type_(AsyncResponseStream *stream)
Return the type for prometheus.
std::string relabel_name_(EntityBase *obj)
bool get_supports_tilt() const
Implementation of SPI Controller mode.
Base class for all binary_sensor-type classes.
LightColorValues remote_values
The remote color values reported to the frontend.
void as_rgbw(float *red, float *green, float *blue, float *white, float gamma=0, bool color_interlock=false) const
Convert these light color values to an RGBW representation and write them to red, green...
int8_t get_accuracy_decimals()
Get the accuracy in decimals, using the manual override if set.
Base-class for all sensors.
void as_brightness(float *brightness, float gamma=0) const
Convert these light color values to a brightness-only representation and write them to brightness...
std::map< EntityBase *, std::string > relabel_map_id_
bool state
The current reported state of the binary sensor.
void cover_row_(AsyncResponseStream *stream, cover::Cover *obj)
Return the switch Values state as prometheus data point.
const StringRef & get_name() const
Base class for all locks.
void fan_row_(AsyncResponseStream *stream, fan::Fan *obj)
Return the sensor state as prometheus data point.
bool supports_speed() const
Return if this fan supports speed modes.