esphome 2024.9.1__py3-none-any.whl → 2024.10.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.
Files changed (196) hide show
  1. esphome/components/aic3204/__init__.py +0 -0
  2. esphome/components/aic3204/aic3204.cpp +173 -0
  3. esphome/components/aic3204/aic3204.h +88 -0
  4. esphome/components/aic3204/audio_dac.py +52 -0
  5. esphome/components/aic3204/automation.h +23 -0
  6. esphome/components/alarm_control_panel/__init__.py +3 -4
  7. esphome/components/animation/__init__.py +16 -12
  8. esphome/components/api/api_connection.cpp +2 -0
  9. esphome/components/api/api_connection.h +3 -1
  10. esphome/components/api/api_frame_helper.cpp +2 -1
  11. esphome/components/api/api_frame_helper.h +2 -1
  12. esphome/components/api/api_server.cpp +2 -0
  13. esphome/components/api/api_server.h +3 -1
  14. esphome/components/api/custom_api_device.h +3 -2
  15. esphome/components/api/homeassistant_service.h +4 -3
  16. esphome/components/api/list_entities.cpp +2 -0
  17. esphome/components/api/list_entities.h +3 -2
  18. esphome/components/api/subscribe_state.cpp +2 -0
  19. esphome/components/api/subscribe_state.h +3 -2
  20. esphome/components/audio_dac/__init__.py +57 -0
  21. esphome/components/audio_dac/audio_dac.h +23 -0
  22. esphome/components/audio_dac/automation.h +43 -0
  23. esphome/components/bang_bang/bang_bang_climate.cpp +5 -2
  24. esphome/components/bedjet/bedjet_codec.cpp +4 -2
  25. esphome/components/binary_sensor/__init__.py +3 -4
  26. esphome/components/bl0906/sensor.py +3 -2
  27. esphome/components/button/__init__.py +3 -4
  28. esphome/components/ch422g/__init__.py +26 -17
  29. esphome/components/ch422g/ch422g.cpp +66 -49
  30. esphome/components/ch422g/ch422g.h +17 -19
  31. esphome/components/climate/__init__.py +3 -4
  32. esphome/components/cover/__init__.py +4 -5
  33. esphome/components/cse7766/cse7766.cpp +12 -1
  34. esphome/components/cse7766/cse7766.h +4 -0
  35. esphome/components/cse7766/sensor.py +13 -1
  36. esphome/components/cst816/touchscreen/__init__.py +7 -4
  37. esphome/components/cst816/touchscreen/cst816_touchscreen.cpp +20 -19
  38. esphome/components/cst816/touchscreen/cst816_touchscreen.h +2 -0
  39. esphome/components/datetime/__init__.py +21 -14
  40. esphome/components/datetime/datetime_base.h +8 -1
  41. esphome/components/datetime/datetime_entity.cpp +2 -0
  42. esphome/components/datetime/datetime_entity.h +2 -0
  43. esphome/components/datetime/time_entity.cpp +2 -0
  44. esphome/components/datetime/time_entity.h +2 -0
  45. esphome/components/esp32/__init__.py +20 -4
  46. esphome/components/esp32_improv/__init__.py +82 -1
  47. esphome/components/esp32_improv/automation.h +72 -0
  48. esphome/components/esp32_improv/esp32_improv_component.cpp +13 -5
  49. esphome/components/esp32_improv/esp32_improv_component.h +15 -0
  50. esphome/components/ethernet/__init__.py +5 -0
  51. esphome/components/ethernet/ethernet_component.cpp +13 -0
  52. esphome/components/ethernet/ethernet_component.h +1 -0
  53. esphome/components/event/__init__.py +20 -12
  54. esphome/components/fan/__init__.py +3 -4
  55. esphome/components/gp2y1010au0f/__init__.py +0 -0
  56. esphome/components/gp2y1010au0f/gp2y1010au0f.cpp +67 -0
  57. esphome/components/gp2y1010au0f/gp2y1010au0f.h +52 -0
  58. esphome/components/gp2y1010au0f/sensor.py +61 -0
  59. esphome/components/gpio_expander/__init__.py +0 -0
  60. esphome/components/gpio_expander/cached_gpio.h +38 -0
  61. esphome/components/grove_gas_mc_v2/__init__.py +0 -0
  62. esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.cpp +88 -0
  63. esphome/components/grove_gas_mc_v2/grove_gas_mc_v2.h +39 -0
  64. esphome/components/grove_gas_mc_v2/sensor.py +77 -0
  65. esphome/components/haier/climate.py +4 -3
  66. esphome/components/haier/haier_base.cpp +63 -8
  67. esphome/components/haier/haier_base.h +29 -3
  68. esphome/components/haier/hon_climate.cpp +122 -65
  69. esphome/components/haier/hon_climate.h +18 -2
  70. esphome/components/haier/smartair2_climate.cpp +21 -21
  71. esphome/components/haier/switch/__init__.py +91 -0
  72. esphome/components/haier/switch/beeper.cpp +14 -0
  73. esphome/components/haier/switch/beeper.h +18 -0
  74. esphome/components/haier/switch/display.cpp +14 -0
  75. esphome/components/haier/switch/display.h +18 -0
  76. esphome/components/haier/switch/health_mode.cpp +14 -0
  77. esphome/components/haier/switch/health_mode.h +18 -0
  78. esphome/components/haier/switch/quiet_mode.cpp +14 -0
  79. esphome/components/haier/switch/quiet_mode.h +18 -0
  80. esphome/components/hmac_md5/hmac_md5.cpp +2 -0
  81. esphome/components/hmac_md5/hmac_md5.h +2 -1
  82. esphome/components/i2s_audio/speaker/__init__.py +19 -0
  83. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +1 -1
  84. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +2 -0
  85. esphome/components/ili9xxx/ili9xxx_display.h +1 -0
  86. esphome/components/image/__init__.py +12 -12
  87. esphome/components/image/image.cpp +44 -0
  88. esphome/components/image/image.h +17 -2
  89. esphome/components/inkplate6/display.py +2 -0
  90. esphome/components/inkplate6/inkplate.h +30 -2
  91. esphome/components/light/__init__.py +3 -4
  92. esphome/components/lock/__init__.py +3 -4
  93. esphome/components/lvgl/__init__.py +16 -5
  94. esphome/components/lvgl/defines.py +1 -0
  95. esphome/components/lvgl/hello_world.py +64 -0
  96. esphome/components/lvgl/lv_validation.py +159 -3
  97. esphome/components/lvgl/lvgl_esphome.cpp +0 -43
  98. esphome/components/lvgl/lvgl_esphome.h +0 -4
  99. esphome/components/lvgl/styles.py +3 -2
  100. esphome/components/lvgl/text/__init__.py +3 -3
  101. esphome/components/lvgl/widgets/__init__.py +2 -0
  102. esphome/components/lvgl/widgets/animimg.py +3 -4
  103. esphome/components/lvgl/widgets/dropdown.py +5 -1
  104. esphome/components/lvgl/widgets/meter.py +16 -11
  105. esphome/components/md5/__init__.py +6 -0
  106. esphome/components/md5/md5.cpp +2 -0
  107. esphome/components/md5/md5.h +2 -0
  108. esphome/components/micro_wake_word/__init__.py +7 -0
  109. esphome/components/mics_4514/sensor.py +11 -26
  110. esphome/components/modbus_controller/__init__.py +7 -5
  111. esphome/components/modbus_controller/binary_sensor/__init__.py +6 -6
  112. esphome/components/modbus_controller/number/__init__.py +5 -6
  113. esphome/components/modbus_controller/output/__init__.py +10 -14
  114. esphome/components/modbus_controller/select/__init__.py +1 -1
  115. esphome/components/modbus_controller/sensor/__init__.py +7 -7
  116. esphome/components/modbus_controller/switch/__init__.py +6 -7
  117. esphome/components/modbus_controller/text_sensor/__init__.py +8 -9
  118. esphome/components/mqtt/__init__.py +3 -0
  119. esphome/components/mqtt/mqtt_client.cpp +2 -0
  120. esphome/components/mqtt/mqtt_client.h +2 -0
  121. esphome/components/nau7802/__init__.py +0 -0
  122. esphome/components/nau7802/nau7802.cpp +323 -0
  123. esphome/components/nau7802/nau7802.h +121 -0
  124. esphome/components/nau7802/sensor.py +134 -0
  125. esphome/components/nextion/base_component.py +1 -0
  126. esphome/components/nextion/display.py +4 -0
  127. esphome/components/nextion/nextion.cpp +19 -4
  128. esphome/components/nextion/nextion.h +16 -0
  129. esphome/components/npi19/__init__.py +0 -0
  130. esphome/components/npi19/npi19.cpp +111 -0
  131. esphome/components/npi19/npi19.h +30 -0
  132. esphome/components/npi19/sensor.py +52 -0
  133. esphome/components/number/__init__.py +3 -5
  134. esphome/components/online_image/__init__.py +1 -1
  135. esphome/components/online_image/online_image.h +1 -2
  136. esphome/components/opentherm/__init__.py +57 -0
  137. esphome/components/opentherm/hub.cpp +277 -0
  138. esphome/components/opentherm/hub.h +110 -0
  139. esphome/components/opentherm/opentherm.cpp +568 -0
  140. esphome/components/opentherm/opentherm.h +347 -0
  141. esphome/components/pulse_counter/pulse_counter_sensor.cpp +8 -1
  142. esphome/components/pulse_counter/pulse_counter_sensor.h +1 -0
  143. esphome/components/radon_eye_ble/radon_eye_listener.cpp +10 -3
  144. esphome/components/remote_transmitter/__init__.py +18 -2
  145. esphome/components/remote_transmitter/remote_transmitter.h +6 -0
  146. esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +2 -0
  147. esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +2 -0
  148. esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +2 -0
  149. esphome/components/rp2040/__init__.py +13 -14
  150. esphome/components/select/__init__.py +3 -4
  151. esphome/components/sensor/__init__.py +3 -4
  152. esphome/components/shelly_dimmer/shelly_dimmer.cpp +32 -32
  153. esphome/components/shelly_dimmer/shelly_dimmer.h +2 -0
  154. esphome/components/st7701s/st7701s.cpp +21 -8
  155. esphome/components/st7701s/st7701s.h +2 -0
  156. esphome/components/switch/__init__.py +3 -4
  157. esphome/components/tca9555/__init__.py +72 -0
  158. esphome/components/tca9555/tca9555.cpp +140 -0
  159. esphome/components/tca9555/tca9555.h +64 -0
  160. esphome/components/tcs34725/tcs34725.cpp +62 -64
  161. esphome/components/tem3200/__init__.py +0 -0
  162. esphome/components/tem3200/sensor.py +55 -0
  163. esphome/components/tem3200/tem3200.cpp +151 -0
  164. esphome/components/tem3200/tem3200.h +30 -0
  165. esphome/components/template/binary_sensor/__init__.py +19 -6
  166. esphome/components/text/__init__.py +3 -4
  167. esphome/components/text_sensor/__init__.py +3 -4
  168. esphome/components/thermostat/climate.py +11 -9
  169. esphome/components/thermostat/thermostat_climate.cpp +21 -15
  170. esphome/components/tm1638/binary_sensor/__init__.py +3 -2
  171. esphome/components/tm1638/display.py +5 -5
  172. esphome/components/tm1638/output/__init__.py +3 -2
  173. esphome/components/tm1638/switch/__init__.py +3 -2
  174. esphome/components/touchscreen/touchscreen.cpp +2 -2
  175. esphome/components/update/__init__.py +3 -4
  176. esphome/components/valve/__init__.py +3 -4
  177. esphome/components/web_server/__init__.py +78 -22
  178. esphome/components/web_server/server_index_v3.h +3989 -3979
  179. esphome/components/web_server/web_server.cpp +219 -34
  180. esphome/components/web_server/web_server.h +10 -1
  181. esphome/components/wifi/wifi_component_esp_idf.cpp +4 -5
  182. esphome/config_validation.py +1 -0
  183. esphome/const.py +12 -2
  184. esphome/core/defines.h +4 -2
  185. esphome/core/helpers.cpp +46 -10
  186. esphome/core/helpers.h +8 -0
  187. esphome/core/ring_buffer.cpp +12 -2
  188. esphome/core/ring_buffer.h +3 -0
  189. esphome/voluptuous_schema.py +3 -1
  190. esphome/wizard.py +0 -3
  191. {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/METADATA +5 -3
  192. {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/RECORD +196 -147
  193. {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/LICENSE +0 -0
  194. {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/WHEEL +0 -0
  195. {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/entry_points.txt +0 -0
  196. {esphome-2024.9.1.dist-info → esphome-2024.10.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,55 @@
1
+ import esphome.codegen as cg
2
+ import esphome.config_validation as cv
3
+ from esphome.components import i2c, sensor
4
+
5
+ from esphome.const import (
6
+ CONF_ID,
7
+ CONF_TEMPERATURE,
8
+ DEVICE_CLASS_TEMPERATURE,
9
+ STATE_CLASS_MEASUREMENT,
10
+ UNIT_CELSIUS,
11
+ )
12
+
13
+ CODEOWNERS = ["@bakerkj"]
14
+ DEPENDENCIES = ["i2c"]
15
+
16
+ tem3200_ns = cg.esphome_ns.namespace("tem3200")
17
+
18
+ TEM3200Component = tem3200_ns.class_(
19
+ "TEM3200Component", cg.PollingComponent, i2c.I2CDevice
20
+ )
21
+
22
+ CONF_RAW_PRESSURE = "raw_pressure"
23
+
24
+ CONFIG_SCHEMA = (
25
+ cv.Schema(
26
+ {
27
+ cv.GenerateID(): cv.declare_id(TEM3200Component),
28
+ cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
29
+ unit_of_measurement=UNIT_CELSIUS,
30
+ accuracy_decimals=1,
31
+ device_class=DEVICE_CLASS_TEMPERATURE,
32
+ state_class=STATE_CLASS_MEASUREMENT,
33
+ ),
34
+ cv.Optional(CONF_RAW_PRESSURE): sensor.sensor_schema(
35
+ accuracy_decimals=0, state_class=STATE_CLASS_MEASUREMENT
36
+ ),
37
+ }
38
+ )
39
+ .extend(cv.polling_component_schema("60s"))
40
+ .extend(i2c.i2c_device_schema(0x28))
41
+ )
42
+
43
+
44
+ async def to_code(config):
45
+ var = cg.new_Pvariable(config[CONF_ID])
46
+ await cg.register_component(var, config)
47
+ await i2c.register_i2c_device(var, config)
48
+
49
+ if temperature_config := config.get(CONF_TEMPERATURE):
50
+ sens = await sensor.new_sensor(temperature_config)
51
+ cg.add(var.set_temperature_sensor(sens))
52
+
53
+ if raw_pressure_config := config.get(CONF_RAW_PRESSURE):
54
+ sens = await sensor.new_sensor(raw_pressure_config)
55
+ cg.add(var.set_raw_pressure_sensor(sens))
@@ -0,0 +1,151 @@
1
+ #include "tem3200.h"
2
+ #include "esphome/core/log.h"
3
+ #include "esphome/core/helpers.h"
4
+ #include "esphome/core/hal.h"
5
+
6
+ namespace esphome {
7
+ namespace tem3200 {
8
+
9
+ static const char *const TAG = "tem3200";
10
+
11
+ enum ErrorCode {
12
+ NONE = 0,
13
+ RESERVED = 1,
14
+ STALE = 2,
15
+ FAULT = 3,
16
+ };
17
+
18
+ void TEM3200Component::setup() {
19
+ ESP_LOGCONFIG(TAG, "Setting up TEM3200...");
20
+
21
+ uint8_t status(NONE);
22
+ uint16_t raw_temperature(0);
23
+ uint16_t raw_pressure(0);
24
+
25
+ i2c::ErrorCode err = this->read_(status, raw_temperature, raw_pressure);
26
+ if (err != i2c::ERROR_OK) {
27
+ ESP_LOGCONFIG(TAG, " I2C Communication Failed...");
28
+ this->mark_failed();
29
+ return;
30
+ }
31
+
32
+ switch (status) {
33
+ case RESERVED:
34
+ ESP_LOGE(TAG, "Invalid RESERVED Device Status");
35
+ this->mark_failed();
36
+ return;
37
+ case FAULT:
38
+ ESP_LOGE(TAG, "FAULT condition in the SSC or sensing element");
39
+ this->mark_failed();
40
+ return;
41
+ case STALE:
42
+ ESP_LOGE(TAG, "STALE data. Data has not been updated since last fetch");
43
+ this->status_set_warning();
44
+ break;
45
+ }
46
+ ESP_LOGCONFIG(TAG, " Success...");
47
+ }
48
+
49
+ void TEM3200Component::dump_config() {
50
+ ESP_LOGCONFIG(TAG, "TEM3200:");
51
+ LOG_I2C_DEVICE(this);
52
+ LOG_UPDATE_INTERVAL(this);
53
+ LOG_SENSOR(" ", "Raw Pressure", this->raw_pressure_sensor_);
54
+ LOG_SENSOR(" ", "Temperature", this->temperature_sensor_);
55
+ }
56
+
57
+ float TEM3200Component::get_setup_priority() const { return setup_priority::DATA; }
58
+
59
+ i2c::ErrorCode TEM3200Component::read_(uint8_t &status, uint16_t &raw_temperature, uint16_t &raw_pressure) {
60
+ uint8_t response[4] = {0x00, 0x00, 0x00, 0x00};
61
+
62
+ // initiate data read
63
+ i2c::ErrorCode err = this->read(response, 4);
64
+ if (err != i2c::ERROR_OK) {
65
+ return err;
66
+ }
67
+
68
+ // extract top 2 bits of first byte for status
69
+ status = (ErrorCode) (response[0] & 0xc0) >> 6;
70
+ if (status == RESERVED || status == FAULT) {
71
+ return i2c::ERROR_OK;
72
+ }
73
+
74
+ // if data is stale; reread
75
+ if (status == STALE) {
76
+ // wait for measurement 2ms
77
+ delay(2);
78
+
79
+ err = this->read(response, 4);
80
+ if (err != i2c::ERROR_OK) {
81
+ return err;
82
+ }
83
+ }
84
+
85
+ // extract top 2 bits of first byte for status
86
+ status = (ErrorCode) (response[0] & 0xc0) >> 6;
87
+ if (status == RESERVED || status == FAULT) {
88
+ return i2c::ERROR_OK;
89
+ }
90
+
91
+ // extract top 6 bits of first byte and all bits of second byte for pressure
92
+ raw_pressure = (((response[0] & 0x3f)) << 8 | response[1]);
93
+
94
+ // extract all bytes of 3rd byte and top 3 bits of fourth byte for temperature
95
+ raw_temperature = ((response[2] << 3) | (response[3] & 0xe0) >> 5);
96
+
97
+ return i2c::ERROR_OK;
98
+ }
99
+
100
+ inline float convert_temperature(uint16_t raw_temperature) {
101
+ const float temperature_bits_span = 2048;
102
+ const float temperature_max = 150;
103
+ const float temperature_min = -50;
104
+ const float temperature_span = temperature_max - temperature_min;
105
+
106
+ float temperature = (raw_temperature * temperature_span / temperature_bits_span) + temperature_min;
107
+
108
+ return temperature;
109
+ }
110
+
111
+ void TEM3200Component::update() {
112
+ uint8_t status(NONE);
113
+ uint16_t raw_temperature(0);
114
+ uint16_t raw_pressure(0);
115
+ i2c::ErrorCode err = this->read_(status, raw_temperature, raw_pressure);
116
+
117
+ if (err != i2c::ERROR_OK) {
118
+ ESP_LOGW(TAG, "I2C Communication Failed");
119
+ this->status_set_warning();
120
+ return;
121
+ }
122
+
123
+ switch (status) {
124
+ case RESERVED:
125
+ ESP_LOGE(TAG, "Failed: Device return RESERVED status");
126
+ this->status_set_warning();
127
+ return;
128
+ case FAULT:
129
+ ESP_LOGE(TAG, "Failed: FAULT condition in the SSC or sensing element");
130
+ this->mark_failed();
131
+ return;
132
+ case STALE:
133
+ ESP_LOGE(TAG, "Warning: STALE data. Data has not been updated since last fetch");
134
+ this->status_set_warning();
135
+ return;
136
+ }
137
+
138
+ float temperature = convert_temperature(raw_temperature);
139
+
140
+ ESP_LOGD(TAG, "Got raw pressure=%d, temperature=%.1f°C", raw_pressure, temperature);
141
+
142
+ if (this->temperature_sensor_ != nullptr)
143
+ this->temperature_sensor_->publish_state(temperature);
144
+ if (this->raw_pressure_sensor_ != nullptr)
145
+ this->raw_pressure_sensor_->publish_state(raw_pressure);
146
+
147
+ this->status_clear_warning();
148
+ }
149
+
150
+ } // namespace tem3200
151
+ } // namespace esphome
@@ -0,0 +1,30 @@
1
+ #pragma once
2
+
3
+ #include "esphome/core/component.h"
4
+ #include "esphome/components/sensor/sensor.h"
5
+ #include "esphome/components/i2c/i2c.h"
6
+
7
+ namespace esphome {
8
+ namespace tem3200 {
9
+
10
+ /// This class implements support for the tem3200 pressure and temperature i2c sensors.
11
+ class TEM3200Component : public PollingComponent, public i2c::I2CDevice {
12
+ public:
13
+ void set_temperature_sensor(sensor::Sensor *temperature_sensor) { this->temperature_sensor_ = temperature_sensor; }
14
+ void set_raw_pressure_sensor(sensor::Sensor *raw_pressure_sensor) {
15
+ this->raw_pressure_sensor_ = raw_pressure_sensor;
16
+ }
17
+
18
+ float get_setup_priority() const override;
19
+ void setup() override;
20
+ void dump_config() override;
21
+ void update() override;
22
+
23
+ protected:
24
+ i2c::ErrorCode read_(uint8_t &status, uint16_t &raw_temperature, uint16_t &raw_pressure);
25
+ sensor::Sensor *temperature_sensor_{nullptr};
26
+ sensor::Sensor *raw_pressure_sensor_{nullptr};
27
+ };
28
+
29
+ } // namespace tem3200
30
+ } // namespace esphome
@@ -1,8 +1,10 @@
1
- import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
1
  from esphome import automation
2
+ import esphome.codegen as cg
4
3
  from esphome.components import binary_sensor
5
- from esphome.const import CONF_ID, CONF_LAMBDA, CONF_STATE
4
+ import esphome.config_validation as cv
5
+ from esphome.const import CONF_CONDITION, CONF_ID, CONF_LAMBDA, CONF_STATE
6
+ from esphome.cpp_generator import LambdaExpression
7
+
6
8
  from .. import template_ns
7
9
 
8
10
  TemplateBinarySensor = template_ns.class_(
@@ -13,7 +15,10 @@ CONFIG_SCHEMA = (
13
15
  binary_sensor.binary_sensor_schema(TemplateBinarySensor)
14
16
  .extend(
15
17
  {
16
- cv.Optional(CONF_LAMBDA): cv.returning_lambda,
18
+ cv.Exclusive(CONF_LAMBDA, CONF_CONDITION): cv.returning_lambda,
19
+ cv.Exclusive(
20
+ CONF_CONDITION, CONF_CONDITION
21
+ ): automation.validate_potentially_and_condition,
17
22
  }
18
23
  )
19
24
  .extend(cv.COMPONENT_SCHEMA)
@@ -24,9 +29,17 @@ async def to_code(config):
24
29
  var = await binary_sensor.new_binary_sensor(config)
25
30
  await cg.register_component(var, config)
26
31
 
27
- if CONF_LAMBDA in config:
32
+ if lamb := config.get(CONF_LAMBDA):
28
33
  template_ = await cg.process_lambda(
29
- config[CONF_LAMBDA], [], return_type=cg.optional.template(bool)
34
+ lamb, [], return_type=cg.optional.template(bool)
35
+ )
36
+ cg.add(var.set_template(template_))
37
+ if condition := config.get(CONF_CONDITION):
38
+ condition = await automation.build_condition(
39
+ condition, cg.TemplateArguments(), []
40
+ )
41
+ template_ = LambdaExpression(
42
+ f"return {condition.check()};", [], return_type=cg.optional.template(bool)
30
43
  )
31
44
  cg.add(var.set_template(template_))
32
45
 
@@ -11,7 +11,7 @@ from esphome.const import (
11
11
  CONF_ON_VALUE,
12
12
  CONF_TRIGGER_ID,
13
13
  CONF_VALUE,
14
- CONF_WEB_SERVER_ID,
14
+ CONF_WEB_SERVER,
15
15
  )
16
16
  from esphome.core import CORE, coroutine_with_priority
17
17
  from esphome.cpp_helpers import setup_entity
@@ -82,9 +82,8 @@ async def setup_text_core_(
82
82
  mqtt_ = cg.new_Pvariable(mqtt_id, var)
83
83
  await mqtt.register_mqtt_component(mqtt_, config)
84
84
 
85
- if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
86
- web_server_ = await cg.get_variable(webserver_id)
87
- web_server.add_entity_to_sorting_list(web_server_, var, config)
85
+ if web_server_config := config.get(CONF_WEB_SERVER):
86
+ await web_server.add_entity_config(var, web_server_config)
88
87
 
89
88
 
90
89
  async def register_text(
@@ -15,7 +15,7 @@ from esphome.const import (
15
15
  CONF_STATE,
16
16
  CONF_TO,
17
17
  CONF_TRIGGER_ID,
18
- CONF_WEB_SERVER_ID,
18
+ CONF_WEB_SERVER,
19
19
  DEVICE_CLASS_DATE,
20
20
  DEVICE_CLASS_EMPTY,
21
21
  DEVICE_CLASS_TIMESTAMP,
@@ -212,9 +212,8 @@ async def setup_text_sensor_core_(var, config):
212
212
  mqtt_ = cg.new_Pvariable(mqtt_id, var)
213
213
  await mqtt.register_mqtt_component(mqtt_, config)
214
214
 
215
- if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
216
- web_server_ = await cg.get_variable(webserver_id)
217
- web_server.add_entity_to_sorting_list(web_server_, var, config)
215
+ if web_server_config := config.get(CONF_WEB_SERVER):
216
+ await web_server.add_entity_config(var, web_server_config)
218
217
 
219
218
 
220
219
  async def register_text_sensor(var, config):
@@ -1,7 +1,7 @@
1
- import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
1
  from esphome import automation
2
+ import esphome.codegen as cg
4
3
  from esphome.components import climate, sensor
4
+ import esphome.config_validation as cv
5
5
  from esphome.const import (
6
6
  CONF_AUTO_MODE,
7
7
  CONF_AWAY_CONFIG,
@@ -15,15 +15,15 @@ from esphome.const import (
15
15
  CONF_DRY_ACTION,
16
16
  CONF_DRY_MODE,
17
17
  CONF_FAN_MODE,
18
- CONF_FAN_MODE_ON_ACTION,
19
- CONF_FAN_MODE_OFF_ACTION,
20
18
  CONF_FAN_MODE_AUTO_ACTION,
19
+ CONF_FAN_MODE_DIFFUSE_ACTION,
20
+ CONF_FAN_MODE_FOCUS_ACTION,
21
+ CONF_FAN_MODE_HIGH_ACTION,
21
22
  CONF_FAN_MODE_LOW_ACTION,
22
23
  CONF_FAN_MODE_MEDIUM_ACTION,
23
- CONF_FAN_MODE_HIGH_ACTION,
24
24
  CONF_FAN_MODE_MIDDLE_ACTION,
25
- CONF_FAN_MODE_FOCUS_ACTION,
26
- CONF_FAN_MODE_DIFFUSE_ACTION,
25
+ CONF_FAN_MODE_OFF_ACTION,
26
+ CONF_FAN_MODE_ON_ACTION,
27
27
  CONF_FAN_MODE_QUIET_ACTION,
28
28
  CONF_FAN_ONLY_ACTION,
29
29
  CONF_FAN_ONLY_ACTION_USES_FAN_MODE_TIMER,
@@ -50,8 +50,8 @@ from esphome.const import (
50
50
  CONF_MIN_HEATING_RUN_TIME,
51
51
  CONF_MIN_IDLE_TIME,
52
52
  CONF_MIN_TEMPERATURE,
53
- CONF_NAME,
54
53
  CONF_MODE,
54
+ CONF_NAME,
55
55
  CONF_OFF_MODE,
56
56
  CONF_PRESET,
57
57
  CONF_SENSOR,
@@ -892,7 +892,7 @@ async def to_code(config):
892
892
  if name.upper() in climate.CLIMATE_PRESETS:
893
893
  standard_preset = climate.CLIMATE_PRESETS[name.upper()]
894
894
 
895
- if two_points_available is True:
895
+ if two_points_available:
896
896
  preset_target_config = ThermostatClimateTargetTempConfig(
897
897
  preset_config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW],
898
898
  preset_config[CONF_DEFAULT_TARGET_TEMPERATURE_HIGH],
@@ -905,6 +905,8 @@ async def to_code(config):
905
905
  preset_target_config = ThermostatClimateTargetTempConfig(
906
906
  preset_config[CONF_DEFAULT_TARGET_TEMPERATURE_LOW]
907
907
  )
908
+ else:
909
+ preset_target_config = None
908
910
 
909
911
  preset_target_variable = cg.new_variable(
910
912
  preset_config[CONF_ID], preset_target_config
@@ -502,8 +502,9 @@ void ThermostatClimate::switch_to_action_(climate::ClimateAction action, bool pu
502
502
  }
503
503
  this->action = action;
504
504
  this->prev_action_trigger_ = trig;
505
- assert(trig != nullptr);
506
- trig->trigger();
505
+ if (trig != nullptr) {
506
+ trig->trigger();
507
+ }
507
508
  // if enabled, call the fan_only action with cooling/heating actions
508
509
  if (trig_fan != nullptr) {
509
510
  ESP_LOGVV(TAG, "Calling FAN_ONLY action with HEATING/COOLING action");
@@ -564,7 +565,6 @@ void ThermostatClimate::trigger_supplemental_action_() {
564
565
  }
565
566
 
566
567
  if (trig != nullptr) {
567
- assert(trig != nullptr);
568
568
  trig->trigger();
569
569
  }
570
570
  }
@@ -634,8 +634,9 @@ void ThermostatClimate::switch_to_fan_mode_(climate::ClimateFanMode fan_mode, bo
634
634
  this->prev_fan_mode_trigger_ = nullptr;
635
635
  }
636
636
  this->start_timer_(thermostat::TIMER_FAN_MODE);
637
- assert(trig != nullptr);
638
- trig->trigger();
637
+ if (trig != nullptr) {
638
+ trig->trigger();
639
+ }
639
640
  this->prev_fan_mode_ = fan_mode;
640
641
  this->prev_fan_mode_trigger_ = trig;
641
642
  }
@@ -678,8 +679,9 @@ void ThermostatClimate::switch_to_mode_(climate::ClimateMode mode, bool publish_
678
679
  mode = climate::CLIMATE_MODE_HEAT_COOL;
679
680
  // trig = this->auto_mode_trigger_;
680
681
  }
681
- assert(trig != nullptr);
682
- trig->trigger();
682
+ if (trig != nullptr) {
683
+ trig->trigger();
684
+ }
683
685
  this->mode = mode;
684
686
  this->prev_mode_ = mode;
685
687
  this->prev_mode_trigger_ = trig;
@@ -718,8 +720,9 @@ void ThermostatClimate::switch_to_swing_mode_(climate::ClimateSwingMode swing_mo
718
720
  swing_mode = climate::CLIMATE_SWING_OFF;
719
721
  // trig = this->swing_mode_off_trigger_;
720
722
  }
721
- assert(trig != nullptr);
722
- trig->trigger();
723
+ if (trig != nullptr) {
724
+ trig->trigger();
725
+ }
723
726
  this->swing_mode = swing_mode;
724
727
  this->prev_swing_mode_ = swing_mode;
725
728
  this->prev_swing_mode_trigger_ = trig;
@@ -867,8 +870,9 @@ void ThermostatClimate::check_temperature_change_trigger_() {
867
870
  }
868
871
  // trigger the action
869
872
  Trigger<> *trig = this->temperature_change_trigger_;
870
- assert(trig != nullptr);
871
- trig->trigger();
873
+ if (trig != nullptr) {
874
+ trig->trigger();
875
+ }
872
876
  }
873
877
 
874
878
  bool ThermostatClimate::cooling_required_() {
@@ -998,9 +1002,10 @@ void ThermostatClimate::change_preset_(climate::ClimatePreset preset) {
998
1002
  this->preset.value() != preset) {
999
1003
  // Fire any preset changed trigger if defined
1000
1004
  Trigger<> *trig = this->preset_change_trigger_;
1001
- assert(trig != nullptr);
1002
1005
  this->preset = preset;
1003
- trig->trigger();
1006
+ if (trig != nullptr) {
1007
+ trig->trigger();
1008
+ }
1004
1009
 
1005
1010
  this->refresh();
1006
1011
  ESP_LOGI(TAG, "Preset %s applied", LOG_STR_ARG(climate::climate_preset_to_string(preset)));
@@ -1023,9 +1028,10 @@ void ThermostatClimate::change_custom_preset_(const std::string &custom_preset)
1023
1028
  this->custom_preset.value() != custom_preset) {
1024
1029
  // Fire any preset changed trigger if defined
1025
1030
  Trigger<> *trig = this->preset_change_trigger_;
1026
- assert(trig != nullptr);
1027
1031
  this->custom_preset = custom_preset;
1028
- trig->trigger();
1032
+ if (trig != nullptr) {
1033
+ trig->trigger();
1034
+ }
1029
1035
 
1030
1036
  this->refresh();
1031
1037
  ESP_LOGI(TAG, "Custom preset %s applied", custom_preset.c_str());
@@ -1,8 +1,9 @@
1
1
  import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
2
  from esphome.components import binary_sensor
3
+ import esphome.config_validation as cv
4
4
  from esphome.const import CONF_KEY
5
- from ..display import tm1638_ns, TM1638Component, CONF_TM1638_ID
5
+
6
+ from ..display import CONF_TM1638_ID, TM1638Component, tm1638_ns
6
7
 
7
8
  TM1638Key = tm1638_ns.class_("TM1638Key", binary_sensor.BinarySensor)
8
9
 
@@ -1,13 +1,13 @@
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
4
+ import esphome.config_validation as cv
5
5
  from esphome.const import (
6
+ CONF_CLK_PIN,
7
+ CONF_DIO_PIN,
6
8
  CONF_ID,
7
9
  CONF_INTENSITY,
8
10
  CONF_LAMBDA,
9
- CONF_CLK_PIN,
10
- CONF_DIO_PIN,
11
11
  CONF_STB_PIN,
12
12
  )
13
13
 
@@ -51,4 +51,4 @@ async def to_code(config):
51
51
  config[CONF_LAMBDA], [(TM1638ComponentRef, "it")], return_type=cg.void
52
52
  )
53
53
 
54
- cg.add(var.set_writer(lambda_))
54
+ cg.add(var.set_writer(lambda_))
@@ -1,8 +1,9 @@
1
1
  import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
2
  from esphome.components import output
3
+ import esphome.config_validation as cv
4
4
  from esphome.const import CONF_ID, CONF_LED
5
- from ..display import tm1638_ns, TM1638Component, CONF_TM1638_ID
5
+
6
+ from ..display import CONF_TM1638_ID, TM1638Component, tm1638_ns
6
7
 
7
8
  TM1638OutputLed = tm1638_ns.class_("TM1638OutputLed", output.BinaryOutput, cg.Component)
8
9
 
@@ -1,8 +1,9 @@
1
1
  import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
2
  from esphome.components import switch
3
+ import esphome.config_validation as cv
4
4
  from esphome.const import CONF_LED
5
- from ..display import tm1638_ns, TM1638Component, CONF_TM1638_ID
5
+
6
+ from ..display import CONF_TM1638_ID, TM1638Component, tm1638_ns
6
7
 
7
8
  TM1638SwitchLed = tm1638_ns.class_("TM1638SwitchLed", switch.Switch, cg.Component)
8
9
 
@@ -18,8 +18,8 @@ void Touchscreen::attach_interrupt_(InternalGPIOPin *irq_pin, esphome::gpio::Int
18
18
 
19
19
  void Touchscreen::call_setup() {
20
20
  if (this->display_ != nullptr) {
21
- this->display_width_ = this->display_->get_native_width();
22
- this->display_height_ = this->display_->get_native_height();
21
+ this->display_width_ = this->display_->get_width();
22
+ this->display_height_ = this->display_->get_height();
23
23
  }
24
24
  PollingComponent::call_setup();
25
25
  }
@@ -8,7 +8,7 @@ from esphome.const import (
8
8
  CONF_FORCE_UPDATE,
9
9
  CONF_ID,
10
10
  CONF_MQTT_ID,
11
- CONF_WEB_SERVER_ID,
11
+ CONF_WEB_SERVER,
12
12
  DEVICE_CLASS_EMPTY,
13
13
  DEVICE_CLASS_FIRMWARE,
14
14
  ENTITY_CATEGORY_CONFIG,
@@ -73,9 +73,8 @@ async def setup_update_core_(var, config):
73
73
  mqtt_ = cg.new_Pvariable(mqtt_id_config, var)
74
74
  await mqtt.register_mqtt_component(mqtt_, config)
75
75
 
76
- if web_server_id_config := config.get(CONF_WEB_SERVER_ID):
77
- web_server_ = await cg.get_variable(web_server_id_config)
78
- web_server.add_entity_to_sorting_list(web_server_, var, config)
76
+ if web_server_config := config.get(CONF_WEB_SERVER):
77
+ await web_server.add_entity_config(var, web_server_config)
79
78
 
80
79
 
81
80
  async def register_update(var, config):
@@ -14,7 +14,7 @@ from esphome.const import (
14
14
  CONF_STATE,
15
15
  CONF_STOP,
16
16
  CONF_TRIGGER_ID,
17
- CONF_WEB_SERVER_ID,
17
+ CONF_WEB_SERVER,
18
18
  DEVICE_CLASS_EMPTY,
19
19
  DEVICE_CLASS_GAS,
20
20
  DEVICE_CLASS_WATER,
@@ -124,9 +124,8 @@ async def setup_valve_core_(var, config):
124
124
  mqtt_.set_custom_position_command_topic(position_command_topic_config)
125
125
  )
126
126
 
127
- if (webserver_id := config.get(CONF_WEB_SERVER_ID)) is not None:
128
- web_server_ = await cg.get_variable(webserver_id)
129
- web_server.add_entity_to_sorting_list(web_server_, var, config)
127
+ if web_server_config := config.get(CONF_WEB_SERVER):
128
+ await web_server.add_entity_config(var, web_server_config)
130
129
 
131
130
 
132
131
  async def register_valve(var, config):