10 AsyncResponseStream *stream = req->beginResponseStream(
"text/plain; version=0.0.4; charset=utf-8");
18 #ifdef USE_BINARY_SENSOR 70 stream->print(F(
"#TYPE esphome_sensor_value GAUGE\n"));
71 stream->print(F(
"#TYPE esphome_sensor_failed GAUGE\n"));
76 if (!std::isnan(obj->
state)) {
78 stream->print(F(
"esphome_sensor_failed{id=\""));
80 stream->print(F(
"\",name=\""));
82 stream->print(F(
"\"} 0\n"));
84 stream->print(F(
"esphome_sensor_value{id=\""));
86 stream->print(F(
"\",name=\""));
88 stream->print(F(
"\",unit=\""));
90 stream->print(F(
"\"} "));
95 stream->print(F(
"esphome_sensor_failed{id=\""));
97 stream->print(F(
"\",name=\""));
99 stream->print(F(
"\"} 1\n"));
105 #ifdef USE_BINARY_SENSOR 107 stream->print(F(
"#TYPE esphome_binary_sensor_value GAUGE\n"));
108 stream->print(F(
"#TYPE esphome_binary_sensor_failed GAUGE\n"));
115 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
117 stream->print(F(
"\",name=\""));
119 stream->print(F(
"\"} 0\n"));
121 stream->print(F(
"esphome_binary_sensor_value{id=\""));
123 stream->print(F(
"\",name=\""));
125 stream->print(F(
"\"} "));
126 stream->print(obj->
state);
130 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
132 stream->print(F(
"\",name=\""));
134 stream->print(F(
"\"} 1\n"));
141 stream->print(F(
"#TYPE esphome_fan_value GAUGE\n"));
142 stream->print(F(
"#TYPE esphome_fan_failed GAUGE\n"));
143 stream->print(F(
"#TYPE esphome_fan_speed GAUGE\n"));
144 stream->print(F(
"#TYPE esphome_fan_oscillation GAUGE\n"));
149 stream->print(F(
"esphome_fan_failed{id=\""));
151 stream->print(F(
"\",name=\""));
153 stream->print(F(
"\"} 0\n"));
155 stream->print(F(
"esphome_fan_value{id=\""));
157 stream->print(F(
"\",name=\""));
159 stream->print(F(
"\"} "));
160 stream->print(obj->
state);
164 stream->print(F(
"esphome_fan_speed{id=\""));
166 stream->print(F(
"\",name=\""));
168 stream->print(F(
"\"} "));
169 stream->print(obj->
speed);
174 stream->print(F(
"esphome_fan_oscillation{id=\""));
176 stream->print(F(
"\",name=\""));
178 stream->print(F(
"\"} "));
187 stream->print(F(
"#TYPE esphome_light_state GAUGE\n"));
188 stream->print(F(
"#TYPE esphome_light_color GAUGE\n"));
189 stream->print(F(
"#TYPE esphome_light_effect_active GAUGE\n"));
195 stream->print(F(
"esphome_light_state{id=\""));
197 stream->print(F(
"\",name=\""));
199 stream->print(F(
"\"} "));
201 stream->print(F(
"\n"));
204 float brightness, r, g, b, w;
207 stream->print(F(
"esphome_light_color{id=\""));
209 stream->print(F(
"\",name=\""));
211 stream->print(F(
"\",channel=\"brightness\"} "));
212 stream->print(brightness);
213 stream->print(F(
"\n"));
214 stream->print(F(
"esphome_light_color{id=\""));
216 stream->print(F(
"\",name=\""));
218 stream->print(F(
"\",channel=\"r\"} "));
220 stream->print(F(
"\n"));
221 stream->print(F(
"esphome_light_color{id=\""));
223 stream->print(F(
"\",name=\""));
225 stream->print(F(
"\",channel=\"g\"} "));
227 stream->print(F(
"\n"));
228 stream->print(F(
"esphome_light_color{id=\""));
230 stream->print(F(
"\",name=\""));
232 stream->print(F(
"\",channel=\"b\"} "));
234 stream->print(F(
"\n"));
235 stream->print(F(
"esphome_light_color{id=\""));
237 stream->print(F(
"\",name=\""));
239 stream->print(F(
"\",channel=\"w\"} "));
241 stream->print(F(
"\n"));
244 if (effect ==
"None") {
245 stream->print(F(
"esphome_light_effect_active{id=\""));
247 stream->print(F(
"\",name=\""));
249 stream->print(F(
"\",effect=\"None\"} 0\n"));
251 stream->print(F(
"esphome_light_effect_active{id=\""));
253 stream->print(F(
"\",name=\""));
255 stream->print(F(
"\",effect=\""));
256 stream->print(effect.c_str());
257 stream->print(F(
"\"} 1\n"));
264 stream->print(F(
"#TYPE esphome_cover_value GAUGE\n"));
265 stream->print(F(
"#TYPE esphome_cover_failed GAUGE\n"));
272 stream->print(F(
"esphome_cover_failed{id=\""));
274 stream->print(F(
"\",name=\""));
276 stream->print(F(
"\"} 0\n"));
278 stream->print(F(
"esphome_cover_value{id=\""));
280 stream->print(F(
"\",name=\""));
282 stream->print(F(
"\"} "));
286 stream->print(F(
"esphome_cover_tilt{id=\""));
288 stream->print(F(
"\",name=\""));
290 stream->print(F(
"\"} "));
291 stream->print(obj->
tilt);
296 stream->print(F(
"esphome_cover_failed{id=\""));
298 stream->print(F(
"\",name=\""));
300 stream->print(F(
"\"} 1\n"));
307 stream->print(F(
"#TYPE esphome_switch_value GAUGE\n"));
308 stream->print(F(
"#TYPE esphome_switch_failed GAUGE\n"));
313 stream->print(F(
"esphome_switch_failed{id=\""));
315 stream->print(F(
"\",name=\""));
317 stream->print(F(
"\"} 0\n"));
319 stream->print(F(
"esphome_switch_value{id=\""));
321 stream->print(F(
"\",name=\""));
323 stream->print(F(
"\"} "));
324 stream->print(obj->
state);
331 stream->print(F(
"#TYPE esphome_lock_value GAUGE\n"));
332 stream->print(F(
"#TYPE esphome_lock_failed GAUGE\n"));
337 stream->print(F(
"esphome_lock_failed{id=\""));
339 stream->print(F(
"\",name=\""));
341 stream->print(F(
"\"} 0\n"));
343 stream->print(F(
"esphome_lock_value{id=\""));
345 stream->print(F(
"\",name=\""));
347 stream->print(F(
"\"} "));
348 stream->print(obj->
state);
356 #endif // USE_ARDUINO 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
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.