esphome 2024.8.2__py3-none-any.whl → 2024.9.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 (204) hide show
  1. esphome/__main__.py +6 -2
  2. esphome/components/api/api_connection.cpp +53 -0
  3. esphome/components/api/api_connection.h +4 -0
  4. esphome/components/api/api_pb2.cpp +280 -0
  5. esphome/components/api/api_pb2.h +91 -0
  6. esphome/components/api/api_pb2_service.cpp +85 -0
  7. esphome/components/api/api_pb2_service.h +28 -0
  8. esphome/components/async_tcp/__init__.py +3 -3
  9. esphome/components/atm90e26/sensor.py +10 -10
  10. esphome/components/atm90e32/sensor.py +1 -1
  11. esphome/components/bl0906/__init__.py +1 -0
  12. esphome/components/bl0906/bl0906.cpp +238 -0
  13. esphome/components/bl0906/bl0906.h +96 -0
  14. esphome/components/bl0906/const.py +4 -0
  15. esphome/components/bl0906/constants.h +122 -0
  16. esphome/components/bl0906/sensor.py +184 -0
  17. esphome/components/bl0942/__init__.py +1 -1
  18. esphome/components/bl0942/bl0942.cpp +127 -34
  19. esphome/components/bl0942/bl0942.h +87 -3
  20. esphome/components/bl0942/sensor.py +46 -8
  21. esphome/components/ble_client/__init__.py +1 -3
  22. esphome/components/ble_presence/binary_sensor.py +2 -2
  23. esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
  24. esphome/components/bmp280/sensor.py +2 -93
  25. esphome/components/bmp280_base/__init__.py +88 -0
  26. esphome/components/{bmp280/bmp280.cpp → bmp280_base/bmp280_base.cpp} +11 -4
  27. esphome/components/{bmp280/bmp280.h → bmp280_base/bmp280_base.h} +9 -5
  28. esphome/components/bmp280_i2c/__init__.py +0 -0
  29. esphome/components/bmp280_i2c/bmp280_i2c.cpp +27 -0
  30. esphome/components/bmp280_i2c/bmp280_i2c.h +22 -0
  31. esphome/components/bmp280_i2c/sensor.py +22 -0
  32. esphome/components/bmp280_spi/__init__.py +0 -0
  33. esphome/components/bmp280_spi/bmp280_spi.cpp +65 -0
  34. esphome/components/bmp280_spi/bmp280_spi.h +20 -0
  35. esphome/components/bmp280_spi/sensor.py +22 -0
  36. esphome/components/captive_portal/captive_portal.cpp +2 -0
  37. esphome/components/captive_portal/captive_portal.h +3 -1
  38. esphome/components/ch422g/__init__.py +67 -0
  39. esphome/components/ch422g/ch422g.cpp +122 -0
  40. esphome/components/ch422g/ch422g.h +70 -0
  41. esphome/components/debug/debug_esp32.cpp +3 -1
  42. esphome/components/display/__init__.py +5 -4
  43. esphome/components/dsmr/dsmr.cpp +6 -0
  44. esphome/components/dsmr/dsmr.h +6 -0
  45. esphome/components/dsmr/text_sensor.py +7 -2
  46. esphome/components/e131/e131.cpp +2 -0
  47. esphome/components/e131/e131.h +3 -1
  48. esphome/components/e131/e131_addressable_light_effect.cpp +2 -0
  49. esphome/components/e131/e131_addressable_light_effect.h +2 -1
  50. esphome/components/e131/e131_packet.cpp +2 -0
  51. esphome/components/esp32_ble/ble_uuid.cpp +7 -0
  52. esphome/components/esp32_ble/ble_uuid.h +1 -0
  53. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +11 -9
  54. esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +3 -3
  55. esphome/components/esp32_camera/__init__.py +4 -0
  56. esphome/components/esp32_camera/esp32_camera.cpp +9 -1
  57. esphome/components/esp32_camera/esp32_camera.h +3 -0
  58. esphome/components/esp32_can/canbus.py +18 -7
  59. esphome/components/esp32_can/esp32_can.cpp +8 -0
  60. esphome/components/esp32_can/esp32_can.h +4 -0
  61. esphome/components/esp32_rmt_led_strip/led_strip.cpp +14 -2
  62. esphome/components/esp32_rmt_led_strip/led_strip.h +3 -2
  63. esphome/components/esp32_rmt_led_strip/light.py +21 -4
  64. esphome/components/esphome/ota/ota_esphome.cpp +2 -1
  65. esphome/components/esphome/ota/ota_esphome.h +2 -0
  66. esphome/components/font/__init__.py +11 -22
  67. esphome/components/font/font.cpp +3 -2
  68. esphome/components/font/font.h +12 -3
  69. esphome/components/gree/climate.py +2 -1
  70. esphome/components/gree/gree.cpp +54 -3
  71. esphome/components/gree/gree.h +10 -2
  72. esphome/components/gt911/touchscreen/__init__.py +6 -4
  73. esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +17 -0
  74. esphome/components/gt911/touchscreen/gt911_touchscreen.h +2 -0
  75. esphome/components/hmac_md5/__init__.py +2 -0
  76. esphome/components/hmac_md5/hmac_md5.cpp +56 -0
  77. esphome/components/hmac_md5/hmac_md5.h +48 -0
  78. esphome/components/homeassistant/__init__.py +13 -0
  79. esphome/components/homeassistant/switch/__init__.py +15 -2
  80. esphome/components/homeassistant/switch/homeassistant_switch.cpp +2 -2
  81. esphome/components/i2s_audio/__init__.py +88 -9
  82. esphome/components/i2s_audio/i2s_audio.h +20 -2
  83. esphome/components/i2s_audio/media_player/__init__.py +8 -4
  84. esphome/components/i2s_audio/media_player/i2s_audio_media_player.h +1 -1
  85. esphome/components/i2s_audio/microphone/__init__.py +19 -51
  86. esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +18 -15
  87. esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +0 -12
  88. esphome/components/i2s_audio/speaker/__init__.py +39 -27
  89. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +49 -37
  90. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +3 -4
  91. esphome/components/ili9xxx/display.py +16 -17
  92. esphome/components/ili9xxx/ili9xxx_display.cpp +1 -1
  93. esphome/components/ili9xxx/ili9xxx_display.h +18 -18
  94. esphome/components/ili9xxx/ili9xxx_init.h +0 -3
  95. esphome/components/improv_serial/improv_serial_component.cpp +2 -1
  96. esphome/components/improv_serial/improv_serial_component.h +2 -1
  97. esphome/components/ledc/ledc_output.cpp +11 -7
  98. esphome/components/libretiny/__init__.py +8 -13
  99. esphome/components/ltr501/__init__.py +1 -0
  100. esphome/components/ltr501/ltr501.cpp +542 -0
  101. esphome/components/ltr501/ltr501.h +184 -0
  102. esphome/components/ltr501/ltr_definitions_501.h +260 -0
  103. esphome/components/ltr501/sensor.py +274 -0
  104. esphome/components/ltr_als_ps/sensor.py +2 -2
  105. esphome/components/lvgl/__init__.py +19 -16
  106. esphome/components/lvgl/automation.py +90 -9
  107. esphome/components/lvgl/defines.py +29 -2
  108. esphome/components/lvgl/gradient.py +61 -0
  109. esphome/components/lvgl/lv_validation.py +45 -27
  110. esphome/components/lvgl/lvcode.py +8 -3
  111. esphome/components/lvgl/lvgl_esphome.cpp +54 -0
  112. esphome/components/lvgl/lvgl_esphome.h +9 -3
  113. esphome/components/lvgl/number/__init__.py +1 -0
  114. esphome/components/lvgl/number/lvgl_number.h +3 -1
  115. esphome/components/lvgl/schemas.py +16 -11
  116. esphome/components/lvgl/select/__init__.py +1 -0
  117. esphome/components/lvgl/select/lvgl_select.h +3 -1
  118. esphome/components/lvgl/switch/__init__.py +2 -1
  119. esphome/components/lvgl/switch/lvgl_switch.h +3 -1
  120. esphome/components/lvgl/text/__init__.py +1 -0
  121. esphome/components/lvgl/text/lvgl_text.h +3 -1
  122. esphome/components/lvgl/trigger.py +3 -2
  123. esphome/components/lvgl/types.py +2 -1
  124. esphome/components/lvgl/widgets/__init__.py +23 -8
  125. esphome/components/lvgl/widgets/arc.py +5 -1
  126. esphome/components/lvgl/widgets/buttonmatrix.py +5 -1
  127. esphome/components/lvgl/widgets/checkbox.py +8 -3
  128. esphome/components/lvgl/widgets/meter.py +8 -1
  129. esphome/components/lvgl/widgets/msgbox.py +26 -15
  130. esphome/components/lvgl/widgets/page.py +51 -7
  131. esphome/components/lvgl/widgets/tileview.py +2 -8
  132. esphome/components/max31856/max31856.cpp +12 -1
  133. esphome/components/max31856/max31856.h +5 -2
  134. esphome/components/max31856/sensor.py +20 -0
  135. esphome/components/mcp9600/sensor.py +2 -2
  136. esphome/components/mdns/__init__.py +6 -6
  137. esphome/components/media_player/media_player.h +16 -0
  138. esphome/components/micro_wake_word/__init__.py +2 -25
  139. esphome/components/microphone/microphone.h +1 -1
  140. esphome/components/mics_4514/mics_4514.cpp +26 -36
  141. esphome/components/modbus_controller/__init__.py +6 -0
  142. esphome/components/modbus_controller/const.py +2 -0
  143. esphome/components/modbus_controller/modbus_controller.cpp +30 -27
  144. esphome/components/modbus_controller/modbus_controller.h +22 -4
  145. esphome/components/network/__init__.py +11 -8
  146. esphome/components/pipsolar/pipsolar.cpp +3 -0
  147. esphome/components/pipsolar/pipsolar.h +1 -0
  148. esphome/components/pipsolar/switch/__init__.py +2 -0
  149. esphome/components/prometheus/prometheus_handler.cpp +2 -0
  150. esphome/components/prometheus/prometheus_handler.h +3 -1
  151. esphome/components/rp2040/__init__.py +7 -8
  152. esphome/components/rpi_dpi_rgb/display.py +20 -17
  153. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +36 -6
  154. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.h +4 -0
  155. esphome/components/socket/socket.cpp +2 -0
  156. esphome/components/socket/socket.h +2 -0
  157. esphome/components/speaker/speaker.h +1 -1
  158. esphome/components/st7701s/display.py +35 -37
  159. esphome/components/st7701s/st7701s.cpp +11 -6
  160. esphome/components/st7701s/st7701s.h +1 -0
  161. esphome/components/statsd/__init__.py +65 -0
  162. esphome/components/statsd/statsd.cpp +156 -0
  163. esphome/components/statsd/statsd.h +86 -0
  164. esphome/components/tuya/__init__.py +1 -0
  165. esphome/components/tuya/number/__init__.py +39 -2
  166. esphome/components/tuya/number/tuya_number.cpp +58 -2
  167. esphome/components/tuya/number/tuya_number.h +12 -3
  168. esphome/components/udp/__init__.py +158 -0
  169. esphome/components/udp/binary_sensor.py +27 -0
  170. esphome/components/udp/sensor.py +27 -0
  171. esphome/components/udp/udp_component.cpp +616 -0
  172. esphome/components/udp/udp_component.h +158 -0
  173. esphome/components/uponor_smatrix/uponor_smatrix.cpp +4 -6
  174. esphome/components/uponor_smatrix/uponor_smatrix.h +0 -1
  175. esphome/components/veml7700/sensor.py +2 -2
  176. esphome/components/voice_assistant/__init__.py +6 -0
  177. esphome/components/voice_assistant/voice_assistant.cpp +24 -2
  178. esphome/components/voice_assistant/voice_assistant.h +20 -0
  179. esphome/components/web_server/__init__.py +11 -11
  180. esphome/components/web_server/list_entities.cpp +2 -0
  181. esphome/components/web_server/list_entities.h +3 -1
  182. esphome/components/web_server/web_server.cpp +2 -1
  183. esphome/components/web_server/web_server.h +2 -0
  184. esphome/components/web_server_base/web_server_base.cpp +2 -0
  185. esphome/components/web_server_base/web_server_base.h +3 -1
  186. esphome/components/wifi/wifi_component_libretiny.cpp +15 -1
  187. esphome/components/wireguard/__init__.py +9 -6
  188. esphome/components/wireguard/wireguard.cpp +2 -1
  189. esphome/components/wireguard/wireguard.h +3 -1
  190. esphome/config_validation.py +8 -0
  191. esphome/const.py +8 -1
  192. esphome/core/bytebuffer.cpp +117 -84
  193. esphome/core/bytebuffer.h +69 -21
  194. esphome/core/config.py +0 -3
  195. esphome/core/defines.h +2 -0
  196. esphome/core/ring_buffer.cpp +13 -2
  197. esphome/core/ring_buffer.h +56 -0
  198. esphome/external_files.py +5 -3
  199. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/METADATA +1 -1
  200. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/RECORD +204 -169
  201. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/LICENSE +0 -0
  202. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/WHEEL +0 -0
  203. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/entry_points.txt +0 -0
  204. {esphome-2024.8.2.dist-info → esphome-2024.9.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,158 @@
1
+ #pragma once
2
+
3
+ #include "esphome/core/component.h"
4
+ #ifdef USE_SENSOR
5
+ #include "esphome/components/sensor/sensor.h"
6
+ #endif
7
+ #ifdef USE_BINARY_SENSOR
8
+ #include "esphome/components/binary_sensor/binary_sensor.h"
9
+ #endif
10
+ #if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
11
+ #include "esphome/components/socket/socket.h"
12
+ #else
13
+ #include <WiFiUdp.h>
14
+ #endif
15
+ #include <vector>
16
+ #include <map>
17
+
18
+ namespace esphome {
19
+ namespace udp {
20
+
21
+ struct Provider {
22
+ std::vector<uint8_t> encryption_key;
23
+ const char *name;
24
+ uint32_t last_code[2];
25
+ };
26
+
27
+ #ifdef USE_SENSOR
28
+ struct Sensor {
29
+ sensor::Sensor *sensor;
30
+ const char *id;
31
+ bool updated;
32
+ };
33
+ #endif
34
+ #ifdef USE_BINARY_SENSOR
35
+ struct BinarySensor {
36
+ binary_sensor::BinarySensor *sensor;
37
+ const char *id;
38
+ bool updated;
39
+ };
40
+ #endif
41
+
42
+ class UDPComponent : public PollingComponent {
43
+ public:
44
+ void setup() override;
45
+ void loop() override;
46
+ void update() override;
47
+ void dump_config() override;
48
+
49
+ #ifdef USE_SENSOR
50
+ void add_sensor(const char *id, sensor::Sensor *sensor) {
51
+ Sensor st{sensor, id, true};
52
+ this->sensors_.push_back(st);
53
+ }
54
+ void add_remote_sensor(const char *hostname, const char *remote_id, sensor::Sensor *sensor) {
55
+ this->add_provider(hostname);
56
+ this->remote_sensors_[hostname][remote_id] = sensor;
57
+ }
58
+ #endif
59
+ #ifdef USE_BINARY_SENSOR
60
+ void add_binary_sensor(const char *id, binary_sensor::BinarySensor *sensor) {
61
+ BinarySensor st{sensor, id, true};
62
+ this->binary_sensors_.push_back(st);
63
+ }
64
+
65
+ void add_remote_binary_sensor(const char *hostname, const char *remote_id, binary_sensor::BinarySensor *sensor) {
66
+ this->add_provider(hostname);
67
+ this->remote_binary_sensors_[hostname][remote_id] = sensor;
68
+ }
69
+ #endif
70
+ void add_address(const char *addr) { this->addresses_.emplace_back(addr); }
71
+ void set_port(uint16_t port) { this->port_ = port; }
72
+ float get_setup_priority() const override { return setup_priority::AFTER_WIFI; }
73
+
74
+ void add_provider(const char *hostname) {
75
+ if (this->providers_.count(hostname) == 0) {
76
+ Provider provider;
77
+ provider.encryption_key = std::vector<uint8_t>{};
78
+ provider.last_code[0] = 0;
79
+ provider.last_code[1] = 0;
80
+ provider.name = hostname;
81
+ this->providers_[hostname] = provider;
82
+ #ifdef USE_SENSOR
83
+ this->remote_sensors_[hostname] = std::map<std::string, sensor::Sensor *>();
84
+ #endif
85
+ #ifdef USE_BINARY_SENSOR
86
+ this->remote_binary_sensors_[hostname] = std::map<std::string, binary_sensor::BinarySensor *>();
87
+ #endif
88
+ }
89
+ }
90
+
91
+ void set_encryption_key(std::vector<uint8_t> key) { this->encryption_key_ = std::move(key); }
92
+ void set_rolling_code_enable(bool enable) { this->rolling_code_enable_ = enable; }
93
+ void set_ping_pong_enable(bool enable) { this->ping_pong_enable_ = enable; }
94
+ void set_ping_pong_recycle_time(uint32_t recycle_time) { this->ping_pong_recyle_time_ = recycle_time; }
95
+ void set_provider_encryption(const char *name, std::vector<uint8_t> key) {
96
+ this->providers_[name].encryption_key = std::move(key);
97
+ }
98
+
99
+ protected:
100
+ void send_data_(bool all);
101
+ void process_(uint8_t *buf, size_t len);
102
+ void flush_();
103
+ void add_data_(uint8_t key, const char *id, float data);
104
+ void add_data_(uint8_t key, const char *id, uint32_t data);
105
+ void increment_code_();
106
+ void add_binary_data_(uint8_t key, const char *id, bool data);
107
+ void init_data_();
108
+
109
+ bool updated_{};
110
+ uint16_t port_{18511};
111
+ uint32_t ping_key_{};
112
+ uint32_t rolling_code_[2]{};
113
+ bool rolling_code_enable_{};
114
+ bool ping_pong_enable_{};
115
+ uint32_t ping_pong_recyle_time_{};
116
+ uint32_t last_key_time_{};
117
+ bool resend_ping_key_{};
118
+ bool resend_data_{};
119
+ bool should_send_{};
120
+ const char *name_{};
121
+ bool should_listen_{};
122
+ ESPPreferenceObject pref_;
123
+
124
+ #if defined(USE_SOCKET_IMPL_BSD_SOCKETS) || defined(USE_SOCKET_IMPL_LWIP_SOCKETS)
125
+ std::unique_ptr<socket::Socket> broadcast_socket_ = nullptr;
126
+ std::unique_ptr<socket::Socket> listen_socket_ = nullptr;
127
+ std::vector<struct sockaddr> sockaddrs_{};
128
+ #else
129
+ std::vector<IPAddress> ipaddrs_{};
130
+ WiFiUDP udp_client_{};
131
+ #endif
132
+ std::vector<uint8_t> encryption_key_{};
133
+ std::vector<std::string> addresses_{};
134
+
135
+ #ifdef USE_SENSOR
136
+ std::vector<Sensor> sensors_{};
137
+ std::map<std::string, std::map<std::string, sensor::Sensor *>> remote_sensors_{};
138
+ #endif
139
+ #ifdef USE_BINARY_SENSOR
140
+ std::vector<BinarySensor> binary_sensors_{};
141
+ std::map<std::string, std::map<std::string, binary_sensor::BinarySensor *>> remote_binary_sensors_{};
142
+ #endif
143
+
144
+ std::map<std::string, Provider> providers_{};
145
+ std::vector<uint8_t> ping_header_{};
146
+ std::vector<uint8_t> header_{};
147
+ std::vector<uint8_t> data_{};
148
+ std::map<const char *, uint32_t> ping_keys_{};
149
+ void add_key_(const char *name, uint32_t key);
150
+ void send_ping_pong_request_();
151
+ void send_packet_(void *data, size_t len);
152
+ void process_ping_request_(const char *name, uint8_t *ptr, size_t len);
153
+
154
+ inline bool is_encrypted_() { return !this->encryption_key_.empty(); }
155
+ };
156
+
157
+ } // namespace udp
158
+ } // namespace esphome
@@ -45,11 +45,8 @@ void UponorSmatrixComponent::loop() {
45
45
 
46
46
  // Read incoming data
47
47
  while (this->available()) {
48
- // The controller polls devices every 10 seconds, with around 200 ms between devices.
49
- // Remember timestamps so we can send our own packets when the bus is expected to be silent.
50
- if (now - this->last_rx_ > 500) {
51
- this->last_poll_start_ = now;
52
- }
48
+ // The controller polls devices every 10 seconds in some units or continuously in others with around 200 ms between
49
+ // devices. Remember timestamps so we can send our own packets when the bus is expected to be silent.
53
50
  this->last_rx_ = now;
54
51
 
55
52
  uint8_t byte;
@@ -60,7 +57,8 @@ void UponorSmatrixComponent::loop() {
60
57
  }
61
58
 
62
59
  // Send packets during bus silence
63
- if ((now - this->last_rx_ > 300) && (now - this->last_poll_start_ < 9500) && (now - this->last_tx_ > 200)) {
60
+ if (this->rx_buffer_.empty() && (now - this->last_rx_ > 50) && (now - this->last_rx_ < 100) &&
61
+ (now - this->last_tx_ > 200)) {
64
62
  #ifdef USE_TIME
65
63
  // Only build time packet when bus is silent and queue is empty to make sure we can send it right away
66
64
  if (this->send_time_requested_ && this->tx_queue_.empty() && this->do_send_time_())
@@ -93,7 +93,6 @@ class UponorSmatrixComponent : public uart::UARTDevice, public Component {
93
93
  std::queue<std::vector<uint8_t>> tx_queue_;
94
94
  uint32_t last_rx_;
95
95
  uint32_t last_tx_;
96
- uint32_t last_poll_start_;
97
96
 
98
97
  #ifdef USE_TIME
99
98
  time::RealTimeClock *time_id_{nullptr};
@@ -3,9 +3,11 @@ import esphome.config_validation as cv
3
3
  from esphome.components import i2c, sensor
4
4
  from esphome.const import (
5
5
  CONF_ACTUAL_GAIN,
6
+ CONF_ACTUAL_INTEGRATION_TIME,
6
7
  CONF_AMBIENT_LIGHT,
7
8
  CONF_AUTO_MODE,
8
9
  CONF_FULL_SPECTRUM,
10
+ CONF_FULL_SPECTRUM_COUNTS,
9
11
  CONF_GAIN,
10
12
  CONF_GLASS_ATTENUATION_FACTOR,
11
13
  CONF_ID,
@@ -28,9 +30,7 @@ UNIT_COUNTS = "#"
28
30
  ICON_MULTIPLICATION = "mdi:multiplication"
29
31
  ICON_BRIGHTNESS_7 = "mdi:brightness-7"
30
32
 
31
- CONF_ACTUAL_INTEGRATION_TIME = "actual_integration_time"
32
33
  CONF_AMBIENT_LIGHT_COUNTS = "ambient_light_counts"
33
- CONF_FULL_SPECTRUM_COUNTS = "full_spectrum_counts"
34
34
  CONF_LUX_COMPENSATION = "lux_compensation"
35
35
 
36
36
  veml7700_ns = cg.esphome_ns.namespace("veml7700")
@@ -43,6 +43,8 @@ CONF_VOLUME_MULTIPLIER = "volume_multiplier"
43
43
 
44
44
  CONF_WAKE_WORD = "wake_word"
45
45
 
46
+ CONF_CONVERSATION_TIMEOUT = "conversation_timeout"
47
+
46
48
  CONF_ON_TIMER_STARTED = "on_timer_started"
47
49
  CONF_ON_TIMER_UPDATED = "on_timer_updated"
48
50
  CONF_ON_TIMER_CANCELLED = "on_timer_cancelled"
@@ -100,6 +102,9 @@ CONFIG_SCHEMA = cv.All(
100
102
  cv.float_with_unit("decibel full scale", "(dBFS|dbfs|DBFS)"),
101
103
  cv.int_range(0, 31),
102
104
  ),
105
+ cv.Optional(
106
+ CONF_CONVERSATION_TIMEOUT, default="300s"
107
+ ): cv.positive_time_period_milliseconds,
103
108
  cv.Optional(CONF_VOLUME_MULTIPLIER, default=1.0): cv.float_range(
104
109
  min=0.0, min_included=False
105
110
  ),
@@ -182,6 +187,7 @@ async def to_code(config):
182
187
  cg.add(var.set_noise_suppression_level(config[CONF_NOISE_SUPPRESSION_LEVEL]))
183
188
  cg.add(var.set_auto_gain(config[CONF_AUTO_GAIN]))
184
189
  cg.add(var.set_volume_multiplier(config[CONF_VOLUME_MULTIPLIER]))
190
+ cg.add(var.set_conversation_timeout(config[CONF_CONVERSATION_TIMEOUT]))
185
191
 
186
192
  if CONF_ON_LISTENING in config:
187
193
  await automation.build_automation(
@@ -171,6 +171,11 @@ void VoiceAssistant::deallocate_buffers_() {
171
171
  #endif
172
172
  }
173
173
 
174
+ void VoiceAssistant::reset_conversation_id() {
175
+ this->conversation_id_ = "";
176
+ ESP_LOGD(TAG, "reset conversation ID");
177
+ }
178
+
174
179
  int VoiceAssistant::read_microphone_() {
175
180
  size_t bytes_read = 0;
176
181
  if (this->mic_->is_running()) { // Read audio into input buffer
@@ -299,7 +304,8 @@ void VoiceAssistant::loop() {
299
304
  break;
300
305
  }
301
306
  this->set_state_(State::STARTING_PIPELINE);
302
- this->set_timeout("reset-conversation_id", 5 * 60 * 1000, [this]() { this->conversation_id_ = ""; });
307
+ this->set_timeout("reset-conversation_id", this->conversation_timeout_,
308
+ [this]() { this->reset_conversation_id(); });
303
309
  break;
304
310
  }
305
311
  case State::STARTING_PIPELINE: {
@@ -390,6 +396,10 @@ void VoiceAssistant::loop() {
390
396
  this->set_timeout("playing", 2000, [this]() {
391
397
  this->cancel_timeout("speaker-timeout");
392
398
  this->set_state_(State::IDLE, State::IDLE);
399
+
400
+ api::VoiceAssistantAnnounceFinished msg;
401
+ msg.success = true;
402
+ this->api_client_->send_voice_assistant_announce_finished(msg);
393
403
  });
394
404
  }
395
405
  break;
@@ -745,7 +755,7 @@ void VoiceAssistant::on_event(const api::VoiceAssistantEventResponse &msg) {
745
755
  message = std::move(arg.value);
746
756
  }
747
757
  }
748
- if (code == "wake-word-timeout" || code == "wake_word_detection_aborted") {
758
+ if (code == "wake-word-timeout" || code == "wake_word_detection_aborted" || code == "no_wake_word") {
749
759
  // Don't change state here since either the "tts-end" or "run-end" events will do it.
750
760
  return;
751
761
  } else if (code == "wake-provider-missing" || code == "wake-engine-missing") {
@@ -860,6 +870,18 @@ void VoiceAssistant::timer_tick_() {
860
870
  this->timer_tick_trigger_->trigger(res);
861
871
  }
862
872
 
873
+ void VoiceAssistant::on_announce(const api::VoiceAssistantAnnounceRequest &msg) {
874
+ #ifdef USE_MEDIA_PLAYER
875
+ if (this->media_player_ != nullptr) {
876
+ this->tts_start_trigger_->trigger(msg.text);
877
+ this->media_player_->make_call().set_media_url(msg.media_id).set_announcement(true).perform();
878
+ this->set_state_(State::STREAMING_RESPONSE, State::STREAMING_RESPONSE);
879
+ this->tts_end_trigger_->trigger(msg.media_id);
880
+ this->end_trigger_->trigger();
881
+ }
882
+ #endif
883
+ }
884
+
863
885
  VoiceAssistant *global_voice_assistant = nullptr; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
864
886
 
865
887
  } // namespace voice_assistant
@@ -77,6 +77,18 @@ struct Timer {
77
77
  }
78
78
  };
79
79
 
80
+ struct WakeWord {
81
+ std::string id;
82
+ std::string wake_word;
83
+ std::vector<std::string> trained_languages;
84
+ };
85
+
86
+ struct Configuration {
87
+ std::vector<WakeWord> available_wake_words;
88
+ std::vector<std::string> active_wake_words;
89
+ uint32_t max_active_wake_words;
90
+ };
91
+
80
92
  class VoiceAssistant : public Component {
81
93
  public:
82
94
  void setup() override;
@@ -132,6 +144,9 @@ class VoiceAssistant : public Component {
132
144
  void on_event(const api::VoiceAssistantEventResponse &msg);
133
145
  void on_audio(const api::VoiceAssistantAudio &msg);
134
146
  void on_timer_event(const api::VoiceAssistantTimerEventResponse &msg);
147
+ void on_announce(const api::VoiceAssistantAnnounceRequest &msg);
148
+ void on_set_configuration(const std::vector<std::string> &active_wake_words){};
149
+ const Configuration &get_configuration() { return this->config_; };
135
150
 
136
151
  bool is_running() const { return this->state_ != State::IDLE; }
137
152
  void set_continuous(bool continuous) { this->continuous_ = continuous; }
@@ -147,6 +162,8 @@ class VoiceAssistant : public Component {
147
162
  }
148
163
  void set_auto_gain(uint8_t auto_gain) { this->auto_gain_ = auto_gain; }
149
164
  void set_volume_multiplier(float volume_multiplier) { this->volume_multiplier_ = volume_multiplier; }
165
+ void set_conversation_timeout(uint32_t conversation_timeout) { this->conversation_timeout_ = conversation_timeout; }
166
+ void reset_conversation_id();
150
167
 
151
168
  Trigger<> *get_intent_end_trigger() const { return this->intent_end_trigger_; }
152
169
  Trigger<> *get_intent_start_trigger() const { return this->intent_start_trigger_; }
@@ -262,6 +279,7 @@ class VoiceAssistant : public Component {
262
279
  uint8_t noise_suppression_level_;
263
280
  uint8_t auto_gain_;
264
281
  float volume_multiplier_;
282
+ uint32_t conversation_timeout_;
265
283
 
266
284
  uint8_t *send_buffer_;
267
285
  int16_t *input_buffer_;
@@ -275,6 +293,8 @@ class VoiceAssistant : public Component {
275
293
  AudioMode audio_mode_{AUDIO_MODE_UDP};
276
294
  bool udp_socket_running_{false};
277
295
  bool start_udp_socket_();
296
+
297
+ Configuration config_{};
278
298
  };
279
299
 
280
300
  template<typename... Ts> class StartAction : public Action<Ts...>, public Parented<VoiceAssistant> {
@@ -1,35 +1,36 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import gzip
4
+
4
5
  import esphome.codegen as cg
5
- import esphome.config_validation as cv
6
- import esphome.final_validate as fv
7
6
  from esphome.components import web_server_base
8
7
  from esphome.components.web_server_base import CONF_WEB_SERVER_BASE_ID
8
+ import esphome.config_validation as cv
9
9
  from esphome.const import (
10
+ CONF_AUTH,
10
11
  CONF_CSS_INCLUDE,
11
12
  CONF_CSS_URL,
13
+ CONF_ENABLE_PRIVATE_NETWORK_ACCESS,
12
14
  CONF_ID,
15
+ CONF_INCLUDE_INTERNAL,
13
16
  CONF_JS_INCLUDE,
14
17
  CONF_JS_URL,
15
- CONF_ENABLE_PRIVATE_NETWORK_ACCESS,
18
+ CONF_LOCAL,
19
+ CONF_LOG,
20
+ CONF_OTA,
21
+ CONF_PASSWORD,
16
22
  CONF_PORT,
17
- CONF_AUTH,
18
23
  CONF_USERNAME,
19
- CONF_PASSWORD,
20
- CONF_INCLUDE_INTERNAL,
21
- CONF_OTA,
22
- CONF_LOG,
23
24
  CONF_VERSION,
24
- CONF_LOCAL,
25
25
  CONF_WEB_SERVER_ID,
26
26
  CONF_WEB_SERVER_SORTING_WEIGHT,
27
+ PLATFORM_BK72XX,
27
28
  PLATFORM_ESP32,
28
29
  PLATFORM_ESP8266,
29
- PLATFORM_BK72XX,
30
30
  PLATFORM_RTL87XX,
31
31
  )
32
32
  from esphome.core import CORE, coroutine_with_priority
33
+ import esphome.final_validate as fv
33
34
 
34
35
  AUTO_LOAD = ["json", "web_server_base"]
35
36
 
@@ -208,7 +209,6 @@ async def to_code(config):
208
209
  var = cg.new_Pvariable(config[CONF_ID], paren)
209
210
  await cg.register_component(var, config)
210
211
 
211
- cg.add_define("USE_WEBSERVER")
212
212
  version = config[CONF_VERSION]
213
213
 
214
214
  cg.add(paren.set_port(config[CONF_PORT]))
@@ -1,4 +1,5 @@
1
1
  #include "list_entities.h"
2
+ #ifdef USE_WEBSERVER
2
3
  #include "esphome/core/application.h"
3
4
  #include "esphome/core/log.h"
4
5
  #include "esphome/core/util.h"
@@ -188,3 +189,4 @@ bool ListEntitiesIterator::on_update(update::UpdateEntity *update) {
188
189
 
189
190
  } // namespace web_server
190
191
  } // namespace esphome
192
+ #endif
@@ -1,8 +1,9 @@
1
1
  #pragma once
2
2
 
3
+ #include "esphome/core/defines.h"
4
+ #ifdef USE_WEBSERVER
3
5
  #include "esphome/core/component.h"
4
6
  #include "esphome/core/component_iterator.h"
5
- #include "esphome/core/defines.h"
6
7
  namespace esphome {
7
8
  namespace web_server {
8
9
 
@@ -78,3 +79,4 @@ class ListEntitiesIterator : public ComponentIterator {
78
79
 
79
80
  } // namespace web_server
80
81
  } // namespace esphome
82
+ #endif
@@ -1,5 +1,5 @@
1
1
  #include "web_server.h"
2
-
2
+ #ifdef USE_WEBSERVER
3
3
  #include "esphome/components/json/json_util.h"
4
4
  #include "esphome/components/network/util.h"
5
5
  #include "esphome/core/application.h"
@@ -1659,3 +1659,4 @@ void WebServer::schedule_(std::function<void()> &&f) {
1659
1659
 
1660
1660
  } // namespace web_server
1661
1661
  } // namespace esphome
1662
+ #endif
@@ -3,6 +3,7 @@
3
3
  #include "list_entities.h"
4
4
 
5
5
  #include "esphome/components/web_server_base/web_server_base.h"
6
+ #ifdef USE_WEBSERVER
6
7
  #include "esphome/core/component.h"
7
8
  #include "esphome/core/controller.h"
8
9
  #include "esphome/core/entity_base.h"
@@ -366,3 +367,4 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
366
367
 
367
368
  } // namespace web_server
368
369
  } // namespace esphome
370
+ #endif
@@ -1,4 +1,5 @@
1
1
  #include "web_server_base.h"
2
+ #ifdef USE_NETWORK
2
3
  #include "esphome/core/log.h"
3
4
  #include "esphome/core/application.h"
4
5
  #include "esphome/core/helpers.h"
@@ -121,3 +122,4 @@ float WebServerBase::get_setup_priority() const {
121
122
 
122
123
  } // namespace web_server_base
123
124
  } // namespace esphome
125
+ #endif
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
-
2
+ #include "esphome/core/defines.h"
3
+ #ifdef USE_NETWORK
3
4
  #include <memory>
4
5
  #include <utility>
5
6
  #include <vector>
@@ -145,3 +146,4 @@ class OTARequestHandler : public AsyncWebHandler {
145
146
 
146
147
  } // namespace web_server_base
147
148
  } // namespace esphome
149
+ #endif
@@ -85,7 +85,16 @@ bool WiFiComponent::wifi_sta_ip_config_(optional<ManualIP> manual_ip) {
85
85
  network::IPAddresses WiFiComponent::wifi_sta_ip_addresses() {
86
86
  if (!this->has_sta())
87
87
  return {};
88
- return {WiFi.localIP()};
88
+ network::IPAddresses addresses;
89
+ addresses[0] = WiFi.localIP();
90
+ #if USE_NETWORK_IPV6
91
+ int i = 1;
92
+ auto v6_addresses = WiFi.allLocalIPv6();
93
+ for (auto address : v6_addresses) {
94
+ addresses[i++] = network::IPAddress(address.toString().c_str());
95
+ }
96
+ #endif /* USE_NETWORK_IPV6 */
97
+ return addresses;
89
98
  }
90
99
 
91
100
  bool WiFiComponent::wifi_apply_hostname_() {
@@ -321,6 +330,11 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
321
330
  s_sta_connecting = false;
322
331
  break;
323
332
  }
333
+ case ESPHOME_EVENT_ID_WIFI_STA_GOT_IP6: {
334
+ // auto it = info.got_ip.ip_info;
335
+ ESP_LOGV(TAG, "Event: Got IPv6");
336
+ break;
337
+ }
324
338
  case ESPHOME_EVENT_ID_WIFI_STA_LOST_IP: {
325
339
  ESP_LOGV(TAG, "Event: Lost IP");
326
340
  break;
@@ -1,19 +1,20 @@
1
- import re
2
1
  import ipaddress
2
+ import re
3
+
4
+ from esphome import automation
3
5
  import esphome.codegen as cg
6
+ from esphome.components import time
7
+ from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
4
8
  import esphome.config_validation as cv
5
9
  from esphome.const import (
6
- CONF_ID,
7
- CONF_TIME_ID,
8
10
  CONF_ADDRESS,
11
+ CONF_ID,
9
12
  CONF_REBOOT_TIMEOUT,
13
+ CONF_TIME_ID,
10
14
  KEY_CORE,
11
15
  KEY_FRAMEWORK_VERSION,
12
16
  )
13
- from esphome.components.esp32 import CORE, add_idf_sdkconfig_option
14
- from esphome.components import time
15
17
  from esphome.core import TimePeriod
16
- from esphome import automation
17
18
 
18
19
  CONF_NETMASK = "netmask"
19
20
  CONF_PRIVATE_KEY = "private_key"
@@ -91,6 +92,8 @@ CONFIG_SCHEMA = cv.Schema(
91
92
  async def to_code(config):
92
93
  var = cg.new_Pvariable(config[CONF_ID])
93
94
 
95
+ cg.add_define("USE_WIREGUARD")
96
+
94
97
  cg.add(var.set_address(str(config[CONF_ADDRESS])))
95
98
  cg.add(var.set_netmask(str(config[CONF_NETMASK])))
96
99
  cg.add(var.set_private_key(config[CONF_PRIVATE_KEY]))
@@ -1,5 +1,5 @@
1
1
  #include "wireguard.h"
2
-
2
+ #ifdef USE_WIREGUARD
3
3
  #include <cinttypes>
4
4
  #include <ctime>
5
5
  #include <functional>
@@ -289,3 +289,4 @@ std::string mask_key(const std::string &key) { return (key.substr(0, 5) + "[...]
289
289
 
290
290
  } // namespace wireguard
291
291
  } // namespace esphome
292
+ #endif
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
-
2
+ #include "esphome/core/defines.h"
3
+ #ifdef USE_WIREGUARD
3
4
  #include <ctime>
4
5
  #include <vector>
5
6
  #include <tuple>
@@ -170,3 +171,4 @@ template<typename... Ts> class WireguardDisableAction : public Action<Ts...>, pu
170
171
 
171
172
  } // namespace wireguard
172
173
  } // namespace esphome
174
+ #endif
@@ -2045,6 +2045,7 @@ def require_framework_version(
2045
2045
  esp32_arduino=None,
2046
2046
  esp8266_arduino=None,
2047
2047
  rp2040_arduino=None,
2048
+ bk72xx_libretiny=None,
2048
2049
  host=None,
2049
2050
  max_version=False,
2050
2051
  extra_message=None,
@@ -2059,6 +2060,13 @@ def require_framework_version(
2059
2060
  msg += f". {extra_message}"
2060
2061
  raise Invalid(msg)
2061
2062
  required = esp_idf
2063
+ elif CORE.is_bk72xx and framework == "arduino":
2064
+ if bk72xx_libretiny is None:
2065
+ msg = "This feature is incompatible with BK72XX"
2066
+ if extra_message:
2067
+ msg += f". {extra_message}"
2068
+ raise Invalid(msg)
2069
+ required = bk72xx_libretiny
2062
2070
  elif CORE.is_esp32 and framework == "arduino":
2063
2071
  if esp32_arduino is None:
2064
2072
  msg = "This feature is incompatible with ESP32 using arduino framework"
esphome/const.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Constants used by esphome."""
2
2
 
3
- __version__ = "2024.8.2"
3
+ __version__ = "2024.9.0"
4
4
 
5
5
  ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
6
6
  VALID_SUBSTITUTIONS_CHARACTERS = (
@@ -44,6 +44,7 @@ CONF_ACTIONS = "actions"
44
44
  CONF_ACTIVE = "active"
45
45
  CONF_ACTIVE_POWER = "active_power"
46
46
  CONF_ACTUAL_GAIN = "actual_gain"
47
+ CONF_ACTUAL_INTEGRATION_TIME = "actual_integration_time"
47
48
  CONF_ADDRESS = "address"
48
49
  CONF_ADDRESSABLE_LIGHT_ID = "addressable_light_id"
49
50
  CONF_ADVANCED = "advanced"
@@ -323,6 +324,7 @@ CONF_FREQUENCY = "frequency"
323
324
  CONF_FRIENDLY_NAME = "friendly_name"
324
325
  CONF_FROM = "from"
325
326
  CONF_FULL_SPECTRUM = "full_spectrum"
327
+ CONF_FULL_SPECTRUM_COUNTS = "full_spectrum_counts"
326
328
  CONF_FULL_UPDATE_EVERY = "full_update_every"
327
329
  CONF_GAIN = "gain"
328
330
  CONF_GAMMA_CORRECT = "gamma_correct"
@@ -431,6 +433,7 @@ CONF_LIGHT_ID = "light_id"
431
433
  CONF_LIGHTNING_ENERGY = "lightning_energy"
432
434
  CONF_LIGHTNING_THRESHOLD = "lightning_threshold"
433
435
  CONF_LIMIT_MODE = "limit_mode"
436
+ CONF_LINE_FREQUENCY = "line_frequency"
434
437
  CONF_LINE_THICKNESS = "line_thickness"
435
438
  CONF_LINE_TYPE = "line_type"
436
439
  CONF_LOADED_INTEGRATIONS = "loaded_integrations"
@@ -729,6 +732,7 @@ CONF_RW_PIN = "rw_pin"
729
732
  CONF_RX_BUFFER_SIZE = "rx_buffer_size"
730
733
  CONF_RX_ONLY = "rx_only"
731
734
  CONF_RX_PIN = "rx_pin"
735
+ CONF_RX_QUEUE_LEN = "rx_queue_len"
732
736
  CONF_SAFE_MODE = "safe_mode"
733
737
  CONF_SAMPLE_RATE = "sample_rate"
734
738
  CONF_SAMSUNG = "samsung"
@@ -848,6 +852,7 @@ CONF_TEMPERATURE_STEP = "temperature_step"
848
852
  CONF_TEXT = "text"
849
853
  CONF_TEXT_SENSORS = "text_sensors"
850
854
  CONF_THEN = "then"
855
+ CONF_THERMOCOUPLE_TYPE = "thermocouple_type"
851
856
  CONF_THRESHOLD = "threshold"
852
857
  CONF_THROTTLE = "throttle"
853
858
  CONF_TILT = "tilt"
@@ -880,6 +885,7 @@ CONF_TVOC = "tvoc"
880
885
  CONF_TX_BUFFER_SIZE = "tx_buffer_size"
881
886
  CONF_TX_PIN = "tx_pin"
882
887
  CONF_TX_POWER = "tx_power"
888
+ CONF_TX_QUEUE_LEN = "tx_queue_len"
883
889
  CONF_TYPE = "type"
884
890
  CONF_TYPE_ID = "type_id"
885
891
  CONF_UART_ID = "uart_id"
@@ -1042,6 +1048,7 @@ UNIT_KILOVOLT_AMPS_REACTIVE = "kVAR"
1042
1048
  UNIT_KILOVOLT_AMPS_REACTIVE_HOURS = "kVARh"
1043
1049
  UNIT_KILOWATT = "kW"
1044
1050
  UNIT_KILOWATT_HOURS = "kWh"
1051
+ UNIT_LITRE = "L"
1045
1052
  UNIT_LUX = "lx"
1046
1053
  UNIT_METER = "m"
1047
1054
  UNIT_METER_PER_SECOND_SQUARED = "m/s²"