esphome 2024.8.3__py3-none-any.whl → 2024.9.0b1__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 (198) hide show
  1. esphome/__main__.py +6 -2
  2. esphome/components/api/api_connection.cpp +19 -0
  3. esphome/components/api/api_connection.h +1 -0
  4. esphome/components/api/api_pb2.cpp +136 -0
  5. esphome/components/api/api_pb2.h +43 -0
  6. esphome/components/api/api_pb2_service.cpp +21 -0
  7. esphome/components/api/api_pb2_service.h +6 -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/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
  23. esphome/components/bmp280/sensor.py +2 -93
  24. esphome/components/bmp280_base/__init__.py +88 -0
  25. esphome/components/{bmp280/bmp280.cpp → bmp280_base/bmp280_base.cpp} +11 -4
  26. esphome/components/{bmp280/bmp280.h → bmp280_base/bmp280_base.h} +9 -5
  27. esphome/components/bmp280_i2c/__init__.py +0 -0
  28. esphome/components/bmp280_i2c/bmp280_i2c.cpp +27 -0
  29. esphome/components/bmp280_i2c/bmp280_i2c.h +22 -0
  30. esphome/components/bmp280_i2c/sensor.py +22 -0
  31. esphome/components/bmp280_spi/__init__.py +0 -0
  32. esphome/components/bmp280_spi/bmp280_spi.cpp +65 -0
  33. esphome/components/bmp280_spi/bmp280_spi.h +20 -0
  34. esphome/components/bmp280_spi/sensor.py +22 -0
  35. esphome/components/captive_portal/captive_portal.cpp +2 -0
  36. esphome/components/captive_portal/captive_portal.h +3 -1
  37. esphome/components/ch422g/__init__.py +67 -0
  38. esphome/components/ch422g/ch422g.cpp +122 -0
  39. esphome/components/ch422g/ch422g.h +70 -0
  40. esphome/components/debug/debug_esp32.cpp +3 -1
  41. esphome/components/display/__init__.py +5 -4
  42. esphome/components/dsmr/dsmr.cpp +6 -0
  43. esphome/components/dsmr/dsmr.h +6 -0
  44. esphome/components/dsmr/text_sensor.py +7 -2
  45. esphome/components/e131/e131.cpp +2 -0
  46. esphome/components/e131/e131.h +3 -1
  47. esphome/components/e131/e131_addressable_light_effect.cpp +2 -0
  48. esphome/components/e131/e131_addressable_light_effect.h +2 -1
  49. esphome/components/e131/e131_packet.cpp +2 -0
  50. esphome/components/esp32_camera/__init__.py +4 -0
  51. esphome/components/esp32_camera/esp32_camera.cpp +9 -1
  52. esphome/components/esp32_camera/esp32_camera.h +3 -0
  53. esphome/components/esp32_can/canbus.py +18 -7
  54. esphome/components/esp32_can/esp32_can.cpp +8 -0
  55. esphome/components/esp32_can/esp32_can.h +4 -0
  56. esphome/components/esp32_rmt_led_strip/led_strip.cpp +14 -2
  57. esphome/components/esp32_rmt_led_strip/led_strip.h +3 -2
  58. esphome/components/esp32_rmt_led_strip/light.py +21 -4
  59. esphome/components/esphome/ota/ota_esphome.cpp +2 -1
  60. esphome/components/esphome/ota/ota_esphome.h +2 -0
  61. esphome/components/font/__init__.py +11 -22
  62. esphome/components/font/font.cpp +3 -2
  63. esphome/components/font/font.h +12 -3
  64. esphome/components/gree/climate.py +2 -1
  65. esphome/components/gree/gree.cpp +54 -3
  66. esphome/components/gree/gree.h +10 -2
  67. esphome/components/gt911/touchscreen/__init__.py +6 -4
  68. esphome/components/gt911/touchscreen/gt911_touchscreen.cpp +17 -0
  69. esphome/components/gt911/touchscreen/gt911_touchscreen.h +2 -0
  70. esphome/components/hmac_md5/__init__.py +2 -0
  71. esphome/components/hmac_md5/hmac_md5.cpp +56 -0
  72. esphome/components/hmac_md5/hmac_md5.h +48 -0
  73. esphome/components/homeassistant/__init__.py +13 -0
  74. esphome/components/homeassistant/switch/__init__.py +15 -2
  75. esphome/components/homeassistant/switch/homeassistant_switch.cpp +2 -2
  76. esphome/components/i2s_audio/__init__.py +88 -9
  77. esphome/components/i2s_audio/i2s_audio.h +20 -2
  78. esphome/components/i2s_audio/media_player/__init__.py +8 -4
  79. esphome/components/i2s_audio/media_player/i2s_audio_media_player.h +1 -1
  80. esphome/components/i2s_audio/microphone/__init__.py +19 -51
  81. esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +18 -15
  82. esphome/components/i2s_audio/microphone/i2s_audio_microphone.h +0 -12
  83. esphome/components/i2s_audio/speaker/__init__.py +39 -27
  84. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +49 -37
  85. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +3 -4
  86. esphome/components/ili9xxx/display.py +16 -17
  87. esphome/components/ili9xxx/ili9xxx_display.cpp +1 -1
  88. esphome/components/ili9xxx/ili9xxx_display.h +18 -18
  89. esphome/components/ili9xxx/ili9xxx_init.h +0 -3
  90. esphome/components/improv_serial/improv_serial_component.cpp +2 -1
  91. esphome/components/improv_serial/improv_serial_component.h +2 -1
  92. esphome/components/ledc/ledc_output.cpp +11 -7
  93. esphome/components/libretiny/__init__.py +8 -13
  94. esphome/components/ltr501/__init__.py +1 -0
  95. esphome/components/ltr501/ltr501.cpp +542 -0
  96. esphome/components/ltr501/ltr501.h +184 -0
  97. esphome/components/ltr501/ltr_definitions_501.h +260 -0
  98. esphome/components/ltr501/sensor.py +274 -0
  99. esphome/components/ltr_als_ps/sensor.py +2 -2
  100. esphome/components/lvgl/__init__.py +19 -16
  101. esphome/components/lvgl/automation.py +90 -9
  102. esphome/components/lvgl/defines.py +29 -2
  103. esphome/components/lvgl/gradient.py +61 -0
  104. esphome/components/lvgl/lv_validation.py +45 -27
  105. esphome/components/lvgl/lvcode.py +8 -3
  106. esphome/components/lvgl/lvgl_esphome.cpp +54 -0
  107. esphome/components/lvgl/lvgl_esphome.h +9 -3
  108. esphome/components/lvgl/number/__init__.py +1 -0
  109. esphome/components/lvgl/number/lvgl_number.h +3 -1
  110. esphome/components/lvgl/schemas.py +16 -11
  111. esphome/components/lvgl/select/__init__.py +1 -0
  112. esphome/components/lvgl/select/lvgl_select.h +3 -1
  113. esphome/components/lvgl/switch/__init__.py +2 -1
  114. esphome/components/lvgl/switch/lvgl_switch.h +3 -1
  115. esphome/components/lvgl/text/__init__.py +1 -0
  116. esphome/components/lvgl/text/lvgl_text.h +3 -1
  117. esphome/components/lvgl/trigger.py +3 -2
  118. esphome/components/lvgl/types.py +2 -1
  119. esphome/components/lvgl/widgets/__init__.py +23 -8
  120. esphome/components/lvgl/widgets/arc.py +5 -1
  121. esphome/components/lvgl/widgets/buttonmatrix.py +5 -1
  122. esphome/components/lvgl/widgets/checkbox.py +8 -3
  123. esphome/components/lvgl/widgets/meter.py +8 -1
  124. esphome/components/lvgl/widgets/msgbox.py +26 -15
  125. esphome/components/lvgl/widgets/page.py +51 -7
  126. esphome/components/lvgl/widgets/tileview.py +2 -8
  127. esphome/components/max31856/max31856.cpp +12 -1
  128. esphome/components/max31856/max31856.h +5 -2
  129. esphome/components/max31856/sensor.py +20 -0
  130. esphome/components/mcp9600/sensor.py +2 -2
  131. esphome/components/mdns/__init__.py +6 -6
  132. esphome/components/media_player/media_player.h +15 -0
  133. esphome/components/micro_wake_word/__init__.py +2 -25
  134. esphome/components/microphone/microphone.h +1 -1
  135. esphome/components/mics_4514/mics_4514.cpp +26 -36
  136. esphome/components/modbus_controller/__init__.py +6 -0
  137. esphome/components/modbus_controller/const.py +2 -0
  138. esphome/components/modbus_controller/modbus_controller.cpp +30 -27
  139. esphome/components/modbus_controller/modbus_controller.h +22 -4
  140. esphome/components/network/__init__.py +11 -8
  141. esphome/components/pipsolar/pipsolar.cpp +3 -0
  142. esphome/components/pipsolar/pipsolar.h +1 -0
  143. esphome/components/pipsolar/switch/__init__.py +2 -0
  144. esphome/components/prometheus/prometheus_handler.cpp +2 -0
  145. esphome/components/prometheus/prometheus_handler.h +3 -1
  146. esphome/components/rp2040/__init__.py +7 -8
  147. esphome/components/rpi_dpi_rgb/display.py +20 -17
  148. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.cpp +36 -6
  149. esphome/components/rpi_dpi_rgb/rpi_dpi_rgb.h +4 -0
  150. esphome/components/socket/socket.cpp +2 -0
  151. esphome/components/socket/socket.h +2 -0
  152. esphome/components/speaker/speaker.h +1 -1
  153. esphome/components/st7701s/display.py +35 -37
  154. esphome/components/st7701s/st7701s.cpp +11 -6
  155. esphome/components/st7701s/st7701s.h +1 -0
  156. esphome/components/statsd/__init__.py +65 -0
  157. esphome/components/statsd/statsd.cpp +156 -0
  158. esphome/components/statsd/statsd.h +86 -0
  159. esphome/components/tuya/__init__.py +1 -0
  160. esphome/components/tuya/number/__init__.py +39 -2
  161. esphome/components/tuya/number/tuya_number.cpp +58 -2
  162. esphome/components/tuya/number/tuya_number.h +12 -3
  163. esphome/components/udp/__init__.py +158 -0
  164. esphome/components/udp/binary_sensor.py +27 -0
  165. esphome/components/udp/sensor.py +27 -0
  166. esphome/components/udp/udp_component.cpp +616 -0
  167. esphome/components/udp/udp_component.h +158 -0
  168. esphome/components/uponor_smatrix/uponor_smatrix.cpp +4 -6
  169. esphome/components/uponor_smatrix/uponor_smatrix.h +0 -1
  170. esphome/components/veml7700/sensor.py +2 -2
  171. esphome/components/voice_assistant/__init__.py +6 -0
  172. esphome/components/voice_assistant/voice_assistant.cpp +23 -1
  173. esphome/components/voice_assistant/voice_assistant.h +4 -0
  174. esphome/components/web_server/__init__.py +11 -11
  175. esphome/components/web_server/list_entities.cpp +2 -0
  176. esphome/components/web_server/list_entities.h +3 -1
  177. esphome/components/web_server/web_server.cpp +2 -1
  178. esphome/components/web_server/web_server.h +2 -0
  179. esphome/components/web_server_base/web_server_base.cpp +2 -0
  180. esphome/components/web_server_base/web_server_base.h +3 -1
  181. esphome/components/wifi/wifi_component_libretiny.cpp +15 -1
  182. esphome/components/wireguard/__init__.py +9 -6
  183. esphome/components/wireguard/wireguard.cpp +2 -1
  184. esphome/components/wireguard/wireguard.h +3 -1
  185. esphome/config_validation.py +8 -0
  186. esphome/const.py +8 -1
  187. esphome/core/bytebuffer.cpp +117 -84
  188. esphome/core/bytebuffer.h +69 -21
  189. esphome/core/defines.h +2 -0
  190. esphome/core/ring_buffer.cpp +13 -2
  191. esphome/core/ring_buffer.h +56 -0
  192. esphome/external_files.py +5 -3
  193. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/METADATA +1 -1
  194. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/RECORD +198 -163
  195. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/LICENSE +0 -0
  196. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/WHEEL +0 -0
  197. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/entry_points.txt +0 -0
  198. {esphome-2024.8.3.dist-info → esphome-2024.9.0b1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,20 @@
1
+ #pragma once
2
+
3
+ #include "esphome/components/bmp280_base/bmp280_base.h"
4
+ #include "esphome/components/spi/spi.h"
5
+
6
+ namespace esphome {
7
+ namespace bmp280_spi {
8
+
9
+ class BMP280SPIComponent : public esphome::bmp280_base::BMP280Component,
10
+ public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_LOW,
11
+ spi::CLOCK_PHASE_LEADING, spi::DATA_RATE_200KHZ> {
12
+ void setup() override;
13
+ bool read_byte(uint8_t a_register, uint8_t *data) override;
14
+ bool write_byte(uint8_t a_register, uint8_t data) override;
15
+ bool read_bytes(uint8_t a_register, uint8_t *data, size_t len) override;
16
+ bool read_byte_16(uint8_t a_register, uint16_t *data) override;
17
+ };
18
+
19
+ } // namespace bmp280_spi
20
+ } // namespace esphome
@@ -0,0 +1,22 @@
1
+ import esphome.codegen as cg
2
+ import esphome.config_validation as cv
3
+ from esphome.components import spi
4
+ from ..bmp280_base import to_code_base, CONFIG_SCHEMA_BASE
5
+
6
+ AUTO_LOAD = ["bmp280_base"]
7
+ CODEOWNERS = ["@ademuri"]
8
+ DEPENDENCIES = ["spi"]
9
+
10
+ bmp280_ns = cg.esphome_ns.namespace("bmp280_spi")
11
+ BMP280SPIComponent = bmp280_ns.class_(
12
+ "BMP280SPIComponent", cg.PollingComponent, spi.SPIDevice
13
+ )
14
+
15
+ CONFIG_SCHEMA = CONFIG_SCHEMA_BASE.extend(
16
+ spi.spi_device_schema(default_mode="mode3")
17
+ ).extend({cv.GenerateID(): cv.declare_id(BMP280SPIComponent)})
18
+
19
+
20
+ async def to_code(config):
21
+ var = await to_code_base(config)
22
+ await spi.register_spi_device(var, config)
@@ -1,4 +1,5 @@
1
1
  #include "captive_portal.h"
2
+ #ifdef USE_CAPTIVE_PORTAL
2
3
  #include "esphome/core/log.h"
3
4
  #include "esphome/core/application.h"
4
5
  #include "esphome/components/wifi/wifi_component.h"
@@ -91,3 +92,4 @@ CaptivePortal *global_captive_portal = nullptr; // NOLINT(cppcoreguidelines-avo
91
92
 
92
93
  } // namespace captive_portal
93
94
  } // namespace esphome
95
+ #endif
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
-
2
+ #include "esphome/core/defines.h"
3
+ #ifdef USE_CAPTIVE_PORTAL
3
4
  #include <memory>
4
5
  #ifdef USE_ARDUINO
5
6
  #include <DNSServer.h>
@@ -71,3 +72,4 @@ extern CaptivePortal *global_captive_portal; // NOLINT(cppcoreguidelines-avoid-
71
72
 
72
73
  } // namespace captive_portal
73
74
  } // namespace esphome
75
+ #endif
@@ -0,0 +1,67 @@
1
+ from esphome import pins
2
+ import esphome.codegen as cg
3
+ from esphome.components import i2c
4
+ import esphome.config_validation as cv
5
+ from esphome.const import (
6
+ CONF_ID,
7
+ CONF_INPUT,
8
+ CONF_INVERTED,
9
+ CONF_MODE,
10
+ CONF_NUMBER,
11
+ CONF_OUTPUT,
12
+ CONF_RESTORE_VALUE,
13
+ )
14
+
15
+ CODEOWNERS = ["@jesterret"]
16
+ DEPENDENCIES = ["i2c"]
17
+ MULTI_CONF = True
18
+ ch422g_ns = cg.esphome_ns.namespace("ch422g")
19
+
20
+ CH422GComponent = ch422g_ns.class_("CH422GComponent", cg.Component, i2c.I2CDevice)
21
+ CH422GGPIOPin = ch422g_ns.class_(
22
+ "CH422GGPIOPin", cg.GPIOPin, cg.Parented.template(CH422GComponent)
23
+ )
24
+
25
+ CONF_CH422G = "ch422g"
26
+ CONFIG_SCHEMA = (
27
+ cv.Schema(
28
+ {
29
+ cv.Required(CONF_ID): cv.declare_id(CH422GComponent),
30
+ cv.Optional(CONF_RESTORE_VALUE, default=False): cv.boolean,
31
+ }
32
+ )
33
+ .extend(cv.COMPONENT_SCHEMA)
34
+ .extend(i2c.i2c_device_schema(0x24))
35
+ )
36
+
37
+
38
+ async def to_code(config):
39
+ var = cg.new_Pvariable(config[CONF_ID])
40
+ cg.add(var.set_restore_value(config[CONF_RESTORE_VALUE]))
41
+ await cg.register_component(var, config)
42
+ await i2c.register_i2c_device(var, config)
43
+
44
+
45
+ CH422G_PIN_SCHEMA = pins.gpio_base_schema(
46
+ CH422GGPIOPin,
47
+ cv.int_range(min=0, max=7),
48
+ modes=[CONF_INPUT, CONF_OUTPUT],
49
+ ).extend(
50
+ {
51
+ cv.Required(CONF_CH422G): cv.use_id(CH422GComponent),
52
+ }
53
+ )
54
+
55
+
56
+ @pins.PIN_SCHEMA_REGISTRY.register(CONF_CH422G, CH422G_PIN_SCHEMA)
57
+ async def ch422g_pin_to_code(config):
58
+ var = cg.new_Pvariable(config[CONF_ID])
59
+ parent = await cg.get_variable(config[CONF_CH422G])
60
+
61
+ cg.add(var.set_parent(parent))
62
+
63
+ num = config[CONF_NUMBER]
64
+ cg.add(var.set_pin(num))
65
+ cg.add(var.set_inverted(config[CONF_INVERTED]))
66
+ cg.add(var.set_flags(pins.gpio_flags_expr(config[CONF_MODE])))
67
+ return var
@@ -0,0 +1,122 @@
1
+ #include "ch422g.h"
2
+ #include "esphome/core/log.h"
3
+
4
+ namespace esphome {
5
+ namespace ch422g {
6
+
7
+ const uint8_t CH422G_REG_IN = 0x26;
8
+ const uint8_t CH422G_REG_OUT = 0x38;
9
+ const uint8_t OUT_REG_DEFAULT_VAL = 0xdf;
10
+
11
+ static const char *const TAG = "ch422g";
12
+
13
+ void CH422GComponent::setup() {
14
+ ESP_LOGCONFIG(TAG, "Setting up CH422G...");
15
+ // Test to see if device exists
16
+ if (!this->read_inputs_()) {
17
+ ESP_LOGE(TAG, "CH422G not detected at 0x%02X", this->address_);
18
+ this->mark_failed();
19
+ return;
20
+ }
21
+
22
+ // restore defaults over whatever got saved on last boot
23
+ if (!this->restore_value_) {
24
+ this->write_output_(OUT_REG_DEFAULT_VAL);
25
+ }
26
+
27
+ ESP_LOGD(TAG, "Initialization complete. Warning: %d, Error: %d", this->status_has_warning(),
28
+ this->status_has_error());
29
+ }
30
+
31
+ void CH422GComponent::loop() {
32
+ // Clear all the previously read flags.
33
+ this->pin_read_cache_ = 0x00;
34
+ }
35
+
36
+ void CH422GComponent::dump_config() {
37
+ ESP_LOGCONFIG(TAG, "CH422G:");
38
+ LOG_I2C_DEVICE(this)
39
+ if (this->is_failed()) {
40
+ ESP_LOGE(TAG, "Communication with CH422G failed!");
41
+ }
42
+ }
43
+
44
+ // ch422g doesn't have any flag support (needs docs?)
45
+ void CH422GComponent::pin_mode(uint8_t pin, gpio::Flags flags) {}
46
+
47
+ bool CH422GComponent::digital_read(uint8_t pin) {
48
+ if (this->pin_read_cache_ == 0 || this->pin_read_cache_ & (1 << pin)) {
49
+ // Read values on first access or in case it's being read again in the same loop
50
+ this->read_inputs_();
51
+ }
52
+
53
+ this->pin_read_cache_ |= (1 << pin);
54
+ return this->state_mask_ & (1 << pin);
55
+ }
56
+
57
+ void CH422GComponent::digital_write(uint8_t pin, bool value) {
58
+ if (value) {
59
+ this->write_output_(this->state_mask_ | (1 << pin));
60
+ } else {
61
+ this->write_output_(this->state_mask_ & ~(1 << pin));
62
+ }
63
+ }
64
+
65
+ bool CH422GComponent::read_inputs_() {
66
+ if (this->is_failed()) {
67
+ return false;
68
+ }
69
+
70
+ uint8_t temp = 0;
71
+ if ((this->last_error_ = this->read(&temp, 1)) != esphome::i2c::ERROR_OK) {
72
+ this->status_set_warning(str_sprintf("read_inputs_(): I2C I/O error: %d", (int) this->last_error_).c_str());
73
+ return false;
74
+ }
75
+
76
+ uint8_t output = 0;
77
+ if ((this->last_error_ = this->bus_->read(CH422G_REG_IN, &output, 1)) != esphome::i2c::ERROR_OK) {
78
+ this->status_set_warning(str_sprintf("read_inputs_(): I2C I/O error: %d", (int) this->last_error_).c_str());
79
+ return false;
80
+ }
81
+
82
+ this->state_mask_ = output;
83
+ this->status_clear_warning();
84
+
85
+ return true;
86
+ }
87
+
88
+ bool CH422GComponent::write_output_(uint8_t value) {
89
+ const uint8_t temp = 1;
90
+ if ((this->last_error_ = this->write(&temp, 1, false)) != esphome::i2c::ERROR_OK) {
91
+ this->status_set_warning(str_sprintf("write_output_(): I2C I/O error: %d", (int) this->last_error_).c_str());
92
+ return false;
93
+ }
94
+
95
+ uint8_t write_mask = value;
96
+ if ((this->last_error_ = this->bus_->write(CH422G_REG_OUT, &write_mask, 1)) != esphome::i2c::ERROR_OK) {
97
+ this->status_set_warning(
98
+ str_sprintf("write_output_(): I2C I/O error: %d for write_mask: %d", (int) this->last_error_, (int) write_mask)
99
+ .c_str());
100
+ return false;
101
+ }
102
+
103
+ this->state_mask_ = value;
104
+ this->status_clear_warning();
105
+ return true;
106
+ }
107
+
108
+ float CH422GComponent::get_setup_priority() const { return setup_priority::IO; }
109
+
110
+ // Run our loop() method very early in the loop, so that we cache read values
111
+ // before other components call our digital_read() method.
112
+ float CH422GComponent::get_loop_priority() const { return 9.0f; } // Just after WIFI
113
+
114
+ void CH422GGPIOPin::setup() { pin_mode(flags_); }
115
+ void CH422GGPIOPin::pin_mode(gpio::Flags flags) { this->parent_->pin_mode(this->pin_, flags); }
116
+ bool CH422GGPIOPin::digital_read() { return this->parent_->digital_read(this->pin_) != this->inverted_; }
117
+
118
+ void CH422GGPIOPin::digital_write(bool value) { this->parent_->digital_write(this->pin_, value != this->inverted_); }
119
+ std::string CH422GGPIOPin::dump_summary() const { return str_sprintf("EXIO%u via CH422G", pin_); }
120
+
121
+ } // namespace ch422g
122
+ } // namespace esphome
@@ -0,0 +1,70 @@
1
+ #pragma once
2
+
3
+ #include "esphome/core/component.h"
4
+ #include "esphome/core/hal.h"
5
+ #include "esphome/components/i2c/i2c.h"
6
+
7
+ namespace esphome {
8
+ namespace ch422g {
9
+
10
+ class CH422GComponent : public Component, public i2c::I2CDevice {
11
+ public:
12
+ CH422GComponent() = default;
13
+
14
+ /// Check i2c availability and setup masks
15
+ void setup() override;
16
+ /// Poll for input changes periodically
17
+ void loop() override;
18
+ /// Helper function to read the value of a pin.
19
+ bool digital_read(uint8_t pin);
20
+ /// Helper function to write the value of a pin.
21
+ void digital_write(uint8_t pin, bool value);
22
+ /// Helper function to set the pin mode of a pin.
23
+ void pin_mode(uint8_t pin, gpio::Flags flags);
24
+
25
+ float get_setup_priority() const override;
26
+
27
+ float get_loop_priority() const override;
28
+
29
+ void dump_config() override;
30
+
31
+ void set_restore_value(bool restore_value) { this->restore_value_ = restore_value; }
32
+
33
+ protected:
34
+ bool read_inputs_();
35
+
36
+ bool write_output_(uint8_t value);
37
+
38
+ /// The mask to write as output state - 1 means HIGH, 0 means LOW
39
+ uint8_t state_mask_{0x00};
40
+ /// Flags to check if read previously during this loop
41
+ uint8_t pin_read_cache_ = {0x00};
42
+ /// Storage for last I2C error seen
43
+ esphome::i2c::ErrorCode last_error_;
44
+ /// Whether we want to override stored values on expander
45
+ bool restore_value_{false};
46
+ };
47
+
48
+ /// Helper class to expose a CH422G pin as an internal input GPIO pin.
49
+ class CH422GGPIOPin : public GPIOPin {
50
+ public:
51
+ void setup() override;
52
+ void pin_mode(gpio::Flags flags) override;
53
+ bool digital_read() override;
54
+ void digital_write(bool value) override;
55
+ std::string dump_summary() const override;
56
+
57
+ void set_parent(CH422GComponent *parent) { parent_ = parent; }
58
+ void set_pin(uint8_t pin) { pin_ = pin; }
59
+ void set_inverted(bool inverted) { inverted_ = inverted; }
60
+ void set_flags(gpio::Flags flags) { flags_ = flags; }
61
+
62
+ protected:
63
+ CH422GComponent *parent_;
64
+ uint8_t pin_;
65
+ bool inverted_;
66
+ gpio::Flags flags_;
67
+ };
68
+
69
+ } // namespace ch422g
70
+ } // namespace esphome
@@ -16,6 +16,8 @@
16
16
  #include <esp32s2/rom/rtc.h>
17
17
  #elif defined(USE_ESP32_VARIANT_ESP32S3)
18
18
  #include <esp32s3/rom/rtc.h>
19
+ #elif defined(USE_ESP32_VARIANT_ESP32H2)
20
+ #include <esp32h2/rom/rtc.h>
19
21
  #endif
20
22
  #ifdef USE_ARDUINO
21
23
  #include <Esp.h>
@@ -61,7 +63,7 @@ std::string DebugComponent::get_reset_reason_() {
61
63
  case RTCWDT_SYS_RESET:
62
64
  reset_reason = "RTC Watch Dog Reset Digital Core";
63
65
  break;
64
- #if !defined(USE_ESP32_VARIANT_ESP32C6)
66
+ #if !defined(USE_ESP32_VARIANT_ESP32C6) && !defined(USE_ESP32_VARIANT_ESP32H2)
65
67
  case INTRUSION_RESET:
66
68
  reset_reason = "Intrusion Reset CPU";
67
69
  break;
@@ -1,15 +1,15 @@
1
+ from esphome import automation, core
2
+ from esphome.automation import maybe_simple_id
1
3
  import esphome.codegen as cg
2
4
  import esphome.config_validation as cv
3
- from esphome import core, automation
4
- from esphome.automation import maybe_simple_id
5
5
  from esphome.const import (
6
6
  CONF_AUTO_CLEAR_ENABLED,
7
+ CONF_FROM,
7
8
  CONF_ID,
8
9
  CONF_LAMBDA,
9
- CONF_PAGES,
10
10
  CONF_PAGE_ID,
11
+ CONF_PAGES,
11
12
  CONF_ROTATION,
12
- CONF_FROM,
13
13
  CONF_TO,
14
14
  CONF_TRIGGER_ID,
15
15
  )
@@ -195,3 +195,4 @@ async def display_is_displaying_page_to_code(config, condition_id, template_arg,
195
195
  @coroutine_with_priority(100.0)
196
196
  async def to_code(config):
197
197
  cg.add_global(display_ns.using)
198
+ cg.add_define("USE_DISPLAY")
@@ -256,6 +256,7 @@ bool Dsmr::parse_telegram() {
256
256
  MyData data;
257
257
  ESP_LOGV(TAG, "Trying to parse telegram");
258
258
  this->stop_requesting_data_();
259
+
259
260
  ::dsmr::ParseResult<void> res =
260
261
  ::dsmr::P1Parser::parse(&data, this->telegram_, this->bytes_read_, false,
261
262
  this->crc_check_); // Parse telegram according to data definition. Ignore unknown values.
@@ -267,6 +268,11 @@ bool Dsmr::parse_telegram() {
267
268
  } else {
268
269
  this->status_clear_warning();
269
270
  this->publish_sensors(data);
271
+
272
+ // publish the telegram, after publishing the sensors so it can also trigger action based on latest values
273
+ if (this->s_telegram_ != nullptr) {
274
+ this->s_telegram_->publish_state(std::string(this->telegram_, this->bytes_read_));
275
+ }
270
276
  return true;
271
277
  }
272
278
  }
@@ -85,6 +85,9 @@ class Dsmr : public Component, public uart::UARTDevice {
85
85
  void set_##s(text_sensor::TextSensor *sensor) { s_##s##_ = sensor; }
86
86
  DSMR_TEXT_SENSOR_LIST(DSMR_SET_TEXT_SENSOR, )
87
87
 
88
+ // handled outside dsmr
89
+ void set_telegram(text_sensor::TextSensor *sensor) { s_telegram_ = sensor; }
90
+
88
91
  protected:
89
92
  void receive_telegram_();
90
93
  void receive_encrypted_telegram_();
@@ -124,6 +127,9 @@ class Dsmr : public Component, public uart::UARTDevice {
124
127
  bool header_found_{false};
125
128
  bool footer_found_{false};
126
129
 
130
+ // handled outside dsmr
131
+ text_sensor::TextSensor *s_telegram_{nullptr};
132
+
127
133
  // Sensor member pointers
128
134
  #define DSMR_DECLARE_SENSOR(s) sensor::Sensor *s_##s##_{nullptr};
129
135
  DSMR_SENSOR_LIST(DSMR_DECLARE_SENSOR, )
@@ -1,7 +1,7 @@
1
1
  import esphome.codegen as cg
2
2
  import esphome.config_validation as cv
3
3
  from esphome.components import text_sensor
4
-
4
+ from esphome.const import CONF_INTERNAL
5
5
  from . import Dsmr, CONF_DSMR_ID
6
6
 
7
7
  AUTO_LOAD = ["dsmr"]
@@ -22,6 +22,9 @@ CONFIG_SCHEMA = cv.Schema(
22
22
  cv.Optional("water_equipment_id"): text_sensor.text_sensor_schema(),
23
23
  cv.Optional("sub_equipment_id"): text_sensor.text_sensor_schema(),
24
24
  cv.Optional("gas_delivered_text"): text_sensor.text_sensor_schema(),
25
+ cv.Optional("telegram"): text_sensor.text_sensor_schema().extend(
26
+ {cv.Optional(CONF_INTERNAL, default=True): cv.boolean}
27
+ ),
25
28
  }
26
29
  ).extend(cv.COMPONENT_SCHEMA)
27
30
 
@@ -37,7 +40,9 @@ async def to_code(config):
37
40
  if id and id.type == text_sensor.TextSensor:
38
41
  var = await text_sensor.new_text_sensor(conf)
39
42
  cg.add(getattr(hub, f"set_{key}")(var))
40
- text_sensors.append(f"F({key})")
43
+ if key != "telegram":
44
+ # telegram is not handled by dsmr
45
+ text_sensors.append(f"F({key})")
41
46
 
42
47
  if text_sensors:
43
48
  cg.add_define(
@@ -1,4 +1,5 @@
1
1
  #include "e131.h"
2
+ #ifdef USE_NETWORK
2
3
  #include "e131_addressable_light_effect.h"
3
4
  #include "esphome/core/log.h"
4
5
 
@@ -118,3 +119,4 @@ bool E131Component::process_(int universe, const E131Packet &packet) {
118
119
 
119
120
  } // namespace e131
120
121
  } // namespace esphome
122
+ #endif
@@ -1,5 +1,6 @@
1
1
  #pragma once
2
-
2
+ #include "esphome/core/defines.h"
3
+ #ifdef USE_NETWORK
3
4
  #include "esphome/components/socket/socket.h"
4
5
  #include "esphome/core/component.h"
5
6
 
@@ -53,3 +54,4 @@ class E131Component : public esphome::Component {
53
54
 
54
55
  } // namespace e131
55
56
  } // namespace esphome
57
+ #endif
@@ -1,5 +1,6 @@
1
1
  #include "e131_addressable_light_effect.h"
2
2
  #include "e131.h"
3
+ #ifdef USE_NETWORK
3
4
  #include "esphome/core/log.h"
4
5
 
5
6
  namespace esphome {
@@ -90,3 +91,4 @@ bool E131AddressableLightEffect::process_(int universe, const E131Packet &packet
90
91
 
91
92
  } // namespace e131
92
93
  } // namespace esphome
94
+ #endif
@@ -2,7 +2,7 @@
2
2
 
3
3
  #include "esphome/core/component.h"
4
4
  #include "esphome/components/light/addressable_light_effect.h"
5
-
5
+ #ifdef USE_NETWORK
6
6
  namespace esphome {
7
7
  namespace e131 {
8
8
 
@@ -42,3 +42,4 @@ class E131AddressableLightEffect : public light::AddressableLightEffect {
42
42
 
43
43
  } // namespace e131
44
44
  } // namespace esphome
45
+ #endif
@@ -1,5 +1,6 @@
1
1
  #include <cstring>
2
2
  #include "e131.h"
3
+ #ifdef USE_NETWORK
3
4
  #include "esphome/components/network/ip_address.h"
4
5
  #include "esphome/core/log.h"
5
6
  #include "esphome/core/util.h"
@@ -137,3 +138,4 @@ bool E131Component::packet_(const std::vector<uint8_t> &data, int &universe, E13
137
138
 
138
139
  } // namespace e131
139
140
  } // namespace esphome
141
+ #endif
@@ -140,6 +140,8 @@ CONF_TEST_PATTERN = "test_pattern"
140
140
  # framerates
141
141
  CONF_MAX_FRAMERATE = "max_framerate"
142
142
  CONF_IDLE_FRAMERATE = "idle_framerate"
143
+ # frame buffer
144
+ CONF_FRAME_BUFFER_COUNT = "frame_buffer_count"
143
145
 
144
146
  # stream trigger
145
147
  CONF_ON_STREAM_START = "on_stream_start"
@@ -213,6 +215,7 @@ CONFIG_SCHEMA = cv.ENTITY_BASE_SCHEMA.extend(
213
215
  cv.Optional(CONF_IDLE_FRAMERATE, default="0.1 fps"): cv.All(
214
216
  cv.framerate, cv.Range(min=0, max=1)
215
217
  ),
218
+ cv.Optional(CONF_FRAME_BUFFER_COUNT, default=1): cv.int_range(min=1, max=2),
216
219
  cv.Optional(CONF_ON_STREAM_START): automation.validate_automation(
217
220
  {
218
221
  cv.GenerateID(CONF_TRIGGER_ID): cv.declare_id(
@@ -285,6 +288,7 @@ async def to_code(config):
285
288
  cg.add(var.set_idle_update_interval(0))
286
289
  else:
287
290
  cg.add(var.set_idle_update_interval(1000 / config[CONF_IDLE_FRAMERATE]))
291
+ cg.add(var.set_frame_buffer_count(config[CONF_FRAME_BUFFER_COUNT]))
288
292
  cg.add(var.set_frame_size(config[CONF_RESOLUTION]))
289
293
 
290
294
  cg.add_define("USE_ESP32_CAMERA")
@@ -127,7 +127,7 @@ void ESP32Camera::dump_config() {
127
127
  sensor_t *s = esp_camera_sensor_get();
128
128
  auto st = s->status;
129
129
  ESP_LOGCONFIG(TAG, " JPEG Quality: %u", st.quality);
130
- // ESP_LOGCONFIG(TAG, " Framebuffer Count: %u", conf.fb_count);
130
+ ESP_LOGCONFIG(TAG, " Framebuffer Count: %u", conf.fb_count);
131
131
  ESP_LOGCONFIG(TAG, " Contrast: %d", st.contrast);
132
132
  ESP_LOGCONFIG(TAG, " Brightness: %d", st.brightness);
133
133
  ESP_LOGCONFIG(TAG, " Saturation: %d", st.saturation);
@@ -212,6 +212,8 @@ ESP32Camera::ESP32Camera() {
212
212
  this->config_.frame_size = FRAMESIZE_VGA; // 640x480
213
213
  this->config_.jpeg_quality = 10;
214
214
  this->config_.fb_count = 1;
215
+ this->config_.grab_mode = CAMERA_GRAB_WHEN_EMPTY;
216
+ this->config_.fb_location = CAMERA_FB_IN_PSRAM;
215
217
 
216
218
  global_esp32_camera = this;
217
219
  }
@@ -333,6 +335,12 @@ void ESP32Camera::set_max_update_interval(uint32_t max_update_interval) {
333
335
  void ESP32Camera::set_idle_update_interval(uint32_t idle_update_interval) {
334
336
  this->idle_update_interval_ = idle_update_interval;
335
337
  }
338
+ /* set frame buffer parameters */
339
+ void ESP32Camera::set_frame_buffer_mode(camera_grab_mode_t mode) { this->config_.grab_mode = mode; }
340
+ void ESP32Camera::set_frame_buffer_count(uint8_t fb_count) {
341
+ this->config_.fb_count = fb_count;
342
+ this->set_frame_buffer_mode(fb_count > 1 ? CAMERA_GRAB_LATEST : CAMERA_GRAB_WHEN_EMPTY);
343
+ }
336
344
 
337
345
  /* ---------------- public API (specific) ---------------- */
338
346
  void ESP32Camera::add_image_callback(std::function<void(std::shared_ptr<CameraImage>)> &&callback) {
@@ -145,6 +145,9 @@ class ESP32Camera : public Component, public EntityBase {
145
145
  /* -- framerates */
146
146
  void set_max_update_interval(uint32_t max_update_interval);
147
147
  void set_idle_update_interval(uint32_t idle_update_interval);
148
+ /* -- frame buffer */
149
+ void set_frame_buffer_mode(camera_grab_mode_t mode);
150
+ void set_frame_buffer_count(uint8_t fb_count);
148
151
 
149
152
  /* public API (derivated) */
150
153
  void setup() override;
@@ -1,18 +1,23 @@
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 canbus
5
- from esphome.const import CONF_ID, CONF_RX_PIN, CONF_TX_PIN
6
- from esphome.components.canbus import CanbusComponent, CanSpeed, CONF_BIT_RATE
7
-
4
+ from esphome.components.canbus import CONF_BIT_RATE, CanbusComponent, CanSpeed
8
5
  from esphome.components.esp32 import get_esp32_variant
9
6
  from esphome.components.esp32.const import (
10
7
  VARIANT_ESP32,
11
- VARIANT_ESP32S2,
12
- VARIANT_ESP32S3,
13
8
  VARIANT_ESP32C3,
14
9
  VARIANT_ESP32C6,
15
10
  VARIANT_ESP32H2,
11
+ VARIANT_ESP32S2,
12
+ VARIANT_ESP32S3,
13
+ )
14
+ import esphome.config_validation as cv
15
+ from esphome.const import (
16
+ CONF_ID,
17
+ CONF_RX_PIN,
18
+ CONF_RX_QUEUE_LEN,
19
+ CONF_TX_PIN,
20
+ CONF_TX_QUEUE_LEN,
16
21
  )
17
22
 
18
23
  CODEOWNERS = ["@Sympatron"]
@@ -77,6 +82,8 @@ CONFIG_SCHEMA = canbus.CANBUS_SCHEMA.extend(
77
82
  cv.Optional(CONF_BIT_RATE, default="125KBPS"): validate_bit_rate,
78
83
  cv.Required(CONF_RX_PIN): pins.internal_gpio_input_pin_number,
79
84
  cv.Required(CONF_TX_PIN): pins.internal_gpio_output_pin_number,
85
+ cv.Optional(CONF_RX_QUEUE_LEN): cv.uint32_t,
86
+ cv.Optional(CONF_TX_QUEUE_LEN): cv.uint32_t,
80
87
  }
81
88
  )
82
89
 
@@ -87,3 +94,7 @@ async def to_code(config):
87
94
 
88
95
  cg.add(var.set_rx(config[CONF_RX_PIN]))
89
96
  cg.add(var.set_tx(config[CONF_TX_PIN]))
97
+ if (rx_queue_len := config.get(CONF_RX_QUEUE_LEN)) is not None:
98
+ cg.add(var.set_rx_queue_len(rx_queue_len))
99
+ if (tx_queue_len := config.get(CONF_TX_QUEUE_LEN)) is not None:
100
+ cg.add(var.set_tx_queue_len(tx_queue_len))
@@ -69,6 +69,13 @@ static bool get_bitrate(canbus::CanSpeed bitrate, twai_timing_config_t *t_config
69
69
  bool ESP32Can::setup_internal() {
70
70
  twai_general_config_t g_config =
71
71
  TWAI_GENERAL_CONFIG_DEFAULT((gpio_num_t) this->tx_, (gpio_num_t) this->rx_, TWAI_MODE_NORMAL);
72
+ if (this->tx_queue_len_.has_value()) {
73
+ g_config.tx_queue_len = this->tx_queue_len_.value();
74
+ }
75
+ if (this->rx_queue_len_.has_value()) {
76
+ g_config.rx_queue_len = this->rx_queue_len_.value();
77
+ }
78
+
72
79
  twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
73
80
  twai_timing_config_t t_config;
74
81
 
@@ -111,6 +118,7 @@ canbus::Error ESP32Can::send_message(struct canbus::CanFrame *frame) {
111
118
  .flags = flags,
112
119
  .identifier = frame->can_id,
113
120
  .data_length_code = frame->can_data_length_code,
121
+ .data = {}, // to suppress warning, data is initialized properly below
114
122
  };
115
123
  if (!frame->remote_transmission_request) {
116
124
  memcpy(message.data, frame->data, frame->can_data_length_code);
@@ -12,6 +12,8 @@ class ESP32Can : public canbus::Canbus {
12
12
  public:
13
13
  void set_rx(int rx) { rx_ = rx; }
14
14
  void set_tx(int tx) { tx_ = tx; }
15
+ void set_tx_queue_len(uint32_t tx_queue_len) { this->tx_queue_len_ = tx_queue_len; }
16
+ void set_rx_queue_len(uint32_t rx_queue_len) { this->rx_queue_len_ = rx_queue_len; }
15
17
  ESP32Can(){};
16
18
 
17
19
  protected:
@@ -21,6 +23,8 @@ class ESP32Can : public canbus::Canbus {
21
23
 
22
24
  int rx_{-1};
23
25
  int tx_{-1};
26
+ optional<uint32_t> tx_queue_len_{};
27
+ optional<uint32_t> rx_queue_len_{};
24
28
  };
25
29
 
26
30
  } // namespace esp32_can