esphome 2024.10.3__py3-none-any.whl → 2024.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- esphome/__main__.py +22 -4
- esphome/automation.py +29 -2
- esphome/components/animation/__init__.py +5 -8
- esphome/components/animation/animation.cpp +1 -1
- esphome/components/audio/__init__.py +9 -0
- esphome/components/audio/audio.h +21 -0
- esphome/components/axs15231/__init__.py +6 -0
- esphome/components/axs15231/touchscreen/__init__.py +36 -0
- esphome/components/axs15231/touchscreen/axs15231_touchscreen.cpp +64 -0
- esphome/components/axs15231/touchscreen/axs15231_touchscreen.h +27 -0
- esphome/components/bme68x_bsec2/__init__.py +1 -1
- esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +50 -47
- esphome/components/bme68x_bsec2/bme68x_bsec2.h +0 -2
- esphome/components/bytebuffer/__init__.py +5 -0
- esphome/components/bytebuffer/bytebuffer.h +421 -0
- esphome/components/climate/__init__.py +14 -13
- esphome/components/datetime/__init__.py +3 -3
- esphome/components/debug/debug_esp32.cpp +16 -8
- esphome/components/dfplayer/dfplayer.cpp +132 -6
- esphome/components/dfplayer/dfplayer.h +19 -53
- esphome/components/display/display.cpp +142 -0
- esphome/components/display/display.h +7 -0
- esphome/components/es8311/__init__.py +0 -0
- esphome/components/es8311/audio_dac.py +70 -0
- esphome/components/es8311/es8311.cpp +227 -0
- esphome/components/es8311/es8311.h +135 -0
- esphome/components/es8311/es8311_const.h +195 -0
- esphome/components/esp32/boards.py +199 -1
- esphome/components/esp32/gpio.py +3 -1
- esphome/components/esp32_ble/const_esp32c6.h +7 -0
- esphome/components/esp32_ble_client/ble_client_base.h +1 -1
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +3 -0
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +2 -1
- esphome/components/esp32_rmt_led_strip/led_strip.cpp +2 -2
- esphome/components/esp32_rmt_led_strip/led_strip.h +2 -0
- esphome/components/esp32_rmt_led_strip/light.py +3 -1
- esphome/components/esp8266/gpio.py +7 -5
- esphome/components/ethernet/__init__.py +55 -1
- esphome/components/ethernet/ethernet_component.cpp +14 -1
- esphome/components/ethernet/ethernet_component.h +7 -1
- esphome/components/font/__init__.py +213 -108
- esphome/components/gp8403/output/__init__.py +1 -1
- esphome/components/host/gpio.py +6 -4
- esphome/components/http_request/__init__.py +12 -0
- esphome/components/http_request/http_request.h +65 -3
- esphome/components/http_request/http_request_arduino.cpp +4 -3
- esphome/components/http_request/http_request_idf.cpp +12 -14
- esphome/components/http_request/ota/ota_http_request.cpp +1 -1
- esphome/components/http_request/update/http_request_update.cpp +1 -1
- esphome/components/i2c_device/__init__.py +26 -0
- esphome/components/i2c_device/i2c_device.cpp +17 -0
- esphome/components/i2c_device/i2c_device.h +18 -0
- esphome/components/i2s_audio/__init__.py +1 -3
- esphome/components/i2s_audio/speaker/__init__.py +12 -4
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +426 -200
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +92 -33
- esphome/components/ili9xxx/display.py +5 -1
- esphome/components/image/__init__.py +5 -8
- esphome/components/image/image.cpp +14 -14
- esphome/components/image/image.h +20 -24
- esphome/components/internal_temperature/internal_temperature.cpp +51 -2
- esphome/components/internal_temperature/internal_temperature.h +1 -0
- esphome/components/ld2420/ld2420.cpp +1 -1
- esphome/components/libretiny/gpio.py +4 -2
- esphome/components/light/__init__.py +32 -1
- esphome/components/light/automation.py +39 -32
- esphome/components/light/effects.py +36 -36
- esphome/components/light/light_state.cpp +6 -16
- esphome/components/light/light_state.h +34 -0
- esphome/components/light/types.py +3 -1
- esphome/components/logger/logger_esp32.cpp +15 -0
- esphome/components/lvgl/__init__.py +202 -95
- esphome/components/lvgl/automation.py +42 -40
- esphome/components/lvgl/binary_sensor/__init__.py +8 -15
- esphome/components/lvgl/defines.py +14 -8
- esphome/components/lvgl/encoders.py +11 -8
- esphome/components/lvgl/keypads.py +77 -0
- esphome/components/lvgl/light/__init__.py +6 -8
- esphome/components/lvgl/lv_validation.py +2 -4
- esphome/components/lvgl/lvcode.py +3 -9
- esphome/components/lvgl/lvgl_esphome.cpp +210 -89
- esphome/components/lvgl/lvgl_esphome.h +113 -30
- esphome/components/lvgl/lvgl_proxy.h +17 -0
- esphome/components/lvgl/number/__init__.py +10 -15
- esphome/components/lvgl/schemas.py +4 -2
- esphome/components/lvgl/select/__init__.py +12 -37
- esphome/components/lvgl/select/lvgl_select.h +27 -33
- esphome/components/lvgl/sensor/__init__.py +8 -14
- esphome/components/lvgl/styles.py +3 -4
- esphome/components/lvgl/switch/__init__.py +8 -13
- esphome/components/lvgl/text/__init__.py +5 -6
- esphome/components/lvgl/text_sensor/__init__.py +15 -15
- esphome/components/lvgl/touchscreens.py +2 -3
- esphome/components/lvgl/trigger.py +7 -9
- esphome/components/lvgl/types.py +9 -3
- esphome/components/lvgl/widgets/__init__.py +32 -21
- esphome/components/lvgl/widgets/dropdown.py +22 -10
- esphome/components/lvgl/widgets/msgbox.py +6 -5
- esphome/components/lvgl/widgets/obj.py +4 -2
- esphome/components/lvgl/widgets/page.py +3 -2
- esphome/components/lvgl/widgets/qrcode.py +54 -0
- esphome/components/lvgl/widgets/roller.py +21 -14
- esphome/components/lvgl/widgets/tileview.py +2 -1
- esphome/components/max17043/__init__.py +1 -0
- esphome/components/max17043/automation.h +20 -0
- esphome/components/max17043/max17043.cpp +98 -0
- esphome/components/max17043/max17043.h +29 -0
- esphome/components/max17043/sensor.py +77 -0
- esphome/components/media_player/__init__.py +11 -0
- esphome/components/media_player/automation.h +10 -0
- esphome/components/media_player/media_player.cpp +4 -0
- esphome/components/midea/air_conditioner.cpp +17 -1
- esphome/components/mlx90393/sensor.py +1 -1
- esphome/components/modbus_controller/__init__.py +31 -1
- esphome/components/modbus_controller/automation.h +16 -0
- esphome/components/modbus_controller/const.py +2 -0
- esphome/components/modbus_controller/modbus_controller.cpp +14 -2
- esphome/components/modbus_controller/modbus_controller.h +9 -0
- esphome/components/mopeka_pro_check/mopeka_pro_check.cpp +40 -21
- esphome/components/mopeka_pro_check/mopeka_pro_check.h +9 -2
- esphome/components/mopeka_pro_check/sensor.py +41 -0
- esphome/components/mqtt/__init__.py +36 -0
- esphome/components/mqtt/mqtt_client.cpp +27 -3
- esphome/components/mqtt/mqtt_client.h +27 -2
- esphome/components/mqtt/mqtt_climate.cpp +4 -2
- esphome/components/mqtt/mqtt_component.cpp +6 -0
- esphome/components/mqtt/mqtt_component.h +4 -0
- esphome/components/mqtt/mqtt_const.h +6 -0
- esphome/components/online_image/online_image.cpp +2 -8
- esphome/components/online_image/online_image.h +2 -6
- esphome/components/opentherm/__init__.py +35 -9
- esphome/components/opentherm/binary_sensor/__init__.py +33 -0
- esphome/components/opentherm/const.py +11 -0
- esphome/components/opentherm/generate.py +142 -0
- esphome/components/opentherm/hub.cpp +130 -24
- esphome/components/opentherm/hub.h +62 -9
- esphome/components/opentherm/input.h +18 -0
- esphome/components/opentherm/input.py +51 -0
- esphome/components/opentherm/number/__init__.py +74 -0
- esphome/components/opentherm/number/number.cpp +40 -0
- esphome/components/opentherm/number/number.h +31 -0
- esphome/components/opentherm/opentherm.cpp +30 -0
- esphome/components/opentherm/opentherm.h +34 -2
- esphome/components/opentherm/opentherm_macros.h +151 -0
- esphome/components/opentherm/output/__init__.py +47 -0
- esphome/components/opentherm/output/output.cpp +18 -0
- esphome/components/opentherm/output/output.h +33 -0
- esphome/components/opentherm/schema.py +814 -0
- esphome/components/opentherm/sensor/__init__.py +51 -0
- esphome/components/opentherm/switch/__init__.py +43 -0
- esphome/components/opentherm/switch/switch.cpp +28 -0
- esphome/components/opentherm/switch/switch.h +20 -0
- esphome/components/opentherm/validate.py +31 -0
- esphome/components/pcd8544/display.py +8 -4
- esphome/components/prometheus/prometheus_handler.cpp +176 -14
- esphome/components/prometheus/prometheus_handler.h +25 -7
- esphome/components/qspi_amoled/display.py +1 -141
- esphome/components/qspi_dbi/display.py +185 -0
- esphome/components/qspi_dbi/models.py +64 -0
- esphome/components/{qspi_amoled/qspi_amoled.cpp → qspi_dbi/qspi_dbi.cpp} +95 -46
- esphome/components/{qspi_amoled/qspi_amoled.h → qspi_dbi/qspi_dbi.h} +26 -15
- esphome/components/rp2040/__init__.py +6 -3
- esphome/components/rp2040/gpio.py +5 -3
- esphome/components/rtttl/rtttl.cpp +4 -1
- esphome/components/rtttl/rtttl.h +1 -0
- esphome/components/sdl/sdl_esphome.cpp +22 -5
- esphome/components/sdl/sdl_esphome.h +1 -0
- esphome/components/sdm_meter/sdm_meter.cpp +1 -1
- esphome/components/sensor/__init__.py +18 -8
- esphome/components/sensor/filter.cpp +19 -18
- esphome/components/sensor/filter.h +9 -10
- esphome/components/sgp4x/sgp4x.cpp +40 -74
- esphome/components/sgp4x/sgp4x.h +5 -3
- esphome/components/speaker/__init__.py +51 -5
- esphome/components/speaker/automation.h +25 -0
- esphome/components/speaker/speaker.h +72 -1
- esphome/components/spi/__init__.py +15 -14
- esphome/components/spi_device/__init__.py +4 -15
- esphome/components/ssd1306_spi/display.py +6 -2
- esphome/components/ssd1322_spi/display.py +6 -2
- esphome/components/ssd1325_spi/display.py +6 -2
- esphome/components/ssd1327_spi/display.py +6 -2
- esphome/components/ssd1331_spi/display.py +6 -2
- esphome/components/ssd1351_spi/display.py +6 -2
- esphome/components/st7567_spi/display.py +6 -2
- esphome/components/st7701s/display.py +5 -1
- esphome/components/st7735/display.py +10 -5
- esphome/components/st7789v/display.py +12 -7
- esphome/components/statsd/statsd.cpp +2 -0
- esphome/components/statsd/statsd.h +2 -0
- esphome/components/sun/sun.h +3 -0
- esphome/components/tc74/__init__.py +1 -0
- esphome/components/tc74/sensor.py +32 -0
- esphome/components/tc74/tc74.cpp +68 -0
- esphome/components/tc74/tc74.h +28 -0
- esphome/components/touchscreen/__init__.py +41 -50
- esphome/components/touchscreen/touchscreen.h +4 -8
- esphome/components/tuya/fan/tuya_fan.cpp +1 -1
- esphome/components/udp/udp_component.cpp +6 -3
- esphome/components/udp/udp_component.h +4 -2
- esphome/components/waveshare_epaper/display.py +6 -2
- esphome/components/web_server/web_server.cpp +22 -0
- esphome/components/web_server/web_server.h +3 -0
- esphome/components/weikai/weikai.h +2 -2
- esphome/components/wifi/wifi_component.cpp +2 -2
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +4 -4
- esphome/components/wifi/wifi_component_esp8266.cpp +4 -4
- esphome/components/wifi/wifi_component_esp_idf.cpp +2 -2
- esphome/components/xpt2046/touchscreen/__init__.py +7 -32
- esphome/config_validation.py +3 -1
- esphome/const.py +9 -2
- esphome/core/defines.h +8 -2
- esphome/core/helpers.cpp +32 -17
- esphome/core/helpers.h +32 -16
- esphome/core/ring_buffer.cpp +2 -2
- esphome/core/ring_buffer.h +2 -2
- esphome/dashboard/core.py +25 -0
- esphome/dashboard/status/mdns.py +3 -4
- esphome/dashboard/web_server.py +54 -19
- esphome/espota2.py +36 -35
- esphome/helpers.py +68 -16
- esphome/mqtt.py +9 -2
- esphome/storage_json.py +4 -0
- esphome/writer.py +7 -18
- esphome/zeroconf.py +8 -6
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/METADATA +7 -5
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/RECORD +232 -186
- esphome/core/bytebuffer.cpp +0 -167
- esphome/core/bytebuffer.h +0 -144
- /esphome/components/{qspi_amoled → qspi_dbi}/__init__.py +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/LICENSE +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/WHEEL +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.10.3.dist-info → esphome-2024.11.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
import esphome.config_validation as cv
|
4
|
+
from esphome.components import sensor
|
5
|
+
from .. import const, schema, validate, generate
|
6
|
+
|
7
|
+
DEPENDENCIES = [const.OPENTHERM]
|
8
|
+
COMPONENT_TYPE = const.SENSOR
|
9
|
+
|
10
|
+
MSG_DATA_TYPES = {
|
11
|
+
"u8_lb",
|
12
|
+
"u8_hb",
|
13
|
+
"s8_lb",
|
14
|
+
"s8_hb",
|
15
|
+
"u8_lb_60",
|
16
|
+
"u8_hb_60",
|
17
|
+
"u16",
|
18
|
+
"s16",
|
19
|
+
"f88",
|
20
|
+
}
|
21
|
+
|
22
|
+
|
23
|
+
def get_entity_validation_schema(entity: schema.SensorSchema) -> cv.Schema:
|
24
|
+
return sensor.sensor_schema(
|
25
|
+
unit_of_measurement=entity.unit_of_measurement
|
26
|
+
or sensor._UNDEF, # pylint: disable=protected-access
|
27
|
+
accuracy_decimals=entity.accuracy_decimals,
|
28
|
+
device_class=entity.device_class
|
29
|
+
or sensor._UNDEF, # pylint: disable=protected-access
|
30
|
+
icon=entity.icon or sensor._UNDEF, # pylint: disable=protected-access
|
31
|
+
state_class=entity.state_class,
|
32
|
+
).extend(
|
33
|
+
{
|
34
|
+
cv.Optional(const.CONF_DATA_TYPE): cv.one_of(*MSG_DATA_TYPES),
|
35
|
+
}
|
36
|
+
)
|
37
|
+
|
38
|
+
|
39
|
+
CONFIG_SCHEMA = validate.create_component_schema(
|
40
|
+
schema.SENSORS, get_entity_validation_schema
|
41
|
+
)
|
42
|
+
|
43
|
+
|
44
|
+
async def to_code(config: dict[str, Any]) -> None:
|
45
|
+
await generate.component_to_code(
|
46
|
+
COMPONENT_TYPE,
|
47
|
+
schema.SENSORS,
|
48
|
+
sensor.Sensor,
|
49
|
+
generate.create_only_conf(sensor.new_sensor),
|
50
|
+
config,
|
51
|
+
)
|
@@ -0,0 +1,43 @@
|
|
1
|
+
from typing import Any
|
2
|
+
|
3
|
+
import esphome.codegen as cg
|
4
|
+
import esphome.config_validation as cv
|
5
|
+
from esphome.components import switch
|
6
|
+
from esphome.const import CONF_ID
|
7
|
+
from .. import const, schema, validate, generate
|
8
|
+
|
9
|
+
DEPENDENCIES = [const.OPENTHERM]
|
10
|
+
COMPONENT_TYPE = const.SWITCH
|
11
|
+
|
12
|
+
OpenthermSwitch = generate.opentherm_ns.class_(
|
13
|
+
"OpenthermSwitch", switch.Switch, cg.Component
|
14
|
+
)
|
15
|
+
|
16
|
+
|
17
|
+
async def new_openthermswitch(config: dict[str, Any]) -> cg.Pvariable:
|
18
|
+
var = cg.new_Pvariable(config[CONF_ID])
|
19
|
+
await cg.register_component(var, config)
|
20
|
+
await switch.register_switch(var, config)
|
21
|
+
return var
|
22
|
+
|
23
|
+
|
24
|
+
def get_entity_validation_schema(entity: schema.SwitchSchema) -> cv.Schema:
|
25
|
+
return switch.SWITCH_SCHEMA.extend(
|
26
|
+
{cv.GenerateID(): cv.declare_id(OpenthermSwitch)}
|
27
|
+
).extend(cv.COMPONENT_SCHEMA)
|
28
|
+
|
29
|
+
|
30
|
+
CONFIG_SCHEMA = validate.create_component_schema(
|
31
|
+
schema.SWITCHES, get_entity_validation_schema
|
32
|
+
)
|
33
|
+
|
34
|
+
|
35
|
+
async def to_code(config: dict[str, Any]) -> None:
|
36
|
+
keys = await generate.component_to_code(
|
37
|
+
COMPONENT_TYPE,
|
38
|
+
schema.SWITCHES,
|
39
|
+
OpenthermSwitch,
|
40
|
+
generate.create_only_conf(new_openthermswitch),
|
41
|
+
config,
|
42
|
+
)
|
43
|
+
generate.define_readers(COMPONENT_TYPE, keys)
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#include "switch.h"
|
2
|
+
|
3
|
+
namespace esphome {
|
4
|
+
namespace opentherm {
|
5
|
+
|
6
|
+
static const char *const TAG = "opentherm.switch";
|
7
|
+
|
8
|
+
void OpenthermSwitch::write_state(bool state) { this->publish_state(state); }
|
9
|
+
|
10
|
+
void OpenthermSwitch::setup() {
|
11
|
+
auto restored = this->get_initial_state_with_restore_mode();
|
12
|
+
bool state = false;
|
13
|
+
if (!restored.has_value()) {
|
14
|
+
ESP_LOGD(TAG, "Couldn't restore state for OpenTherm switch '%s'", this->get_name().c_str());
|
15
|
+
} else {
|
16
|
+
ESP_LOGD(TAG, "Restored state for OpenTherm switch '%s': %d", this->get_name().c_str(), restored.value());
|
17
|
+
state = restored.value();
|
18
|
+
}
|
19
|
+
this->write_state(state);
|
20
|
+
}
|
21
|
+
|
22
|
+
void OpenthermSwitch::dump_config() {
|
23
|
+
LOG_SWITCH("", "OpenTherm Switch", this);
|
24
|
+
ESP_LOGCONFIG(TAG, " Current state: %d", this->state);
|
25
|
+
}
|
26
|
+
|
27
|
+
} // namespace opentherm
|
28
|
+
} // namespace esphome
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "esphome/core/component.h"
|
4
|
+
#include "esphome/components/switch/switch.h"
|
5
|
+
#include "esphome/core/log.h"
|
6
|
+
|
7
|
+
namespace esphome {
|
8
|
+
namespace opentherm {
|
9
|
+
|
10
|
+
class OpenthermSwitch : public switch_::Switch, public Component {
|
11
|
+
protected:
|
12
|
+
void write_state(bool state) override;
|
13
|
+
|
14
|
+
public:
|
15
|
+
void setup() override;
|
16
|
+
void dump_config() override;
|
17
|
+
};
|
18
|
+
|
19
|
+
} // namespace opentherm
|
20
|
+
} // namespace esphome
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from typing import Callable
|
2
|
+
|
3
|
+
from voluptuous import Schema
|
4
|
+
|
5
|
+
import esphome.config_validation as cv
|
6
|
+
|
7
|
+
from . import const, schema, generate
|
8
|
+
from .schema import TSchema
|
9
|
+
|
10
|
+
|
11
|
+
def create_entities_schema(
|
12
|
+
entities: dict[str, schema.EntitySchema],
|
13
|
+
get_entity_validation_schema: Callable[[TSchema], cv.Schema],
|
14
|
+
) -> Schema:
|
15
|
+
entity_schema = {}
|
16
|
+
for key, entity in entities.items():
|
17
|
+
entity_schema[cv.Optional(key)] = get_entity_validation_schema(entity)
|
18
|
+
return cv.Schema(entity_schema)
|
19
|
+
|
20
|
+
|
21
|
+
def create_component_schema(
|
22
|
+
entities: dict[str, schema.EntitySchema],
|
23
|
+
get_entity_validation_schema: Callable[[TSchema], cv.Schema],
|
24
|
+
) -> Schema:
|
25
|
+
return (
|
26
|
+
cv.Schema(
|
27
|
+
{cv.GenerateID(const.CONF_OPENTHERM_ID): cv.use_id(generate.OpenthermHub)}
|
28
|
+
)
|
29
|
+
.extend(create_entities_schema(entities, get_entity_validation_schema))
|
30
|
+
.extend(cv.COMPONENT_SCHEMA)
|
31
|
+
)
|
@@ -1,15 +1,15 @@
|
|
1
|
-
import esphome.codegen as cg
|
2
|
-
import esphome.config_validation as cv
|
3
1
|
from esphome import pins
|
2
|
+
import esphome.codegen as cg
|
4
3
|
from esphome.components import display, spi
|
4
|
+
import esphome.config_validation as cv
|
5
5
|
from esphome.const import (
|
6
|
+
CONF_CONTRAST,
|
7
|
+
CONF_CS_PIN,
|
6
8
|
CONF_DC_PIN,
|
7
9
|
CONF_ID,
|
8
10
|
CONF_LAMBDA,
|
9
11
|
CONF_PAGES,
|
10
12
|
CONF_RESET_PIN,
|
11
|
-
CONF_CS_PIN,
|
12
|
-
CONF_CONTRAST,
|
13
13
|
)
|
14
14
|
|
15
15
|
DEPENDENCIES = ["spi"]
|
@@ -35,6 +35,10 @@ CONFIG_SCHEMA = cv.All(
|
|
35
35
|
cv.has_at_most_one_key(CONF_PAGES, CONF_LAMBDA),
|
36
36
|
)
|
37
37
|
|
38
|
+
FINAL_VALIDATE_SCHEMA = spi.final_validate_device_schema(
|
39
|
+
"pcd8544", require_miso=False, require_mosi=True
|
40
|
+
)
|
41
|
+
|
38
42
|
|
39
43
|
async def to_code(config):
|
40
44
|
var = cg.new_Pvariable(config[CONF_ID])
|
@@ -7,47 +7,56 @@ namespace prometheus {
|
|
7
7
|
|
8
8
|
void PrometheusHandler::handleRequest(AsyncWebServerRequest *req) {
|
9
9
|
AsyncResponseStream *stream = req->beginResponseStream("text/plain; version=0.0.4; charset=utf-8");
|
10
|
+
std::string area = App.get_area();
|
11
|
+
std::string node = App.get_name();
|
12
|
+
std::string friendly_name = App.get_friendly_name();
|
10
13
|
|
11
14
|
#ifdef USE_SENSOR
|
12
15
|
this->sensor_type_(stream);
|
13
16
|
for (auto *obj : App.get_sensors())
|
14
|
-
this->sensor_row_(stream, obj);
|
17
|
+
this->sensor_row_(stream, obj, area, node, friendly_name);
|
15
18
|
#endif
|
16
19
|
|
17
20
|
#ifdef USE_BINARY_SENSOR
|
18
21
|
this->binary_sensor_type_(stream);
|
19
22
|
for (auto *obj : App.get_binary_sensors())
|
20
|
-
this->binary_sensor_row_(stream, obj);
|
23
|
+
this->binary_sensor_row_(stream, obj, area, node, friendly_name);
|
21
24
|
#endif
|
22
25
|
|
23
26
|
#ifdef USE_FAN
|
24
27
|
this->fan_type_(stream);
|
25
28
|
for (auto *obj : App.get_fans())
|
26
|
-
this->fan_row_(stream, obj);
|
29
|
+
this->fan_row_(stream, obj, area, node, friendly_name);
|
27
30
|
#endif
|
28
31
|
|
29
32
|
#ifdef USE_LIGHT
|
30
33
|
this->light_type_(stream);
|
31
34
|
for (auto *obj : App.get_lights())
|
32
|
-
this->light_row_(stream, obj);
|
35
|
+
this->light_row_(stream, obj, area, node, friendly_name);
|
33
36
|
#endif
|
34
37
|
|
35
38
|
#ifdef USE_COVER
|
36
39
|
this->cover_type_(stream);
|
37
40
|
for (auto *obj : App.get_covers())
|
38
|
-
this->cover_row_(stream, obj);
|
41
|
+
this->cover_row_(stream, obj, area, node, friendly_name);
|
39
42
|
#endif
|
40
43
|
|
41
44
|
#ifdef USE_SWITCH
|
42
45
|
this->switch_type_(stream);
|
43
46
|
for (auto *obj : App.get_switches())
|
44
|
-
this->switch_row_(stream, obj);
|
47
|
+
this->switch_row_(stream, obj, area, node, friendly_name);
|
45
48
|
#endif
|
46
49
|
|
47
50
|
#ifdef USE_LOCK
|
48
51
|
this->lock_type_(stream);
|
49
52
|
for (auto *obj : App.get_locks())
|
50
|
-
this->lock_row_(stream, obj);
|
53
|
+
this->lock_row_(stream, obj, area, node, friendly_name);
|
54
|
+
#endif
|
55
|
+
|
56
|
+
#ifdef USE_TEXT_SENSOR
|
57
|
+
this->text_sensor_type_(stream);
|
58
|
+
for (auto *obj : App.get_text_sensors())
|
59
|
+
this->text_sensor_row_(stream, obj, area, node, friendly_name);
|
51
60
|
#endif
|
52
61
|
|
53
62
|
req->send(stream);
|
@@ -63,25 +72,53 @@ std::string PrometheusHandler::relabel_name_(EntityBase *obj) {
|
|
63
72
|
return item == relabel_map_name_.end() ? obj->get_name() : item->second;
|
64
73
|
}
|
65
74
|
|
75
|
+
void PrometheusHandler::add_area_label_(AsyncResponseStream *stream, std::string &area) {
|
76
|
+
if (!area.empty()) {
|
77
|
+
stream->print(F("\",area=\""));
|
78
|
+
stream->print(area.c_str());
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
void PrometheusHandler::add_node_label_(AsyncResponseStream *stream, std::string &node) {
|
83
|
+
if (!node.empty()) {
|
84
|
+
stream->print(F("\",node=\""));
|
85
|
+
stream->print(node.c_str());
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
void PrometheusHandler::add_friendly_name_label_(AsyncResponseStream *stream, std::string &friendly_name) {
|
90
|
+
if (!friendly_name.empty()) {
|
91
|
+
stream->print(F("\",friendly_name=\""));
|
92
|
+
stream->print(friendly_name.c_str());
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
66
96
|
// Type-specific implementation
|
67
97
|
#ifdef USE_SENSOR
|
68
98
|
void PrometheusHandler::sensor_type_(AsyncResponseStream *stream) {
|
69
99
|
stream->print(F("#TYPE esphome_sensor_value gauge\n"));
|
70
100
|
stream->print(F("#TYPE esphome_sensor_failed gauge\n"));
|
71
101
|
}
|
72
|
-
void PrometheusHandler::sensor_row_(AsyncResponseStream *stream, sensor::Sensor *obj
|
102
|
+
void PrometheusHandler::sensor_row_(AsyncResponseStream *stream, sensor::Sensor *obj, std::string &area,
|
103
|
+
std::string &node, std::string &friendly_name) {
|
73
104
|
if (obj->is_internal() && !this->include_internal_)
|
74
105
|
return;
|
75
106
|
if (!std::isnan(obj->state)) {
|
76
107
|
// We have a valid value, output this value
|
77
108
|
stream->print(F("esphome_sensor_failed{id=\""));
|
78
109
|
stream->print(relabel_id_(obj).c_str());
|
110
|
+
add_area_label_(stream, area);
|
111
|
+
add_node_label_(stream, node);
|
112
|
+
add_friendly_name_label_(stream, friendly_name);
|
79
113
|
stream->print(F("\",name=\""));
|
80
114
|
stream->print(relabel_name_(obj).c_str());
|
81
115
|
stream->print(F("\"} 0\n"));
|
82
116
|
// Data itself
|
83
117
|
stream->print(F("esphome_sensor_value{id=\""));
|
84
118
|
stream->print(relabel_id_(obj).c_str());
|
119
|
+
add_area_label_(stream, area);
|
120
|
+
add_node_label_(stream, node);
|
121
|
+
add_friendly_name_label_(stream, friendly_name);
|
85
122
|
stream->print(F("\",name=\""));
|
86
123
|
stream->print(relabel_name_(obj).c_str());
|
87
124
|
stream->print(F("\",unit=\""));
|
@@ -93,6 +130,9 @@ void PrometheusHandler::sensor_row_(AsyncResponseStream *stream, sensor::Sensor
|
|
93
130
|
// Invalid state
|
94
131
|
stream->print(F("esphome_sensor_failed{id=\""));
|
95
132
|
stream->print(relabel_id_(obj).c_str());
|
133
|
+
add_area_label_(stream, area);
|
134
|
+
add_node_label_(stream, node);
|
135
|
+
add_friendly_name_label_(stream, friendly_name);
|
96
136
|
stream->print(F("\",name=\""));
|
97
137
|
stream->print(relabel_name_(obj).c_str());
|
98
138
|
stream->print(F("\"} 1\n"));
|
@@ -106,19 +146,26 @@ void PrometheusHandler::binary_sensor_type_(AsyncResponseStream *stream) {
|
|
106
146
|
stream->print(F("#TYPE esphome_binary_sensor_value gauge\n"));
|
107
147
|
stream->print(F("#TYPE esphome_binary_sensor_failed gauge\n"));
|
108
148
|
}
|
109
|
-
void PrometheusHandler::binary_sensor_row_(AsyncResponseStream *stream, binary_sensor::BinarySensor *obj
|
149
|
+
void PrometheusHandler::binary_sensor_row_(AsyncResponseStream *stream, binary_sensor::BinarySensor *obj,
|
150
|
+
std::string &area, std::string &node, std::string &friendly_name) {
|
110
151
|
if (obj->is_internal() && !this->include_internal_)
|
111
152
|
return;
|
112
153
|
if (obj->has_state()) {
|
113
154
|
// We have a valid value, output this value
|
114
155
|
stream->print(F("esphome_binary_sensor_failed{id=\""));
|
115
156
|
stream->print(relabel_id_(obj).c_str());
|
157
|
+
add_area_label_(stream, area);
|
158
|
+
add_node_label_(stream, node);
|
159
|
+
add_friendly_name_label_(stream, friendly_name);
|
116
160
|
stream->print(F("\",name=\""));
|
117
161
|
stream->print(relabel_name_(obj).c_str());
|
118
162
|
stream->print(F("\"} 0\n"));
|
119
163
|
// Data itself
|
120
164
|
stream->print(F("esphome_binary_sensor_value{id=\""));
|
121
165
|
stream->print(relabel_id_(obj).c_str());
|
166
|
+
add_area_label_(stream, area);
|
167
|
+
add_node_label_(stream, node);
|
168
|
+
add_friendly_name_label_(stream, friendly_name);
|
122
169
|
stream->print(F("\",name=\""));
|
123
170
|
stream->print(relabel_name_(obj).c_str());
|
124
171
|
stream->print(F("\"} "));
|
@@ -128,6 +175,9 @@ void PrometheusHandler::binary_sensor_row_(AsyncResponseStream *stream, binary_s
|
|
128
175
|
// Invalid state
|
129
176
|
stream->print(F("esphome_binary_sensor_failed{id=\""));
|
130
177
|
stream->print(relabel_id_(obj).c_str());
|
178
|
+
add_area_label_(stream, area);
|
179
|
+
add_node_label_(stream, node);
|
180
|
+
add_friendly_name_label_(stream, friendly_name);
|
131
181
|
stream->print(F("\",name=\""));
|
132
182
|
stream->print(relabel_name_(obj).c_str());
|
133
183
|
stream->print(F("\"} 1\n"));
|
@@ -142,17 +192,24 @@ void PrometheusHandler::fan_type_(AsyncResponseStream *stream) {
|
|
142
192
|
stream->print(F("#TYPE esphome_fan_speed gauge\n"));
|
143
193
|
stream->print(F("#TYPE esphome_fan_oscillation gauge\n"));
|
144
194
|
}
|
145
|
-
void PrometheusHandler::fan_row_(AsyncResponseStream *stream, fan::Fan *obj
|
195
|
+
void PrometheusHandler::fan_row_(AsyncResponseStream *stream, fan::Fan *obj, std::string &area, std::string &node,
|
196
|
+
std::string &friendly_name) {
|
146
197
|
if (obj->is_internal() && !this->include_internal_)
|
147
198
|
return;
|
148
199
|
stream->print(F("esphome_fan_failed{id=\""));
|
149
200
|
stream->print(relabel_id_(obj).c_str());
|
201
|
+
add_area_label_(stream, area);
|
202
|
+
add_node_label_(stream, node);
|
203
|
+
add_friendly_name_label_(stream, friendly_name);
|
150
204
|
stream->print(F("\",name=\""));
|
151
205
|
stream->print(relabel_name_(obj).c_str());
|
152
206
|
stream->print(F("\"} 0\n"));
|
153
207
|
// Data itself
|
154
208
|
stream->print(F("esphome_fan_value{id=\""));
|
155
209
|
stream->print(relabel_id_(obj).c_str());
|
210
|
+
add_area_label_(stream, area);
|
211
|
+
add_node_label_(stream, node);
|
212
|
+
add_friendly_name_label_(stream, friendly_name);
|
156
213
|
stream->print(F("\",name=\""));
|
157
214
|
stream->print(relabel_name_(obj).c_str());
|
158
215
|
stream->print(F("\"} "));
|
@@ -162,6 +219,9 @@ void PrometheusHandler::fan_row_(AsyncResponseStream *stream, fan::Fan *obj) {
|
|
162
219
|
if (obj->get_traits().supports_speed()) {
|
163
220
|
stream->print(F("esphome_fan_speed{id=\""));
|
164
221
|
stream->print(relabel_id_(obj).c_str());
|
222
|
+
add_area_label_(stream, area);
|
223
|
+
add_node_label_(stream, node);
|
224
|
+
add_friendly_name_label_(stream, friendly_name);
|
165
225
|
stream->print(F("\",name=\""));
|
166
226
|
stream->print(relabel_name_(obj).c_str());
|
167
227
|
stream->print(F("\"} "));
|
@@ -172,6 +232,9 @@ void PrometheusHandler::fan_row_(AsyncResponseStream *stream, fan::Fan *obj) {
|
|
172
232
|
if (obj->get_traits().supports_oscillation()) {
|
173
233
|
stream->print(F("esphome_fan_oscillation{id=\""));
|
174
234
|
stream->print(relabel_id_(obj).c_str());
|
235
|
+
add_area_label_(stream, area);
|
236
|
+
add_node_label_(stream, node);
|
237
|
+
add_friendly_name_label_(stream, friendly_name);
|
175
238
|
stream->print(F("\",name=\""));
|
176
239
|
stream->print(relabel_name_(obj).c_str());
|
177
240
|
stream->print(F("\"} "));
|
@@ -187,12 +250,16 @@ void PrometheusHandler::light_type_(AsyncResponseStream *stream) {
|
|
187
250
|
stream->print(F("#TYPE esphome_light_color gauge\n"));
|
188
251
|
stream->print(F("#TYPE esphome_light_effect_active gauge\n"));
|
189
252
|
}
|
190
|
-
void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightState *obj
|
253
|
+
void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightState *obj, std::string &area,
|
254
|
+
std::string &node, std::string &friendly_name) {
|
191
255
|
if (obj->is_internal() && !this->include_internal_)
|
192
256
|
return;
|
193
257
|
// State
|
194
258
|
stream->print(F("esphome_light_state{id=\""));
|
195
259
|
stream->print(relabel_id_(obj).c_str());
|
260
|
+
add_area_label_(stream, area);
|
261
|
+
add_node_label_(stream, node);
|
262
|
+
add_friendly_name_label_(stream, friendly_name);
|
196
263
|
stream->print(F("\",name=\""));
|
197
264
|
stream->print(relabel_name_(obj).c_str());
|
198
265
|
stream->print(F("\"} "));
|
@@ -205,6 +272,9 @@ void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightStat
|
|
205
272
|
color.as_rgbw(&r, &g, &b, &w);
|
206
273
|
stream->print(F("esphome_light_color{id=\""));
|
207
274
|
stream->print(relabel_id_(obj).c_str());
|
275
|
+
add_area_label_(stream, area);
|
276
|
+
add_node_label_(stream, node);
|
277
|
+
add_friendly_name_label_(stream, friendly_name);
|
208
278
|
stream->print(F("\",name=\""));
|
209
279
|
stream->print(relabel_name_(obj).c_str());
|
210
280
|
stream->print(F("\",channel=\"brightness\"} "));
|
@@ -212,6 +282,9 @@ void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightStat
|
|
212
282
|
stream->print(F("\n"));
|
213
283
|
stream->print(F("esphome_light_color{id=\""));
|
214
284
|
stream->print(relabel_id_(obj).c_str());
|
285
|
+
add_area_label_(stream, area);
|
286
|
+
add_node_label_(stream, node);
|
287
|
+
add_friendly_name_label_(stream, friendly_name);
|
215
288
|
stream->print(F("\",name=\""));
|
216
289
|
stream->print(relabel_name_(obj).c_str());
|
217
290
|
stream->print(F("\",channel=\"r\"} "));
|
@@ -219,6 +292,9 @@ void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightStat
|
|
219
292
|
stream->print(F("\n"));
|
220
293
|
stream->print(F("esphome_light_color{id=\""));
|
221
294
|
stream->print(relabel_id_(obj).c_str());
|
295
|
+
add_area_label_(stream, area);
|
296
|
+
add_node_label_(stream, node);
|
297
|
+
add_friendly_name_label_(stream, friendly_name);
|
222
298
|
stream->print(F("\",name=\""));
|
223
299
|
stream->print(relabel_name_(obj).c_str());
|
224
300
|
stream->print(F("\",channel=\"g\"} "));
|
@@ -226,6 +302,9 @@ void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightStat
|
|
226
302
|
stream->print(F("\n"));
|
227
303
|
stream->print(F("esphome_light_color{id=\""));
|
228
304
|
stream->print(relabel_id_(obj).c_str());
|
305
|
+
add_area_label_(stream, area);
|
306
|
+
add_node_label_(stream, node);
|
307
|
+
add_friendly_name_label_(stream, friendly_name);
|
229
308
|
stream->print(F("\",name=\""));
|
230
309
|
stream->print(relabel_name_(obj).c_str());
|
231
310
|
stream->print(F("\",channel=\"b\"} "));
|
@@ -233,6 +312,9 @@ void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightStat
|
|
233
312
|
stream->print(F("\n"));
|
234
313
|
stream->print(F("esphome_light_color{id=\""));
|
235
314
|
stream->print(relabel_id_(obj).c_str());
|
315
|
+
add_area_label_(stream, area);
|
316
|
+
add_node_label_(stream, node);
|
317
|
+
add_friendly_name_label_(stream, friendly_name);
|
236
318
|
stream->print(F("\",name=\""));
|
237
319
|
stream->print(relabel_name_(obj).c_str());
|
238
320
|
stream->print(F("\",channel=\"w\"} "));
|
@@ -243,12 +325,18 @@ void PrometheusHandler::light_row_(AsyncResponseStream *stream, light::LightStat
|
|
243
325
|
if (effect == "None") {
|
244
326
|
stream->print(F("esphome_light_effect_active{id=\""));
|
245
327
|
stream->print(relabel_id_(obj).c_str());
|
328
|
+
add_area_label_(stream, area);
|
329
|
+
add_node_label_(stream, node);
|
330
|
+
add_friendly_name_label_(stream, friendly_name);
|
246
331
|
stream->print(F("\",name=\""));
|
247
332
|
stream->print(relabel_name_(obj).c_str());
|
248
333
|
stream->print(F("\",effect=\"None\"} 0\n"));
|
249
334
|
} else {
|
250
335
|
stream->print(F("esphome_light_effect_active{id=\""));
|
251
336
|
stream->print(relabel_id_(obj).c_str());
|
337
|
+
add_area_label_(stream, area);
|
338
|
+
add_node_label_(stream, node);
|
339
|
+
add_friendly_name_label_(stream, friendly_name);
|
252
340
|
stream->print(F("\",name=\""));
|
253
341
|
stream->print(relabel_name_(obj).c_str());
|
254
342
|
stream->print(F("\",effect=\""));
|
@@ -263,19 +351,26 @@ void PrometheusHandler::cover_type_(AsyncResponseStream *stream) {
|
|
263
351
|
stream->print(F("#TYPE esphome_cover_value gauge\n"));
|
264
352
|
stream->print(F("#TYPE esphome_cover_failed gauge\n"));
|
265
353
|
}
|
266
|
-
void PrometheusHandler::cover_row_(AsyncResponseStream *stream, cover::Cover *obj
|
354
|
+
void PrometheusHandler::cover_row_(AsyncResponseStream *stream, cover::Cover *obj, std::string &area, std::string &node,
|
355
|
+
std::string &friendly_name) {
|
267
356
|
if (obj->is_internal() && !this->include_internal_)
|
268
357
|
return;
|
269
358
|
if (!std::isnan(obj->position)) {
|
270
359
|
// We have a valid value, output this value
|
271
360
|
stream->print(F("esphome_cover_failed{id=\""));
|
272
361
|
stream->print(relabel_id_(obj).c_str());
|
362
|
+
add_area_label_(stream, area);
|
363
|
+
add_node_label_(stream, node);
|
364
|
+
add_friendly_name_label_(stream, friendly_name);
|
273
365
|
stream->print(F("\",name=\""));
|
274
366
|
stream->print(relabel_name_(obj).c_str());
|
275
367
|
stream->print(F("\"} 0\n"));
|
276
368
|
// Data itself
|
277
369
|
stream->print(F("esphome_cover_value{id=\""));
|
278
370
|
stream->print(relabel_id_(obj).c_str());
|
371
|
+
add_area_label_(stream, area);
|
372
|
+
add_node_label_(stream, node);
|
373
|
+
add_friendly_name_label_(stream, friendly_name);
|
279
374
|
stream->print(F("\",name=\""));
|
280
375
|
stream->print(relabel_name_(obj).c_str());
|
281
376
|
stream->print(F("\"} "));
|
@@ -284,6 +379,9 @@ void PrometheusHandler::cover_row_(AsyncResponseStream *stream, cover::Cover *ob
|
|
284
379
|
if (obj->get_traits().get_supports_tilt()) {
|
285
380
|
stream->print(F("esphome_cover_tilt{id=\""));
|
286
381
|
stream->print(relabel_id_(obj).c_str());
|
382
|
+
add_area_label_(stream, area);
|
383
|
+
add_node_label_(stream, node);
|
384
|
+
add_friendly_name_label_(stream, friendly_name);
|
287
385
|
stream->print(F("\",name=\""));
|
288
386
|
stream->print(relabel_name_(obj).c_str());
|
289
387
|
stream->print(F("\"} "));
|
@@ -294,6 +392,9 @@ void PrometheusHandler::cover_row_(AsyncResponseStream *stream, cover::Cover *ob
|
|
294
392
|
// Invalid state
|
295
393
|
stream->print(F("esphome_cover_failed{id=\""));
|
296
394
|
stream->print(relabel_id_(obj).c_str());
|
395
|
+
add_area_label_(stream, area);
|
396
|
+
add_node_label_(stream, node);
|
397
|
+
add_friendly_name_label_(stream, friendly_name);
|
297
398
|
stream->print(F("\",name=\""));
|
298
399
|
stream->print(relabel_name_(obj).c_str());
|
299
400
|
stream->print(F("\"} 1\n"));
|
@@ -306,17 +407,24 @@ void PrometheusHandler::switch_type_(AsyncResponseStream *stream) {
|
|
306
407
|
stream->print(F("#TYPE esphome_switch_value gauge\n"));
|
307
408
|
stream->print(F("#TYPE esphome_switch_failed gauge\n"));
|
308
409
|
}
|
309
|
-
void PrometheusHandler::switch_row_(AsyncResponseStream *stream, switch_::Switch *obj
|
410
|
+
void PrometheusHandler::switch_row_(AsyncResponseStream *stream, switch_::Switch *obj, std::string &area,
|
411
|
+
std::string &node, std::string &friendly_name) {
|
310
412
|
if (obj->is_internal() && !this->include_internal_)
|
311
413
|
return;
|
312
414
|
stream->print(F("esphome_switch_failed{id=\""));
|
313
415
|
stream->print(relabel_id_(obj).c_str());
|
416
|
+
add_area_label_(stream, area);
|
417
|
+
add_node_label_(stream, node);
|
418
|
+
add_friendly_name_label_(stream, friendly_name);
|
314
419
|
stream->print(F("\",name=\""));
|
315
420
|
stream->print(relabel_name_(obj).c_str());
|
316
421
|
stream->print(F("\"} 0\n"));
|
317
422
|
// Data itself
|
318
423
|
stream->print(F("esphome_switch_value{id=\""));
|
319
424
|
stream->print(relabel_id_(obj).c_str());
|
425
|
+
add_area_label_(stream, area);
|
426
|
+
add_node_label_(stream, node);
|
427
|
+
add_friendly_name_label_(stream, friendly_name);
|
320
428
|
stream->print(F("\",name=\""));
|
321
429
|
stream->print(relabel_name_(obj).c_str());
|
322
430
|
stream->print(F("\"} "));
|
@@ -330,17 +438,24 @@ void PrometheusHandler::lock_type_(AsyncResponseStream *stream) {
|
|
330
438
|
stream->print(F("#TYPE esphome_lock_value gauge\n"));
|
331
439
|
stream->print(F("#TYPE esphome_lock_failed gauge\n"));
|
332
440
|
}
|
333
|
-
void PrometheusHandler::lock_row_(AsyncResponseStream *stream, lock::Lock *obj
|
441
|
+
void PrometheusHandler::lock_row_(AsyncResponseStream *stream, lock::Lock *obj, std::string &area, std::string &node,
|
442
|
+
std::string &friendly_name) {
|
334
443
|
if (obj->is_internal() && !this->include_internal_)
|
335
444
|
return;
|
336
445
|
stream->print(F("esphome_lock_failed{id=\""));
|
337
446
|
stream->print(relabel_id_(obj).c_str());
|
447
|
+
add_area_label_(stream, area);
|
448
|
+
add_node_label_(stream, node);
|
449
|
+
add_friendly_name_label_(stream, friendly_name);
|
338
450
|
stream->print(F("\",name=\""));
|
339
451
|
stream->print(relabel_name_(obj).c_str());
|
340
452
|
stream->print(F("\"} 0\n"));
|
341
453
|
// Data itself
|
342
454
|
stream->print(F("esphome_lock_value{id=\""));
|
343
455
|
stream->print(relabel_id_(obj).c_str());
|
456
|
+
add_area_label_(stream, area);
|
457
|
+
add_node_label_(stream, node);
|
458
|
+
add_friendly_name_label_(stream, friendly_name);
|
344
459
|
stream->print(F("\",name=\""));
|
345
460
|
stream->print(relabel_name_(obj).c_str());
|
346
461
|
stream->print(F("\"} "));
|
@@ -349,6 +464,53 @@ void PrometheusHandler::lock_row_(AsyncResponseStream *stream, lock::Lock *obj)
|
|
349
464
|
}
|
350
465
|
#endif
|
351
466
|
|
467
|
+
// Type-specific implementation
|
468
|
+
#ifdef USE_TEXT_SENSOR
|
469
|
+
void PrometheusHandler::text_sensor_type_(AsyncResponseStream *stream) {
|
470
|
+
stream->print(F("#TYPE esphome_text_sensor_value gauge\n"));
|
471
|
+
stream->print(F("#TYPE esphome_text_sensor_failed gauge\n"));
|
472
|
+
}
|
473
|
+
void PrometheusHandler::text_sensor_row_(AsyncResponseStream *stream, text_sensor::TextSensor *obj, std::string &area,
|
474
|
+
std::string &node, std::string &friendly_name) {
|
475
|
+
if (obj->is_internal() && !this->include_internal_)
|
476
|
+
return;
|
477
|
+
if (obj->has_state()) {
|
478
|
+
// We have a valid value, output this value
|
479
|
+
stream->print(F("esphome_text_sensor_failed{id=\""));
|
480
|
+
stream->print(relabel_id_(obj).c_str());
|
481
|
+
add_area_label_(stream, area);
|
482
|
+
add_node_label_(stream, node);
|
483
|
+
add_friendly_name_label_(stream, friendly_name);
|
484
|
+
stream->print(F("\",name=\""));
|
485
|
+
stream->print(relabel_name_(obj).c_str());
|
486
|
+
stream->print(F("\"} 0\n"));
|
487
|
+
// Data itself
|
488
|
+
stream->print(F("esphome_text_sensor_value{id=\""));
|
489
|
+
stream->print(relabel_id_(obj).c_str());
|
490
|
+
add_area_label_(stream, area);
|
491
|
+
add_node_label_(stream, node);
|
492
|
+
add_friendly_name_label_(stream, friendly_name);
|
493
|
+
stream->print(F("\",name=\""));
|
494
|
+
stream->print(relabel_name_(obj).c_str());
|
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"));
|
500
|
+
} else {
|
501
|
+
// Invalid state
|
502
|
+
stream->print(F("esphome_text_sensor_failed{id=\""));
|
503
|
+
stream->print(relabel_id_(obj).c_str());
|
504
|
+
add_area_label_(stream, area);
|
505
|
+
add_node_label_(stream, node);
|
506
|
+
add_friendly_name_label_(stream, friendly_name);
|
507
|
+
stream->print(F("\",name=\""));
|
508
|
+
stream->print(relabel_name_(obj).c_str());
|
509
|
+
stream->print(F("\"} 1\n"));
|
510
|
+
}
|
511
|
+
}
|
512
|
+
#endif
|
513
|
+
|
352
514
|
} // namespace prometheus
|
353
515
|
} // namespace esphome
|
354
516
|
#endif
|