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 65 this->
number_row_(stream, obj, area, node, friendly_name);
71 this->
select_row_(stream, obj, area, node, friendly_name);
74 #ifdef USE_MEDIA_PLAYER 89 this->
valve_row_(stream, obj, area, node, friendly_name);
107 stream->print(F(
"\",area=\""));
108 stream->print(area.c_str());
114 stream->print(F(
"\",node=\""));
115 stream->print(node.c_str());
120 if (!friendly_name.empty()) {
121 stream->print(F(
"\",friendly_name=\""));
122 stream->print(friendly_name.c_str());
129 stream->print(F(
"#TYPE esphome_sensor_value gauge\n"));
130 stream->print(F(
"#TYPE esphome_sensor_failed gauge\n"));
133 std::string &node, std::string &friendly_name) {
136 if (!std::isnan(obj->
state)) {
138 stream->print(F(
"esphome_sensor_failed{id=\""));
143 stream->print(F(
"\",name=\""));
145 stream->print(F(
"\"} 0\n"));
147 stream->print(F(
"esphome_sensor_value{id=\""));
152 stream->print(F(
"\",name=\""));
154 stream->print(F(
"\",unit=\""));
156 stream->print(F(
"\"} "));
158 stream->print(F(
"\n"));
161 stream->print(F(
"esphome_sensor_failed{id=\""));
166 stream->print(F(
"\",name=\""));
168 stream->print(F(
"\"} 1\n"));
174 #ifdef USE_BINARY_SENSOR 176 stream->print(F(
"#TYPE esphome_binary_sensor_value gauge\n"));
177 stream->print(F(
"#TYPE esphome_binary_sensor_failed gauge\n"));
180 std::string &area, std::string &node, std::string &friendly_name) {
185 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
190 stream->print(F(
"\",name=\""));
192 stream->print(F(
"\"} 0\n"));
194 stream->print(F(
"esphome_binary_sensor_value{id=\""));
199 stream->print(F(
"\",name=\""));
201 stream->print(F(
"\"} "));
202 stream->print(obj->
state);
203 stream->print(F(
"\n"));
206 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
211 stream->print(F(
"\",name=\""));
213 stream->print(F(
"\"} 1\n"));
220 stream->print(F(
"#TYPE esphome_fan_value gauge\n"));
221 stream->print(F(
"#TYPE esphome_fan_failed gauge\n"));
222 stream->print(F(
"#TYPE esphome_fan_speed gauge\n"));
223 stream->print(F(
"#TYPE esphome_fan_oscillation gauge\n"));
226 std::string &friendly_name) {
229 stream->print(F(
"esphome_fan_failed{id=\""));
234 stream->print(F(
"\",name=\""));
236 stream->print(F(
"\"} 0\n"));
238 stream->print(F(
"esphome_fan_value{id=\""));
243 stream->print(F(
"\",name=\""));
245 stream->print(F(
"\"} "));
246 stream->print(obj->
state);
247 stream->print(F(
"\n"));
250 stream->print(F(
"esphome_fan_speed{id=\""));
255 stream->print(F(
"\",name=\""));
257 stream->print(F(
"\"} "));
258 stream->print(obj->
speed);
259 stream->print(F(
"\n"));
263 stream->print(F(
"esphome_fan_oscillation{id=\""));
268 stream->print(F(
"\",name=\""));
270 stream->print(F(
"\"} "));
272 stream->print(F(
"\n"));
279 stream->print(F(
"#TYPE esphome_light_state gauge\n"));
280 stream->print(F(
"#TYPE esphome_light_color gauge\n"));
281 stream->print(F(
"#TYPE esphome_light_effect_active gauge\n"));
284 std::string &node, std::string &friendly_name) {
288 stream->print(F(
"esphome_light_state{id=\""));
293 stream->print(F(
"\",name=\""));
295 stream->print(F(
"\"} "));
297 stream->print(F(
"\n"));
300 float brightness, r, g, b, w;
303 stream->print(F(
"esphome_light_color{id=\""));
308 stream->print(F(
"\",name=\""));
310 stream->print(F(
"\",channel=\"brightness\"} "));
311 stream->print(brightness);
312 stream->print(F(
"\n"));
313 stream->print(F(
"esphome_light_color{id=\""));
318 stream->print(F(
"\",name=\""));
320 stream->print(F(
"\",channel=\"r\"} "));
322 stream->print(F(
"\n"));
323 stream->print(F(
"esphome_light_color{id=\""));
328 stream->print(F(
"\",name=\""));
330 stream->print(F(
"\",channel=\"g\"} "));
332 stream->print(F(
"\n"));
333 stream->print(F(
"esphome_light_color{id=\""));
338 stream->print(F(
"\",name=\""));
340 stream->print(F(
"\",channel=\"b\"} "));
342 stream->print(F(
"\n"));
343 stream->print(F(
"esphome_light_color{id=\""));
348 stream->print(F(
"\",name=\""));
350 stream->print(F(
"\",channel=\"w\"} "));
352 stream->print(F(
"\n"));
355 if (effect ==
"None") {
356 stream->print(F(
"esphome_light_effect_active{id=\""));
361 stream->print(F(
"\",name=\""));
363 stream->print(F(
"\",effect=\"None\"} 0\n"));
365 stream->print(F(
"esphome_light_effect_active{id=\""));
370 stream->print(F(
"\",name=\""));
372 stream->print(F(
"\",effect=\""));
373 stream->print(effect.c_str());
374 stream->print(F(
"\"} 1\n"));
381 stream->print(F(
"#TYPE esphome_cover_value gauge\n"));
382 stream->print(F(
"#TYPE esphome_cover_failed gauge\n"));
385 std::string &friendly_name) {
390 stream->print(F(
"esphome_cover_failed{id=\""));
395 stream->print(F(
"\",name=\""));
397 stream->print(F(
"\"} 0\n"));
399 stream->print(F(
"esphome_cover_value{id=\""));
404 stream->print(F(
"\",name=\""));
406 stream->print(F(
"\"} "));
408 stream->print(F(
"\n"));
410 stream->print(F(
"esphome_cover_tilt{id=\""));
415 stream->print(F(
"\",name=\""));
417 stream->print(F(
"\"} "));
418 stream->print(obj->
tilt);
419 stream->print(F(
"\n"));
423 stream->print(F(
"esphome_cover_failed{id=\""));
428 stream->print(F(
"\",name=\""));
430 stream->print(F(
"\"} 1\n"));
437 stream->print(F(
"#TYPE esphome_switch_value gauge\n"));
438 stream->print(F(
"#TYPE esphome_switch_failed gauge\n"));
441 std::string &node, std::string &friendly_name) {
444 stream->print(F(
"esphome_switch_failed{id=\""));
449 stream->print(F(
"\",name=\""));
451 stream->print(F(
"\"} 0\n"));
453 stream->print(F(
"esphome_switch_value{id=\""));
458 stream->print(F(
"\",name=\""));
460 stream->print(F(
"\"} "));
461 stream->print(obj->
state);
462 stream->print(F(
"\n"));
468 stream->print(F(
"#TYPE esphome_lock_value gauge\n"));
469 stream->print(F(
"#TYPE esphome_lock_failed gauge\n"));
472 std::string &friendly_name) {
475 stream->print(F(
"esphome_lock_failed{id=\""));
480 stream->print(F(
"\",name=\""));
482 stream->print(F(
"\"} 0\n"));
484 stream->print(F(
"esphome_lock_value{id=\""));
489 stream->print(F(
"\",name=\""));
491 stream->print(F(
"\"} "));
492 stream->print(obj->
state);
493 stream->print(F(
"\n"));
498 #ifdef USE_TEXT_SENSOR 500 stream->print(F(
"#TYPE esphome_text_sensor_value gauge\n"));
501 stream->print(F(
"#TYPE esphome_text_sensor_failed gauge\n"));
504 std::string &node, std::string &friendly_name) {
509 stream->print(F(
"esphome_text_sensor_failed{id=\""));
514 stream->print(F(
"\",name=\""));
516 stream->print(F(
"\"} 0\n"));
518 stream->print(F(
"esphome_text_sensor_value{id=\""));
523 stream->print(F(
"\",name=\""));
525 stream->print(F(
"\",value=\""));
526 stream->print(obj->
state.c_str());
527 stream->print(F(
"\"} "));
528 stream->print(F(
"1.0"));
529 stream->print(F(
"\n"));
532 stream->print(F(
"esphome_text_sensor_failed{id=\""));
537 stream->print(F(
"\",name=\""));
539 stream->print(F(
"\"} 1\n"));
547 stream->print(F(
"#TYPE esphome_number_value gauge\n"));
548 stream->print(F(
"#TYPE esphome_number_failed gauge\n"));
551 std::string &node, std::string &friendly_name) {
554 if (!std::isnan(obj->
state)) {
556 stream->print(F(
"esphome_number_failed{id=\""));
561 stream->print(F(
"\",name=\""));
563 stream->print(F(
"\"} 0\n"));
565 stream->print(F(
"esphome_number_value{id=\""));
570 stream->print(F(
"\",name=\""));
572 stream->print(F(
"\"} "));
573 stream->print(obj->
state);
574 stream->print(F(
"\n"));
577 stream->print(F(
"esphome_number_failed{id=\""));
582 stream->print(F(
"\",name=\""));
584 stream->print(F(
"\"} 1\n"));
591 stream->print(F(
"#TYPE esphome_select_value gauge\n"));
592 stream->print(F(
"#TYPE esphome_select_failed gauge\n"));
595 std::string &node, std::string &friendly_name) {
600 stream->print(F(
"esphome_select_failed{id=\""));
605 stream->print(F(
"\",name=\""));
607 stream->print(F(
"\"} 0\n"));
609 stream->print(F(
"esphome_select_value{id=\""));
614 stream->print(F(
"\",name=\""));
616 stream->print(F(
"\",value=\""));
617 stream->print(obj->
state.c_str());
618 stream->print(F(
"\"} "));
619 stream->print(F(
"1.0"));
620 stream->print(F(
"\n"));
623 stream->print(F(
"esphome_select_failed{id=\""));
628 stream->print(F(
"\",name=\""));
630 stream->print(F(
"\"} 1\n"));
635 #ifdef USE_MEDIA_PLAYER 637 stream->print(F(
"#TYPE esphome_media_player_state_value gauge\n"));
638 stream->print(F(
"#TYPE esphome_media_player_volume gauge\n"));
639 stream->print(F(
"#TYPE esphome_media_player_is_muted gauge\n"));
640 stream->print(F(
"#TYPE esphome_media_player_failed gauge\n"));
643 std::string &area, std::string &node, std::string &friendly_name) {
646 stream->print(F(
"esphome_media_player_failed{id=\""));
651 stream->print(F(
"\",name=\""));
653 stream->print(F(
"\"} 0\n"));
655 stream->print(F(
"esphome_media_player_state_value{id=\""));
660 stream->print(F(
"\",name=\""));
662 stream->print(F(
"\",value=\""));
664 stream->print(F(
"\"} "));
665 stream->print(F(
"1.0"));
666 stream->print(F(
"\n"));
667 stream->print(F(
"esphome_media_player_volume{id=\""));
672 stream->print(F(
"\",name=\""));
674 stream->print(F(
"\"} "));
675 stream->print(obj->
volume);
676 stream->print(F(
"\n"));
677 stream->print(F(
"esphome_media_player_is_muted{id=\""));
682 stream->print(F(
"\",name=\""));
684 stream->print(F(
"\"} "));
686 stream->print(F(
"1.0"));
688 stream->print(F(
"0.0"));
690 stream->print(F(
"\n"));
696 stream->print(F(
"#TYPE esphome_update_entity_state gauge\n"));
697 stream->print(F(
"#TYPE esphome_update_entity_info gauge\n"));
698 stream->print(F(
"#TYPE esphome_update_entity_failed gauge\n"));
704 stream->print(
"unknown");
707 stream->print(
"none");
710 stream->print(
"available");
713 stream->print(
"installing");
716 stream->print(
"invalid");
722 std::string &node, std::string &friendly_name) {
727 stream->print(F(
"esphome_update_entity_failed{id=\""));
732 stream->print(F(
"\",name=\""));
734 stream->print(F(
"\"} 0\n"));
736 stream->print(F(
"esphome_update_entity_state{id=\""));
741 stream->print(F(
"\",name=\""));
743 stream->print(F(
"\",value=\""));
745 stream->print(F(
"\"} "));
746 stream->print(F(
"1.0"));
747 stream->print(F(
"\n"));
749 stream->print(F(
"esphome_update_entity_info{id=\""));
754 stream->print(F(
"\",name=\""));
756 stream->print(F(
"\",current_version=\""));
758 stream->print(F(
"\",latest_version=\""));
760 stream->print(F(
"\",title=\""));
762 stream->print(F(
"\"} "));
763 stream->print(F(
"1.0"));
764 stream->print(F(
"\n"));
767 stream->print(F(
"esphome_update_entity_failed{id=\""));
772 stream->print(F(
"\",name=\""));
774 stream->print(F(
"\"} 1\n"));
781 stream->print(F(
"#TYPE esphome_valve_operation gauge\n"));
782 stream->print(F(
"#TYPE esphome_valve_failed gauge\n"));
783 stream->print(F(
"#TYPE esphome_valve_position gauge\n"));
787 std::string &friendly_name) {
790 stream->print(F(
"esphome_valve_failed{id=\""));
795 stream->print(F(
"\",name=\""));
797 stream->print(F(
"\"} 0\n"));
799 stream->print(F(
"esphome_valve_operation{id=\""));
804 stream->print(F(
"\",name=\""));
806 stream->print(F(
"\",operation=\""));
808 stream->print(F(
"\"} "));
809 stream->print(F(
"1.0"));
810 stream->print(F(
"\n"));
813 stream->print(F(
"esphome_valve_position{id=\""));
818 stream->print(F(
"\",name=\""));
820 stream->print(F(
"\"} "));
822 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.
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.
const std::vector< update::UpdateEntity * > & get_updates()
void select_type_(AsyncResponseStream *stream)
Return the type for prometheus.
const std::vector< valve::Valve * > & get_valves()
float position
The position of the valve from 0.0 (fully closed) to 1.0 (fully open).
virtual FanTraits get_traits()=0
const UpdateState & state
std::string latest_version
std::string relabel_id_(EntityBase *obj)
std::string current_version
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 update_entity_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)
virtual ValveTraits get_traits()=0
void number_row_(AsyncResponseStream *stream, number::Number *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the number state as prometheus data point.
float tilt
The current tilt value of the cover from 0.0 to 1.0.
std::string get_object_id() const
void valve_type_(AsyncResponseStream *stream)
Return the type for prometheus.
void binary_sensor_row_(AsyncResponseStream *stream, binary_sensor::BinarySensor *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the binary sensor state as prometheus data point.
virtual CoverTraits get_traits()=0
const std::vector< lock::Lock * > & get_locks()
void media_player_type_(AsyncResponseStream *stream)
Return the type for prometheus.
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 text sensor values state as prometheus data point.
const UpdateInfo & update_info
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()
Base-class for all numbers.
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 fan 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.
void select_row_(AsyncResponseStream *stream, select::Select *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the select state as prometheus data point.
void update_entity_row_(AsyncResponseStream *stream, update::UpdateEntity *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the update state and info 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()
void handle_update_state_(AsyncResponseStream *stream, update::UpdateState state)
bool get_supports_position() const
const std::string & get_name() const
Get the name of this Application set by pre_setup().
void number_type_(AsyncResponseStream *stream)
Return the type for prometheus.
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.
const char * valve_operation_to_str(ValveOperation op)
void media_player_row_(AsyncResponseStream *stream, media_player::MediaPlayer *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the media player state as prometheus data point.
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 cover values state as prometheus data point.
const std::vector< media_player::MediaPlayer * > & get_media_players()
Base-class for all selects.
Implementation of SPI Controller mode.
bool has_state() const
Return whether this select component has gotten a full state yet.
Base class for all valve devices.
ValveOperation current_operation
The current operation of the valve (idle, opening, closing).
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.
const std::vector< select::Select * > & get_selects()
Base-class for all sensors.
const std::vector< number::Number * > & get_numbers()
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
void valve_row_(AsyncResponseStream *stream, valve::Valve *obj, std::string &area, std::string &node, std::string &friendly_name)
Return the valve state as prometheus data point.
Base class for all locks.
bool supports_speed() const
Return if this fan supports speed modes.