9 AsyncResponseStream *stream = req->beginResponseStream(
"text/plain; version=0.0.4; charset=utf-8");
17 this->
sensor_row_(stream, obj, area, node, friendly_name);
20 #ifdef USE_BINARY_SENSOR 29 this->
fan_row_(stream, obj, area, node, friendly_name);
35 this->
light_row_(stream, obj, area, node, friendly_name);
41 this->
cover_row_(stream, obj, area, node, friendly_name);
47 this->
switch_row_(stream, obj, area, node, friendly_name);
53 this->
lock_row_(stream, obj, area, node, friendly_name);
56 #ifdef USE_TEXT_SENSOR 77 stream->print(F(
"\",area=\""));
78 stream->print(area.c_str());
84 stream->print(F(
"\",node=\""));
85 stream->print(node.c_str());
90 if (!friendly_name.empty()) {
91 stream->print(F(
"\",friendly_name=\""));
92 stream->print(friendly_name.c_str());
99 stream->print(F(
"#TYPE esphome_sensor_value gauge\n"));
100 stream->print(F(
"#TYPE esphome_sensor_failed gauge\n"));
103 std::string &node, std::string &friendly_name) {
106 if (!std::isnan(obj->
state)) {
108 stream->print(F(
"esphome_sensor_failed{id=\""));
113 stream->print(F(
"\",name=\""));
115 stream->print(F(
"\"} 0\n"));
117 stream->print(F(
"esphome_sensor_value{id=\""));
122 stream->print(F(
"\",name=\""));
124 stream->print(F(
"\",unit=\""));
126 stream->print(F(
"\"} "));
128 stream->print(F(
"\n"));
131 stream->print(F(
"esphome_sensor_failed{id=\""));
136 stream->print(F(
"\",name=\""));
138 stream->print(F(
"\"} 1\n"));
144 #ifdef USE_BINARY_SENSOR 146 stream->print(F(
"#TYPE esphome_binary_sensor_value gauge\n"));
147 stream->print(F(
"#TYPE esphome_binary_sensor_failed gauge\n"));
150 std::string &area, std::string &node, std::string &friendly_name) {
155 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
160 stream->print(F(
"\",name=\""));
162 stream->print(F(
"\"} 0\n"));
164 stream->print(F(
"esphome_binary_sensor_value{id=\""));
169 stream->print(F(
"\",name=\""));
171 stream->print(F(
"\"} "));
172 stream->print(obj->
state);
173 stream->print(F(
"\n"));
176 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
181 stream->print(F(
"\",name=\""));
183 stream->print(F(
"\"} 1\n"));
190 stream->print(F(
"#TYPE esphome_fan_value gauge\n"));
191 stream->print(F(
"#TYPE esphome_fan_failed gauge\n"));
192 stream->print(F(
"#TYPE esphome_fan_speed gauge\n"));
193 stream->print(F(
"#TYPE esphome_fan_oscillation gauge\n"));
196 std::string &friendly_name) {
199 stream->print(F(
"esphome_fan_failed{id=\""));
204 stream->print(F(
"\",name=\""));
206 stream->print(F(
"\"} 0\n"));
208 stream->print(F(
"esphome_fan_value{id=\""));
213 stream->print(F(
"\",name=\""));
215 stream->print(F(
"\"} "));
216 stream->print(obj->
state);
217 stream->print(F(
"\n"));
220 stream->print(F(
"esphome_fan_speed{id=\""));
225 stream->print(F(
"\",name=\""));
227 stream->print(F(
"\"} "));
228 stream->print(obj->
speed);
229 stream->print(F(
"\n"));
233 stream->print(F(
"esphome_fan_oscillation{id=\""));
238 stream->print(F(
"\",name=\""));
240 stream->print(F(
"\"} "));
242 stream->print(F(
"\n"));
249 stream->print(F(
"#TYPE esphome_light_state gauge\n"));
250 stream->print(F(
"#TYPE esphome_light_color gauge\n"));
251 stream->print(F(
"#TYPE esphome_light_effect_active gauge\n"));
254 std::string &node, std::string &friendly_name) {
258 stream->print(F(
"esphome_light_state{id=\""));
263 stream->print(F(
"\",name=\""));
265 stream->print(F(
"\"} "));
267 stream->print(F(
"\n"));
270 float brightness, r, g, b, w;
273 stream->print(F(
"esphome_light_color{id=\""));
278 stream->print(F(
"\",name=\""));
280 stream->print(F(
"\",channel=\"brightness\"} "));
281 stream->print(brightness);
282 stream->print(F(
"\n"));
283 stream->print(F(
"esphome_light_color{id=\""));
288 stream->print(F(
"\",name=\""));
290 stream->print(F(
"\",channel=\"r\"} "));
292 stream->print(F(
"\n"));
293 stream->print(F(
"esphome_light_color{id=\""));
298 stream->print(F(
"\",name=\""));
300 stream->print(F(
"\",channel=\"g\"} "));
302 stream->print(F(
"\n"));
303 stream->print(F(
"esphome_light_color{id=\""));
308 stream->print(F(
"\",name=\""));
310 stream->print(F(
"\",channel=\"b\"} "));
312 stream->print(F(
"\n"));
313 stream->print(F(
"esphome_light_color{id=\""));
318 stream->print(F(
"\",name=\""));
320 stream->print(F(
"\",channel=\"w\"} "));
322 stream->print(F(
"\n"));
325 if (effect ==
"None") {
326 stream->print(F(
"esphome_light_effect_active{id=\""));
331 stream->print(F(
"\",name=\""));
333 stream->print(F(
"\",effect=\"None\"} 0\n"));
335 stream->print(F(
"esphome_light_effect_active{id=\""));
340 stream->print(F(
"\",name=\""));
342 stream->print(F(
"\",effect=\""));
343 stream->print(effect.c_str());
344 stream->print(F(
"\"} 1\n"));
351 stream->print(F(
"#TYPE esphome_cover_value gauge\n"));
352 stream->print(F(
"#TYPE esphome_cover_failed gauge\n"));
355 std::string &friendly_name) {
360 stream->print(F(
"esphome_cover_failed{id=\""));
365 stream->print(F(
"\",name=\""));
367 stream->print(F(
"\"} 0\n"));
369 stream->print(F(
"esphome_cover_value{id=\""));
374 stream->print(F(
"\",name=\""));
376 stream->print(F(
"\"} "));
378 stream->print(F(
"\n"));
380 stream->print(F(
"esphome_cover_tilt{id=\""));
385 stream->print(F(
"\",name=\""));
387 stream->print(F(
"\"} "));
388 stream->print(obj->
tilt);
389 stream->print(F(
"\n"));
393 stream->print(F(
"esphome_cover_failed{id=\""));
398 stream->print(F(
"\",name=\""));
400 stream->print(F(
"\"} 1\n"));
407 stream->print(F(
"#TYPE esphome_switch_value gauge\n"));
408 stream->print(F(
"#TYPE esphome_switch_failed gauge\n"));
411 std::string &node, std::string &friendly_name) {
414 stream->print(F(
"esphome_switch_failed{id=\""));
419 stream->print(F(
"\",name=\""));
421 stream->print(F(
"\"} 0\n"));
423 stream->print(F(
"esphome_switch_value{id=\""));
428 stream->print(F(
"\",name=\""));
430 stream->print(F(
"\"} "));
431 stream->print(obj->
state);
432 stream->print(F(
"\n"));
438 stream->print(F(
"#TYPE esphome_lock_value gauge\n"));
439 stream->print(F(
"#TYPE esphome_lock_failed gauge\n"));
442 std::string &friendly_name) {
445 stream->print(F(
"esphome_lock_failed{id=\""));
450 stream->print(F(
"\",name=\""));
452 stream->print(F(
"\"} 0\n"));
454 stream->print(F(
"esphome_lock_value{id=\""));
459 stream->print(F(
"\",name=\""));
461 stream->print(F(
"\"} "));
462 stream->print(obj->
state);
463 stream->print(F(
"\n"));
468 #ifdef USE_TEXT_SENSOR 470 stream->print(F(
"#TYPE esphome_text_sensor_value gauge\n"));
471 stream->print(F(
"#TYPE esphome_text_sensor_failed gauge\n"));
474 std::string &node, std::string &friendly_name) {
479 stream->print(F(
"esphome_text_sensor_failed{id=\""));
484 stream->print(F(
"\",name=\""));
486 stream->print(F(
"\"} 0\n"));
488 stream->print(F(
"esphome_text_sensor_value{id=\""));
493 stream->print(F(
"\",name=\""));
495 stream->print(F(
"\",value=\""));
496 stream->print(obj->
state.c_str());
497 stream->print(F(
"\"} "));
498 stream->print(F(
"1.0"));
499 stream->print(F(
"\n"));
502 stream->print(F(
"esphome_text_sensor_failed{id=\""));
507 stream->print(F(
"\",name=\""));
509 stream->print(F(
"\"} 1\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.
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.
void add_node_label_(AsyncResponseStream *stream, std::string &node)
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::string & get_area() const
Get the area of this Application set by pre_setup().
const std::string & get_friendly_name() const
Get the friendly name of this Application set by pre_setup().
const std::vector< fan::Fan * > & get_fans()
void text_sensor_type_(AsyncResponseStream *stream)
Return the type for prometheus.
void switch_type_(AsyncResponseStream *stream)
Return the type for prometheus.
bool supports_oscillation() const
Return if this fan supports oscillation.
void add_area_label_(AsyncResponseStream *stream, std::string &area)
float tilt
The current tilt value of the cover from 0.0 to 1.0.
std::string get_object_id() const
void binary_sensor_row_(AsyncResponseStream *stream, binary_sensor::BinarySensor *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the sensor state as prometheus data point.
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 text_sensor_row_(AsyncResponseStream *stream, text_sensor::TextSensor *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the lock 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()
void add_friendly_name_label_(AsyncResponseStream *stream, std::string &friendly_name)
int speed
The current fan speed level.
void fan_row_(AsyncResponseStream *stream, fan::Fan *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the sensor state as prometheus data point.
void switch_row_(AsyncResponseStream *stream, switch_::Switch *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the switch Values state as prometheus data point.
std::string get_unit_of_measurement()
Get the unit of measurement, using the manual override if set.
const std::vector< text_sensor::TextSensor * > & get_text_sensors()
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()
const std::string & get_name() const
Get the name of this Application set by pre_setup().
void lock_row_(AsyncResponseStream *stream, lock::Lock *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the lock Values state as prometheus data point.
const std::vector< cover::Cover * > & get_covers()
void lock_type_(AsyncResponseStream *stream)
Return the type for prometheus.
void sensor_row_(AsyncResponseStream *stream, sensor::Sensor *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the sensor state as prometheus data point.
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
void cover_row_(AsyncResponseStream *stream, cover::Cover *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the switch Values state as prometheus data point.
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_
void light_row_(AsyncResponseStream *stream, light::LightState *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the Light Values state as prometheus data point.
bool state
The current reported state of the binary sensor.
const StringRef & get_name() const
Base class for all locks.
bool supports_speed() const
Return if this fan supports speed modes.