esphome 2025.2.1__py3-none-any.whl → 2025.3.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 (152) hide show
  1. esphome/__main__.py +9 -1
  2. esphome/components/api/api_connection.cpp +426 -70
  3. esphome/components/api/api_connection.h +117 -25
  4. esphome/components/api/api_pb2.cpp +33 -0
  5. esphome/components/api/api_pb2.h +4 -0
  6. esphome/components/api/api_server.cpp +2 -2
  7. esphome/components/api/list_entities.cpp +76 -22
  8. esphome/components/api/list_entities.h +1 -0
  9. esphome/components/api/subscribe_state.h +2 -0
  10. esphome/components/audio/__init__.py +1 -1
  11. esphome/components/audio/audio_decoder.cpp +43 -11
  12. esphome/components/audio/audio_reader.cpp +9 -9
  13. esphome/components/audio/audio_reader.h +1 -1
  14. esphome/components/audio/audio_resampler.cpp +4 -2
  15. esphome/components/audio/audio_transfer_buffer.cpp +19 -9
  16. esphome/components/audio/audio_transfer_buffer.h +7 -2
  17. esphome/components/bluetooth_proxy/bluetooth_proxy.h +8 -0
  18. esphome/components/bmp085/bmp085.cpp +1 -1
  19. esphome/components/chsc6x/__init__.py +2 -0
  20. esphome/components/chsc6x/chsc6x_touchscreen.cpp +47 -0
  21. esphome/components/chsc6x/chsc6x_touchscreen.h +34 -0
  22. esphome/components/chsc6x/touchscreen.py +33 -0
  23. esphome/components/climate/__init__.py +0 -1
  24. esphome/components/cst816/binary_sensor/__init__.py +2 -25
  25. esphome/components/cst816/touchscreen/cst816_touchscreen.cpp +3 -14
  26. esphome/components/cst816/touchscreen/cst816_touchscreen.h +0 -4
  27. esphome/components/esp32_ble_beacon/__init__.py +3 -1
  28. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +2 -2
  29. esphome/components/esp8266/gpio.py +1 -2
  30. esphome/components/font/__init__.py +198 -215
  31. esphome/components/font/font.cpp +4 -4
  32. esphome/components/font/font.h +1 -0
  33. esphome/components/graph/graph.cpp +4 -0
  34. esphome/components/graph/graph.h +4 -0
  35. esphome/components/haier/climate.py +11 -10
  36. esphome/components/hbridge/switch/hbridge_switch.cpp +2 -2
  37. esphome/components/heatpumpir/climate.py +2 -1
  38. esphome/components/heatpumpir/heatpumpir.cpp +1 -0
  39. esphome/components/heatpumpir/heatpumpir.h +1 -0
  40. esphome/components/i2c/__init__.py +6 -6
  41. esphome/components/i2c/i2c_bus_esp_idf.cpp +6 -2
  42. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +1 -1
  43. esphome/components/ili9xxx/display.py +1 -0
  44. esphome/components/ili9xxx/ili9xxx_display.h +5 -0
  45. esphome/components/ili9xxx/ili9xxx_init.h +59 -0
  46. esphome/components/ld2450/__init__.py +51 -0
  47. esphome/components/ld2450/binary_sensor.py +47 -0
  48. esphome/components/ld2450/button/__init__.py +45 -0
  49. esphome/components/ld2450/button/reset_button.cpp +9 -0
  50. esphome/components/ld2450/button/reset_button.h +18 -0
  51. esphome/components/ld2450/button/restart_button.cpp +9 -0
  52. esphome/components/ld2450/button/restart_button.h +18 -0
  53. esphome/components/ld2450/ld2450.cpp +876 -0
  54. esphome/components/ld2450/ld2450.h +234 -0
  55. esphome/components/ld2450/number/__init__.py +121 -0
  56. esphome/components/ld2450/number/presence_timeout_number.cpp +12 -0
  57. esphome/components/ld2450/number/presence_timeout_number.h +18 -0
  58. esphome/components/ld2450/number/zone_coordinate_number.cpp +14 -0
  59. esphome/components/ld2450/number/zone_coordinate_number.h +19 -0
  60. esphome/components/ld2450/select/__init__.py +56 -0
  61. esphome/components/ld2450/select/baud_rate_select.cpp +12 -0
  62. esphome/components/ld2450/select/baud_rate_select.h +18 -0
  63. esphome/components/ld2450/select/zone_type_select.cpp +12 -0
  64. esphome/components/ld2450/select/zone_type_select.h +18 -0
  65. esphome/components/ld2450/sensor.py +156 -0
  66. esphome/components/ld2450/switch/__init__.py +45 -0
  67. esphome/components/ld2450/switch/bluetooth_switch.cpp +12 -0
  68. esphome/components/ld2450/switch/bluetooth_switch.h +18 -0
  69. esphome/components/ld2450/switch/multi_target_switch.cpp +12 -0
  70. esphome/components/ld2450/switch/multi_target_switch.h +18 -0
  71. esphome/components/ld2450/text_sensor.py +62 -0
  72. esphome/components/ltr390/ltr390.cpp +7 -7
  73. esphome/components/ltr390/ltr390.h +0 -1
  74. esphome/components/lvgl/defines.py +0 -2
  75. esphome/components/lvgl/font.cpp +1 -1
  76. esphome/components/lvgl/lvgl_esphome.cpp +27 -19
  77. esphome/components/lvgl/widgets/img.py +1 -3
  78. esphome/components/mcp2515/mcp2515.cpp +1 -0
  79. esphome/components/mdns/__init__.py +1 -1
  80. esphome/components/mixer/speaker/mixer_speaker.cpp +6 -1
  81. esphome/components/mixer/speaker/mixer_speaker.h +2 -0
  82. esphome/components/mlx90393/sensor.py +53 -33
  83. esphome/components/mlx90393/sensor_mlx90393.cpp +4 -0
  84. esphome/components/mlx90393/sensor_mlx90393.h +8 -3
  85. esphome/components/mqtt/__init__.py +2 -2
  86. esphome/components/msa3xx/__init__.py +189 -0
  87. esphome/components/msa3xx/binary_sensor.py +40 -0
  88. esphome/components/msa3xx/msa3xx.cpp +417 -0
  89. esphome/components/msa3xx/msa3xx.h +311 -0
  90. esphome/components/msa3xx/sensor.py +42 -0
  91. esphome/components/msa3xx/text_sensor.py +38 -0
  92. esphome/components/nfc/binary_sensor/__init__.py +4 -4
  93. esphome/components/opentherm/binary_sensor/__init__.py +4 -4
  94. esphome/components/opentherm/generate.py +6 -6
  95. esphome/components/opentherm/sensor/__init__.py +5 -6
  96. esphome/components/packages/__init__.py +35 -11
  97. esphome/components/pn532/binary_sensor.py +4 -4
  98. esphome/components/rc522/binary_sensor.py +4 -4
  99. esphome/components/resampler/speaker/resampler_speaker.h +2 -0
  100. esphome/components/socket/bsd_sockets_impl.cpp +1 -0
  101. esphome/components/socket/lwip_sockets_impl.cpp +1 -0
  102. esphome/components/socket/socket.h +3 -1
  103. esphome/components/speaker/speaker.h +2 -2
  104. esphome/components/ssd1306_base/__init__.py +7 -7
  105. esphome/components/thermostat/climate.py +1 -1
  106. esphome/components/tmp1075/tmp1075.cpp +7 -11
  107. esphome/components/tmp1075/tmp1075.h +1 -2
  108. esphome/components/tormatic/__init__.py +1 -0
  109. esphome/components/tormatic/cover.py +47 -0
  110. esphome/components/tormatic/tormatic_cover.cpp +355 -0
  111. esphome/components/tormatic/tormatic_cover.h +60 -0
  112. esphome/components/tormatic/tormatic_protocol.h +211 -0
  113. esphome/components/touchscreen/binary_sensor/__init__.py +3 -0
  114. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.cpp +7 -1
  115. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.h +3 -1
  116. esphome/components/touchscreen/touchscreen.cpp +3 -4
  117. esphome/components/udp/udp_component.h +4 -1
  118. esphome/components/web_server/list_entities.cpp +70 -66
  119. esphome/components/web_server/list_entities.h +43 -22
  120. esphome/components/web_server/web_server.cpp +345 -68
  121. esphome/components/web_server/web_server.h +138 -6
  122. esphome/components/web_server_base/__init__.py +1 -1
  123. esphome/components/web_server_idf/__init__.py +2 -0
  124. esphome/components/web_server_idf/web_server_idf.cpp +177 -30
  125. esphome/components/web_server_idf/web_server_idf.h +53 -4
  126. esphome/config_validation.py +23 -125
  127. esphome/const.py +5 -1
  128. esphome/core/config.py +15 -6
  129. esphome/core/defines.h +1 -1
  130. esphome/core/helpers.h +24 -3
  131. esphome/core/time.cpp +1 -0
  132. esphome/cpp_generator.py +3 -3
  133. esphome/dashboard/core.py +30 -21
  134. esphome/dashboard/dns.py +7 -1
  135. esphome/dashboard/entries.py +83 -16
  136. esphome/dashboard/settings.py +0 -4
  137. esphome/dashboard/status/mdns.py +43 -14
  138. esphome/dashboard/status/mqtt.py +22 -9
  139. esphome/dashboard/status/ping.py +54 -10
  140. esphome/dashboard/web_server.py +56 -24
  141. esphome/storage_json.py +4 -0
  142. esphome/wizard.py +13 -17
  143. esphome/writer.py +1 -3
  144. esphome/yaml_util.py +36 -33
  145. esphome/zeroconf.py +9 -21
  146. {esphome-2025.2.1.dist-info → esphome-2025.3.0.dist-info}/METADATA +7 -7
  147. {esphome-2025.2.1.dist-info → esphome-2025.3.0.dist-info}/RECORD +151 -111
  148. esphome/components/cst816/binary_sensor/cst816_button.h +0 -27
  149. {esphome-2025.2.1.dist-info → esphome-2025.3.0.dist-info}/LICENSE +0 -0
  150. {esphome-2025.2.1.dist-info → esphome-2025.3.0.dist-info}/WHEEL +0 -0
  151. {esphome-2025.2.1.dist-info → esphome-2025.3.0.dist-info}/entry_points.txt +0 -0
  152. {esphome-2025.2.1.dist-info → esphome-2025.3.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,211 @@
1
+ #pragma once
2
+
3
+ #include "esphome/components/cover/cover.h"
4
+
5
+ /**
6
+ * This file implements the UART protocol spoken over the on-board Micro-USB
7
+ * (Type B) connector of Tormatic and Novoferm gates manufactured as of 2016.
8
+ * All communication is initiated by the component. The unit doesn't send data
9
+ * without being asked first.
10
+ *
11
+ * There are two main message types: status requests and commands.
12
+ *
13
+ * Querying the gate's status:
14
+ *
15
+ * | sequence | length | type | payload |
16
+ * | 0xF3 0xCB | 0x00 0x00 0x00 0x06 | 0x01 0x04 | 0x00 0x0A 0x00 0x01 |
17
+ * | 0xF3 0xCB | 0x00 0x00 0x00 0x05 | 0x01 0x04 | 0x02 0x03 0x00 |
18
+ *
19
+ * This request asks for the gate status (0x0A); the only other value observed
20
+ * in the request was 0x0B, but replies were always zero. Presumably this
21
+ * queries another sensor on the unit like a safety breaker, but this is not
22
+ * relevant for an esphome cover component.
23
+ *
24
+ * The second byte of the reply is set to 0x03 when the gate is in fully open
25
+ * position. Other valid values for the second byte are: (0x0) Paused, (0x1)
26
+ * Closed, (0x2) Ventilating, (0x3) Opened, (0x4) Opening, (0x5) Closing. The
27
+ * meaning of the other bytes is currently unknown and ignored by the component.
28
+ *
29
+ * Controlling the gate:
30
+ *
31
+ * | sequence | length | type | payload |
32
+ * | 0x40 0xFF | 0x00 0x00 0x00 0x06 | 0x01 0x06 | 0x00 0x0A 0x00 0x03 |
33
+ * | 0x40 0xFF | 0x00 0x00 0x00 0x06 | 0x01 0x06 | 0x00 0x0A 0x00 0x03 |
34
+ *
35
+ * The unit acks any commands by echoing back the message in full. However,
36
+ * this does _not_ mean the gate has started closing. The component only
37
+ * considers status replies as authoritative and simply fires off commands,
38
+ * ignoring the echoed messages.
39
+ *
40
+ * The payload structure is as follows: [0x00, 0x0A] (gate), followed by
41
+ * one of the states normally carried in status replies: (0x0) Pause, (0x1)
42
+ * Close, (0x2) Ventilate (open ~20%), (0x3) Open/high-torque reverse. The
43
+ * protocol implementation in this file simply reuses the GateStatus enum
44
+ * for this purpose.
45
+ */
46
+
47
+ namespace esphome {
48
+ namespace tormatic {
49
+
50
+ using namespace esphome::cover;
51
+
52
+ // MessageType is the type of message that follows the MessageHeader.
53
+ enum MessageType : uint16_t {
54
+ STATUS = 0x0104,
55
+ COMMAND = 0x0106,
56
+ };
57
+
58
+ inline const char *message_type_to_str(MessageType t) {
59
+ switch (t) {
60
+ case STATUS:
61
+ return "Status";
62
+ case COMMAND:
63
+ return "Command";
64
+ default:
65
+ return "Unknown";
66
+ }
67
+ }
68
+
69
+ // MessageHeader appears at the start of every message, both requests and replies.
70
+ struct MessageHeader {
71
+ uint16_t seq;
72
+ uint32_t len;
73
+ MessageType type;
74
+
75
+ MessageHeader() = default;
76
+ MessageHeader(MessageType type, uint16_t seq, uint32_t payload_size) {
77
+ this->type = type;
78
+ this->seq = seq;
79
+ // len includes the length of the type field. It was
80
+ // included in MessageHeader to avoid having to parse
81
+ // it as part of the payload.
82
+ this->len = payload_size + sizeof(this->type);
83
+ }
84
+
85
+ std::string print() {
86
+ return str_sprintf("MessageHeader: seq %d, len %d, type %s", this->seq, this->len, message_type_to_str(this->type));
87
+ }
88
+
89
+ void byteswap() {
90
+ this->len = convert_big_endian(this->len);
91
+ this->seq = convert_big_endian(this->seq);
92
+ this->type = convert_big_endian(this->type);
93
+ }
94
+
95
+ // payload_size returns the amount of payload bytes to be read from the uart
96
+ // buffer after reading the header.
97
+ uint32_t payload_size() { return this->len - sizeof(this->type); }
98
+ } __attribute__((packed));
99
+
100
+ // StatusType denotes which 'page' of information needs to be retrieved.
101
+ // On my Novoferm 423, only the GATE status type returns values, Unknown
102
+ // only contains zeroes.
103
+ enum StatusType : uint16_t {
104
+ GATE = 0x0A,
105
+ UNKNOWN = 0x0B,
106
+ };
107
+
108
+ // GateStatus defines the current state of the gate, received in a StatusReply
109
+ // and sent in a Command.
110
+ enum GateStatus : uint8_t {
111
+ PAUSED,
112
+ CLOSED,
113
+ VENTILATING,
114
+ OPENED,
115
+ OPENING,
116
+ CLOSING,
117
+ };
118
+
119
+ inline CoverOperation gate_status_to_cover_operation(GateStatus s) {
120
+ switch (s) {
121
+ case OPENING:
122
+ return COVER_OPERATION_OPENING;
123
+ case CLOSING:
124
+ return COVER_OPERATION_CLOSING;
125
+ case OPENED:
126
+ case CLOSED:
127
+ case PAUSED:
128
+ case VENTILATING:
129
+ return COVER_OPERATION_IDLE;
130
+ }
131
+ return COVER_OPERATION_IDLE;
132
+ }
133
+
134
+ inline const char *gate_status_to_str(GateStatus s) {
135
+ switch (s) {
136
+ case PAUSED:
137
+ return "Paused";
138
+ case CLOSED:
139
+ return "Closed";
140
+ case VENTILATING:
141
+ return "Ventilating";
142
+ case OPENED:
143
+ return "Opened";
144
+ case OPENING:
145
+ return "Opening";
146
+ case CLOSING:
147
+ return "Closing";
148
+ default:
149
+ return "Unknown";
150
+ }
151
+ }
152
+
153
+ // A StatusRequest is sent to request the gate's current status.
154
+ struct StatusRequest {
155
+ StatusType type;
156
+ uint16_t trailer = 0x1;
157
+
158
+ StatusRequest() = default;
159
+ StatusRequest(StatusType type) { this->type = type; }
160
+
161
+ void byteswap() {
162
+ this->type = convert_big_endian(this->type);
163
+ this->trailer = convert_big_endian(this->trailer);
164
+ }
165
+ } __attribute__((packed));
166
+
167
+ // StatusReply is received from the unit in response to a StatusRequest.
168
+ struct StatusReply {
169
+ uint8_t ack = 0x2;
170
+ GateStatus state;
171
+ uint8_t trailer = 0x0;
172
+
173
+ std::string print() { return str_sprintf("StatusReply: state %s", gate_status_to_str(this->state)); }
174
+
175
+ void byteswap(){};
176
+ } __attribute__((packed));
177
+
178
+ // Serialize the given object to a new byte vector.
179
+ // Invokes the object's byteswap() method.
180
+ template<typename T> std::vector<uint8_t> serialize(T obj) {
181
+ obj.byteswap();
182
+
183
+ std::vector<uint8_t> out(sizeof(T));
184
+ memcpy(out.data(), &obj, sizeof(T));
185
+
186
+ return out;
187
+ }
188
+
189
+ // Command tells the gate to start or stop moving.
190
+ // It is echoed back by the unit on success.
191
+ struct CommandRequestReply {
192
+ // The part of the unit to control. For now only the gate is supported.
193
+ StatusType type = GATE;
194
+ uint8_t pad = 0x0;
195
+ // The desired state:
196
+ // PAUSED = stop
197
+ // VENTILATING = move to ~20% open
198
+ // CLOSED = close
199
+ // OPENED = open/high-torque reverse when closing
200
+ GateStatus state;
201
+
202
+ CommandRequestReply() = default;
203
+ CommandRequestReply(GateStatus state) { this->state = state; }
204
+
205
+ std::string print() { return str_sprintf("CommandRequestReply: state %s", gate_status_to_str(this->state)); }
206
+
207
+ void byteswap() { this->type = convert_big_endian(this->type); }
208
+ } __attribute__((packed));
209
+
210
+ } // namespace tormatic
211
+ } // namespace esphome
@@ -19,6 +19,7 @@ CONF_X_MIN = "x_min"
19
19
  CONF_X_MAX = "x_max"
20
20
  CONF_Y_MIN = "y_min"
21
21
  CONF_Y_MAX = "y_max"
22
+ CONF_USE_RAW = "use_raw"
22
23
 
23
24
 
24
25
  def _validate_coords(config):
@@ -46,6 +47,7 @@ CONFIG_SCHEMA = cv.All(
46
47
  .extend(
47
48
  {
48
49
  cv.GenerateID(CONF_TOUCHSCREEN_ID): cv.use_id(Touchscreen),
50
+ cv.Optional(CONF_USE_RAW, default=False): cv.boolean,
49
51
  cv.Required(CONF_X_MIN): cv.int_range(min=0, max=2000),
50
52
  cv.Required(CONF_X_MAX): cv.int_range(min=0, max=2000),
51
53
  cv.Required(CONF_Y_MIN): cv.int_range(min=0, max=2000),
@@ -69,6 +71,7 @@ async def to_code(config):
69
71
  await cg.register_component(var, config)
70
72
  await cg.register_parented(var, config[CONF_TOUCHSCREEN_ID])
71
73
 
74
+ cg.add(var.set_use_raw(config[CONF_USE_RAW]))
72
75
  cg.add(
73
76
  var.set_area(
74
77
  config[CONF_X_MIN],
@@ -9,7 +9,13 @@ void TouchscreenBinarySensor::setup() {
9
9
  }
10
10
 
11
11
  void TouchscreenBinarySensor::touch(TouchPoint tp) {
12
- bool touched = (tp.x >= this->x_min_ && tp.x <= this->x_max_ && tp.y >= this->y_min_ && tp.y <= this->y_max_);
12
+ bool touched;
13
+ if (this->use_raw_) {
14
+ touched =
15
+ (tp.x_raw >= this->x_min_ && tp.x_raw <= this->x_max_ && tp.y_raw >= this->y_min_ && tp.y_raw <= this->y_max_);
16
+ } else {
17
+ touched = (tp.x >= this->x_min_ && tp.x <= this->x_max_ && tp.y >= this->y_min_ && tp.y <= this->y_max_);
18
+ }
13
19
 
14
20
  if (!this->pages_.empty()) {
15
21
  auto *current_page = this->parent_->get_display()->get_active_page();
@@ -25,6 +25,7 @@ class TouchscreenBinarySensor : public binary_sensor::BinarySensor,
25
25
  this->y_min_ = y_min;
26
26
  this->y_max_ = y_max;
27
27
  }
28
+ void set_use_raw(bool use_raw) { this->use_raw_ = use_raw; }
28
29
  int16_t get_x_min() { return this->x_min_; }
29
30
  int16_t get_x_max() { return this->x_max_; }
30
31
  int16_t get_y_min() { return this->y_min_; }
@@ -38,7 +39,8 @@ class TouchscreenBinarySensor : public binary_sensor::BinarySensor,
38
39
  void release() override;
39
40
 
40
41
  protected:
41
- int16_t x_min_, x_max_, y_min_, y_max_;
42
+ int16_t x_min_{}, x_max_{}, y_min_{}, y_max_{};
43
+ bool use_raw_{};
42
44
  std::vector<display::DisplayPage *> pages_{};
43
45
  };
44
46
 
@@ -74,6 +74,9 @@ void Touchscreen::loop() {
74
74
  void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_raw, int16_t z_raw) {
75
75
  TouchPoint tp;
76
76
  uint16_t x, y;
77
+ if (this->swap_x_y_) {
78
+ std::swap(x_raw, y_raw);
79
+ }
77
80
  if (this->touches_.count(id) == 0) {
78
81
  tp.state = STATE_PRESSED;
79
82
  tp.id = id;
@@ -90,10 +93,6 @@ void Touchscreen::add_raw_touch_position_(uint8_t id, int16_t x_raw, int16_t y_r
90
93
  x = this->normalize_(x_raw, this->x_raw_min_, this->x_raw_max_, this->invert_x_);
91
94
  y = this->normalize_(y_raw, this->y_raw_min_, this->y_raw_max_, this->invert_y_);
92
95
 
93
- if (this->swap_x_y_) {
94
- std::swap(x, y);
95
- }
96
-
97
96
  tp.x = (uint16_t) ((int) x * this->display_width_ / 0x1000);
98
97
  tp.y = (uint16_t) ((int) y * this->display_height_ / 0x1000);
99
98
  } else {
@@ -70,7 +70,9 @@ class UDPComponent : public PollingComponent {
70
70
  }
71
71
  #endif
72
72
  void add_address(const char *addr) { this->addresses_.emplace_back(addr); }
73
+ #ifdef USE_NETWORK
73
74
  void set_listen_address(const char *listen_addr) { this->listen_address_ = network::IPAddress(listen_addr); }
75
+ #endif
74
76
  void set_port(uint16_t port) { this->port_ = port; }
75
77
  float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
76
78
 
@@ -144,8 +146,9 @@ class UDPComponent : public PollingComponent {
144
146
  std::vector<BinarySensor> binary_sensors_{};
145
147
  std::map<std::string, std::map<std::string, binary_sensor::BinarySensor *>> remote_binary_sensors_{};
146
148
  #endif
147
-
149
+ #ifdef USE_NETWORK
148
150
  optional<network::IPAddress> listen_address_{};
151
+ #endif
149
152
  std::map<std::string, Provider> providers_{};
150
153
  std::vector<uint8_t> ping_header_{};
151
154
  std::vector<uint8_t> header_{};
@@ -9,180 +9,184 @@
9
9
  namespace esphome {
10
10
  namespace web_server {
11
11
 
12
- ListEntitiesIterator::ListEntitiesIterator(WebServer *web_server) : web_server_(web_server) {}
12
+ #ifdef USE_ARDUINO
13
+ ListEntitiesIterator::ListEntitiesIterator(const WebServer *ws, DeferredUpdateEventSource *es)
14
+ : web_server_(ws), events_(es) {}
15
+ #endif
16
+ #ifdef USE_ESP_IDF
17
+ ListEntitiesIterator::ListEntitiesIterator(const WebServer *ws, AsyncEventSource *es) : web_server_(ws), events_(es) {}
18
+ #endif
19
+ ListEntitiesIterator::~ListEntitiesIterator() {}
13
20
 
14
21
  #ifdef USE_BINARY_SENSOR
15
- bool ListEntitiesIterator::on_binary_sensor(binary_sensor::BinarySensor *binary_sensor) {
16
- if (this->web_server_->events_.count() == 0)
22
+ bool ListEntitiesIterator::on_binary_sensor(binary_sensor::BinarySensor *obj) {
23
+ if (this->events_->count() == 0)
17
24
  return true;
18
- this->web_server_->events_.send(
19
- this->web_server_->binary_sensor_json(binary_sensor, binary_sensor->state, DETAIL_ALL).c_str(), "state");
25
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::binary_sensor_all_json_generator);
20
26
  return true;
21
27
  }
22
28
  #endif
23
29
  #ifdef USE_COVER
24
- bool ListEntitiesIterator::on_cover(cover::Cover *cover) {
25
- if (this->web_server_->events_.count() == 0)
30
+ bool ListEntitiesIterator::on_cover(cover::Cover *obj) {
31
+ if (this->events_->count() == 0)
26
32
  return true;
27
- this->web_server_->events_.send(this->web_server_->cover_json(cover, DETAIL_ALL).c_str(), "state");
33
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::cover_all_json_generator);
28
34
  return true;
29
35
  }
30
36
  #endif
31
37
  #ifdef USE_FAN
32
- bool ListEntitiesIterator::on_fan(fan::Fan *fan) {
33
- if (this->web_server_->events_.count() == 0)
38
+ bool ListEntitiesIterator::on_fan(fan::Fan *obj) {
39
+ if (this->events_->count() == 0)
34
40
  return true;
35
- this->web_server_->events_.send(this->web_server_->fan_json(fan, DETAIL_ALL).c_str(), "state");
41
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::fan_all_json_generator);
36
42
  return true;
37
43
  }
38
44
  #endif
39
45
  #ifdef USE_LIGHT
40
- bool ListEntitiesIterator::on_light(light::LightState *light) {
41
- if (this->web_server_->events_.count() == 0)
46
+ bool ListEntitiesIterator::on_light(light::LightState *obj) {
47
+ if (this->events_->count() == 0)
42
48
  return true;
43
- this->web_server_->events_.send(this->web_server_->light_json(light, DETAIL_ALL).c_str(), "state");
49
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::light_all_json_generator);
44
50
  return true;
45
51
  }
46
52
  #endif
47
53
  #ifdef USE_SENSOR
48
- bool ListEntitiesIterator::on_sensor(sensor::Sensor *sensor) {
49
- if (this->web_server_->events_.count() == 0)
54
+ bool ListEntitiesIterator::on_sensor(sensor::Sensor *obj) {
55
+ if (this->events_->count() == 0)
50
56
  return true;
51
- this->web_server_->events_.send(this->web_server_->sensor_json(sensor, sensor->state, DETAIL_ALL).c_str(), "state");
57
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::sensor_all_json_generator);
52
58
  return true;
53
59
  }
54
60
  #endif
55
61
  #ifdef USE_SWITCH
56
- bool ListEntitiesIterator::on_switch(switch_::Switch *a_switch) {
57
- if (this->web_server_->events_.count() == 0)
62
+ bool ListEntitiesIterator::on_switch(switch_::Switch *obj) {
63
+ if (this->events_->count() == 0)
58
64
  return true;
59
- this->web_server_->events_.send(this->web_server_->switch_json(a_switch, a_switch->state, DETAIL_ALL).c_str(),
60
- "state");
65
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::switch_all_json_generator);
61
66
  return true;
62
67
  }
63
68
  #endif
64
69
  #ifdef USE_BUTTON
65
- bool ListEntitiesIterator::on_button(button::Button *button) {
66
- if (this->web_server_->events_.count() == 0)
70
+ bool ListEntitiesIterator::on_button(button::Button *obj) {
71
+ if (this->events_->count() == 0)
67
72
  return true;
68
- this->web_server_->events_.send(this->web_server_->button_json(button, DETAIL_ALL).c_str(), "state");
73
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::button_all_json_generator);
69
74
  return true;
70
75
  }
71
76
  #endif
72
77
  #ifdef USE_TEXT_SENSOR
73
- bool ListEntitiesIterator::on_text_sensor(text_sensor::TextSensor *text_sensor) {
74
- if (this->web_server_->events_.count() == 0)
78
+ bool ListEntitiesIterator::on_text_sensor(text_sensor::TextSensor *obj) {
79
+ if (this->events_->count() == 0)
75
80
  return true;
76
- this->web_server_->events_.send(
77
- this->web_server_->text_sensor_json(text_sensor, text_sensor->state, DETAIL_ALL).c_str(), "state");
81
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::text_sensor_all_json_generator);
78
82
  return true;
79
83
  }
80
84
  #endif
81
85
  #ifdef USE_LOCK
82
- bool ListEntitiesIterator::on_lock(lock::Lock *a_lock) {
83
- if (this->web_server_->events_.count() == 0)
86
+ bool ListEntitiesIterator::on_lock(lock::Lock *obj) {
87
+ if (this->events_->count() == 0)
84
88
  return true;
85
- this->web_server_->events_.send(this->web_server_->lock_json(a_lock, a_lock->state, DETAIL_ALL).c_str(), "state");
89
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::lock_all_json_generator);
86
90
  return true;
87
91
  }
88
92
  #endif
89
93
 
90
94
  #ifdef USE_VALVE
91
- bool ListEntitiesIterator::on_valve(valve::Valve *valve) {
92
- if (this->web_server_->events_.count() == 0)
95
+ bool ListEntitiesIterator::on_valve(valve::Valve *obj) {
96
+ if (this->events_->count() == 0)
93
97
  return true;
94
- this->web_server_->events_.send(this->web_server_->valve_json(valve, DETAIL_ALL).c_str(), "state");
98
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::valve_all_json_generator);
95
99
  return true;
96
100
  }
97
101
  #endif
98
102
 
99
103
  #ifdef USE_CLIMATE
100
- bool ListEntitiesIterator::on_climate(climate::Climate *climate) {
101
- if (this->web_server_->events_.count() == 0)
104
+ bool ListEntitiesIterator::on_climate(climate::Climate *obj) {
105
+ if (this->events_->count() == 0)
102
106
  return true;
103
- this->web_server_->events_.send(this->web_server_->climate_json(climate, DETAIL_ALL).c_str(), "state");
107
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::climate_all_json_generator);
104
108
  return true;
105
109
  }
106
110
  #endif
107
111
 
108
112
  #ifdef USE_NUMBER
109
- bool ListEntitiesIterator::on_number(number::Number *number) {
110
- if (this->web_server_->events_.count() == 0)
113
+ bool ListEntitiesIterator::on_number(number::Number *obj) {
114
+ if (this->events_->count() == 0)
111
115
  return true;
112
- this->web_server_->events_.send(this->web_server_->number_json(number, number->state, DETAIL_ALL).c_str(), "state");
116
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::number_all_json_generator);
113
117
  return true;
114
118
  }
115
119
  #endif
116
120
 
117
121
  #ifdef USE_DATETIME_DATE
118
- bool ListEntitiesIterator::on_date(datetime::DateEntity *date) {
119
- if (this->web_server_->events_.count() == 0)
122
+ bool ListEntitiesIterator::on_date(datetime::DateEntity *obj) {
123
+ if (this->events_->count() == 0)
120
124
  return true;
121
- this->web_server_->events_.send(this->web_server_->date_json(date, DETAIL_ALL).c_str(), "state");
125
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::date_all_json_generator);
122
126
  return true;
123
127
  }
124
128
  #endif
125
129
 
126
130
  #ifdef USE_DATETIME_TIME
127
- bool ListEntitiesIterator::on_time(datetime::TimeEntity *time) {
128
- this->web_server_->events_.send(this->web_server_->time_json(time, DETAIL_ALL).c_str(), "state");
131
+ bool ListEntitiesIterator::on_time(datetime::TimeEntity *obj) {
132
+ if (this->events_->count() == 0)
133
+ return true;
134
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::time_all_json_generator);
129
135
  return true;
130
136
  }
131
137
  #endif
132
138
 
133
139
  #ifdef USE_DATETIME_DATETIME
134
- bool ListEntitiesIterator::on_datetime(datetime::DateTimeEntity *datetime) {
135
- if (this->web_server_->events_.count() == 0)
140
+ bool ListEntitiesIterator::on_datetime(datetime::DateTimeEntity *obj) {
141
+ if (this->events_->count() == 0)
136
142
  return true;
137
- this->web_server_->events_.send(this->web_server_->datetime_json(datetime, DETAIL_ALL).c_str(), "state");
143
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::datetime_all_json_generator);
138
144
  return true;
139
145
  }
140
146
  #endif
141
147
 
142
148
  #ifdef USE_TEXT
143
- bool ListEntitiesIterator::on_text(text::Text *text) {
144
- if (this->web_server_->events_.count() == 0)
149
+ bool ListEntitiesIterator::on_text(text::Text *obj) {
150
+ if (this->events_->count() == 0)
145
151
  return true;
146
- this->web_server_->events_.send(this->web_server_->text_json(text, text->state, DETAIL_ALL).c_str(), "state");
152
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::text_all_json_generator);
147
153
  return true;
148
154
  }
149
155
  #endif
150
156
 
151
157
  #ifdef USE_SELECT
152
- bool ListEntitiesIterator::on_select(select::Select *select) {
153
- if (this->web_server_->events_.count() == 0)
158
+ bool ListEntitiesIterator::on_select(select::Select *obj) {
159
+ if (this->events_->count() == 0)
154
160
  return true;
155
- this->web_server_->events_.send(this->web_server_->select_json(select, select->state, DETAIL_ALL).c_str(), "state");
161
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::select_all_json_generator);
156
162
  return true;
157
163
  }
158
164
  #endif
159
165
 
160
166
  #ifdef USE_ALARM_CONTROL_PANEL
161
- bool ListEntitiesIterator::on_alarm_control_panel(alarm_control_panel::AlarmControlPanel *a_alarm_control_panel) {
162
- if (this->web_server_->events_.count() == 0)
167
+ bool ListEntitiesIterator::on_alarm_control_panel(alarm_control_panel::AlarmControlPanel *obj) {
168
+ if (this->events_->count() == 0)
163
169
  return true;
164
- this->web_server_->events_.send(
165
- this->web_server_->alarm_control_panel_json(a_alarm_control_panel, a_alarm_control_panel->get_state(), DETAIL_ALL)
166
- .c_str(),
167
- "state");
170
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::alarm_control_panel_all_json_generator);
168
171
  return true;
169
172
  }
170
173
  #endif
171
174
 
172
175
  #ifdef USE_EVENT
173
- bool ListEntitiesIterator::on_event(event::Event *event) {
176
+ bool ListEntitiesIterator::on_event(event::Event *obj) {
177
+ if (this->events_->count() == 0)
178
+ return true;
174
179
  // Null event type, since we are just iterating over entities
175
- const std::string null_event_type = "";
176
- this->web_server_->events_.send(this->web_server_->event_json(event, null_event_type, DETAIL_ALL).c_str(), "state");
180
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::event_all_json_generator);
177
181
  return true;
178
182
  }
179
183
  #endif
180
184
 
181
185
  #ifdef USE_UPDATE
182
- bool ListEntitiesIterator::on_update(update::UpdateEntity *update) {
183
- if (this->web_server_->events_.count() == 0)
186
+ bool ListEntitiesIterator::on_update(update::UpdateEntity *obj) {
187
+ if (this->events_->count() == 0)
184
188
  return true;
185
- this->web_server_->events_.send(this->web_server_->update_json(update, DETAIL_ALL).c_str(), "state");
189
+ this->events_->deferrable_send_state(obj, "state_detail_all", WebServer::update_all_json_generator);
186
190
  return true;
187
191
  }
188
192
  #endif