8 AsyncResponseStream *stream = req->beginResponseStream(
"text/plain; version=0.0.4; charset=utf-8");
16 #ifdef USE_BINARY_SENSOR 68 stream->print(F(
"#TYPE esphome_sensor_value gauge\n"));
69 stream->print(F(
"#TYPE esphome_sensor_failed gauge\n"));
74 if (!std::isnan(obj->
state)) {
76 stream->print(F(
"esphome_sensor_failed{id=\""));
78 stream->print(F(
"\",name=\""));
80 stream->print(F(
"\"} 0\n"));
82 stream->print(F(
"esphome_sensor_value{id=\""));
84 stream->print(F(
"\",name=\""));
86 stream->print(F(
"\",unit=\""));
88 stream->print(F(
"\"} "));
90 stream->print(F(
"\n"));
93 stream->print(F(
"esphome_sensor_failed{id=\""));
95 stream->print(F(
"\",name=\""));
97 stream->print(F(
"\"} 1\n"));
103 #ifdef USE_BINARY_SENSOR 105 stream->print(F(
"#TYPE esphome_binary_sensor_value gauge\n"));
106 stream->print(F(
"#TYPE esphome_binary_sensor_failed gauge\n"));
113 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
115 stream->print(F(
"\",name=\""));
117 stream->print(F(
"\"} 0\n"));
119 stream->print(F(
"esphome_binary_sensor_value{id=\""));
121 stream->print(F(
"\",name=\""));
123 stream->print(F(
"\"} "));
124 stream->print(obj->
state);
125 stream->print(F(
"\n"));
128 stream->print(F(
"esphome_binary_sensor_failed{id=\""));
130 stream->print(F(
"\",name=\""));
132 stream->print(F(
"\"} 1\n"));
139 stream->print(F(
"#TYPE esphome_fan_value gauge\n"));
140 stream->print(F(
"#TYPE esphome_fan_failed gauge\n"));
141 stream->print(F(
"#TYPE esphome_fan_speed gauge\n"));
142 stream->print(F(
"#TYPE esphome_fan_oscillation gauge\n"));
147 stream->print(F(
"esphome_fan_failed{id=\""));
149 stream->print(F(
"\",name=\""));
151 stream->print(F(
"\"} 0\n"));
153 stream->print(F(
"esphome_fan_value{id=\""));
155 stream->print(F(
"\",name=\""));
157 stream->print(F(
"\"} "));
158 stream->print(obj->
state);
159 stream->print(F(
"\n"));
162 stream->print(F(
"esphome_fan_speed{id=\""));
164 stream->print(F(
"\",name=\""));
166 stream->print(F(
"\"} "));
167 stream->print(obj->
speed);
168 stream->print(F(
"\n"));
172 stream->print(F(
"esphome_fan_oscillation{id=\""));
174 stream->print(F(
"\",name=\""));
176 stream->print(F(
"\"} "));
178 stream->print(F(
"\n"));
185 stream->print(F(
"#TYPE esphome_light_state gauge\n"));
186 stream->print(F(
"#TYPE esphome_light_color gauge\n"));
187 stream->print(F(
"#TYPE esphome_light_effect_active gauge\n"));
193 stream->print(F(
"esphome_light_state{id=\""));
195 stream->print(F(
"\",name=\""));
197 stream->print(F(
"\"} "));
199 stream->print(F(
"\n"));
202 float brightness, r, g, b, w;
205 stream->print(F(
"esphome_light_color{id=\""));
207 stream->print(F(
"\",name=\""));
209 stream->print(F(
"\",channel=\"brightness\"} "));
210 stream->print(brightness);
211 stream->print(F(
"\n"));
212 stream->print(F(
"esphome_light_color{id=\""));
214 stream->print(F(
"\",name=\""));
216 stream->print(F(
"\",channel=\"r\"} "));
218 stream->print(F(
"\n"));
219 stream->print(F(
"esphome_light_color{id=\""));
221 stream->print(F(
"\",name=\""));
223 stream->print(F(
"\",channel=\"g\"} "));
225 stream->print(F(
"\n"));
226 stream->print(F(
"esphome_light_color{id=\""));
228 stream->print(F(
"\",name=\""));
230 stream->print(F(
"\",channel=\"b\"} "));
232 stream->print(F(
"\n"));
233 stream->print(F(
"esphome_light_color{id=\""));
235 stream->print(F(
"\",name=\""));
237 stream->print(F(
"\",channel=\"w\"} "));
239 stream->print(F(
"\n"));
242 if (effect ==
"None") {
243 stream->print(F(
"esphome_light_effect_active{id=\""));
245 stream->print(F(
"\",name=\""));
247 stream->print(F(
"\",effect=\"None\"} 0\n"));
249 stream->print(F(
"esphome_light_effect_active{id=\""));
251 stream->print(F(
"\",name=\""));
253 stream->print(F(
"\",effect=\""));
254 stream->print(effect.c_str());
255 stream->print(F(
"\"} 1\n"));
262 stream->print(F(
"#TYPE esphome_cover_value gauge\n"));
263 stream->print(F(
"#TYPE esphome_cover_failed gauge\n"));
270 stream->print(F(
"esphome_cover_failed{id=\""));
272 stream->print(F(
"\",name=\""));
274 stream->print(F(
"\"} 0\n"));
276 stream->print(F(
"esphome_cover_value{id=\""));
278 stream->print(F(
"\",name=\""));
280 stream->print(F(
"\"} "));
282 stream->print(F(
"\n"));
284 stream->print(F(
"esphome_cover_tilt{id=\""));
286 stream->print(F(
"\",name=\""));
288 stream->print(F(
"\"} "));
289 stream->print(obj->
tilt);
290 stream->print(F(
"\n"));
294 stream->print(F(
"esphome_cover_failed{id=\""));
296 stream->print(F(
"\",name=\""));
298 stream->print(F(
"\"} 1\n"));
305 stream->print(F(
"#TYPE esphome_switch_value gauge\n"));
306 stream->print(F(
"#TYPE esphome_switch_failed gauge\n"));
311 stream->print(F(
"esphome_switch_failed{id=\""));
313 stream->print(F(
"\",name=\""));
315 stream->print(F(
"\"} 0\n"));
317 stream->print(F(
"esphome_switch_value{id=\""));
319 stream->print(F(
"\",name=\""));
321 stream->print(F(
"\"} "));
322 stream->print(obj->
state);
323 stream->print(F(
"\n"));
329 stream->print(F(
"#TYPE esphome_lock_value gauge\n"));
330 stream->print(F(
"#TYPE esphome_lock_failed gauge\n"));
335 stream->print(F(
"esphome_lock_failed{id=\""));
337 stream->print(F(
"\",name=\""));
339 stream->print(F(
"\"} 0\n"));
341 stream->print(F(
"esphome_lock_value{id=\""));
343 stream->print(F(
"\",name=\""));
345 stream->print(F(
"\"} "));
346 stream->print(obj->
state);
347 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.