esphome 2025.9.3__py3-none-any.whl → 2025.10.0b2__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 (351) hide show
  1. esphome/__main__.py +94 -31
  2. esphome/address_cache.py +142 -0
  3. esphome/automation.py +130 -32
  4. esphome/build_gen/platformio.py +1 -3
  5. esphome/codegen.py +1 -0
  6. esphome/components/animation/animation.cpp +2 -2
  7. esphome/components/api/__init__.py +166 -3
  8. esphome/components/api/api_connection.cpp +84 -41
  9. esphome/components/api/api_connection.h +22 -16
  10. esphome/components/api/api_frame_helper.cpp +33 -19
  11. esphome/components/api/api_frame_helper.h +19 -4
  12. esphome/components/api/api_frame_helper_noise.cpp +41 -53
  13. esphome/components/api/api_frame_helper_noise.h +1 -1
  14. esphome/components/api/api_frame_helper_plaintext.cpp +22 -31
  15. esphome/components/api/api_frame_helper_plaintext.h +1 -1
  16. esphome/components/api/api_pb2.cpp +189 -15
  17. esphome/components/api/api_pb2.h +132 -20
  18. esphome/components/api/api_pb2_dump.cpp +97 -9
  19. esphome/components/api/api_pb2_service.cpp +118 -160
  20. esphome/components/api/api_pb2_service.h +31 -3
  21. esphome/components/api/api_server.cpp +68 -10
  22. esphome/components/api/api_server.h +32 -4
  23. esphome/components/api/custom_api_device.h +8 -8
  24. esphome/components/api/homeassistant_service.h +123 -6
  25. esphome/components/api/proto.h +6 -2
  26. esphome/components/api/user_services.h +2 -2
  27. esphome/components/as7341/sensor.py +1 -1
  28. esphome/components/audio/__init__.py +1 -1
  29. esphome/components/audio/audio.cpp +1 -1
  30. esphome/components/audio/audio_decoder.cpp +9 -9
  31. esphome/components/bl0906/bl0906.cpp +2 -2
  32. esphome/components/bl0942/bl0942.cpp +2 -2
  33. esphome/components/ble_client/__init__.py +1 -1
  34. esphome/components/bluetooth_proxy/__init__.py +4 -30
  35. esphome/components/bluetooth_proxy/bluetooth_connection.cpp +11 -4
  36. esphome/components/bluetooth_proxy/bluetooth_connection.h +2 -2
  37. esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +2 -2
  38. esphome/components/camera_encoder/__init__.py +2 -4
  39. esphome/components/camera_encoder/esp32_camera_jpeg_encoder.cpp +4 -2
  40. esphome/components/camera_encoder/esp32_camera_jpeg_encoder.h +3 -1
  41. esphome/components/canbus/canbus.cpp +7 -5
  42. esphome/components/canbus/canbus.h +7 -7
  43. esphome/components/captive_portal/__init__.py +18 -1
  44. esphome/components/captive_portal/captive_portal.cpp +40 -46
  45. esphome/components/captive_portal/captive_portal.h +20 -22
  46. esphome/components/captive_portal/dns_server_esp32_idf.cpp +205 -0
  47. esphome/components/captive_portal/dns_server_esp32_idf.h +27 -0
  48. esphome/components/ccs811/ccs811.cpp +1 -1
  49. esphome/components/climate/climate.cpp +10 -7
  50. esphome/components/cm1106/cm1106.cpp +1 -1
  51. esphome/components/copy/lock/copy_lock.cpp +1 -1
  52. esphome/components/cover/cover.cpp +1 -0
  53. esphome/components/daikin_arc/daikin_arc.cpp +19 -12
  54. esphome/components/dashboard_import/dashboard_import.cpp +1 -1
  55. esphome/components/dashboard_import/dashboard_import.h +1 -1
  56. esphome/components/deep_sleep/__init__.py +9 -2
  57. esphome/components/deep_sleep/deep_sleep_component.h +11 -9
  58. esphome/components/deep_sleep/deep_sleep_esp32.cpp +51 -27
  59. esphome/components/ektf2232/touchscreen/__init__.py +8 -5
  60. esphome/components/ektf2232/touchscreen/ektf2232.cpp +4 -4
  61. esphome/components/ektf2232/touchscreen/ektf2232.h +2 -2
  62. esphome/components/epaper_spi/__init__.py +1 -0
  63. esphome/components/epaper_spi/display.py +80 -0
  64. esphome/components/epaper_spi/epaper_spi.cpp +227 -0
  65. esphome/components/epaper_spi/epaper_spi.h +93 -0
  66. esphome/components/epaper_spi/epaper_spi_model_7p3in_spectra_e6.cpp +42 -0
  67. esphome/components/epaper_spi/epaper_spi_model_7p3in_spectra_e6.h +45 -0
  68. esphome/components/epaper_spi/epaper_spi_spectra_e6.cpp +135 -0
  69. esphome/components/epaper_spi/epaper_spi_spectra_e6.h +23 -0
  70. esphome/components/es7210/es7210.cpp +3 -3
  71. esphome/components/esp32/__init__.py +256 -340
  72. esphome/components/esp32/boards.py +81 -0
  73. esphome/components/esp32/preferences.cpp +23 -17
  74. esphome/components/esp32_ble/__init__.py +167 -44
  75. esphome/components/esp32_ble/ble.cpp +47 -3
  76. esphome/components/esp32_ble/ble.h +18 -0
  77. esphome/components/esp32_ble/ble_advertising.cpp +7 -3
  78. esphome/components/esp32_ble/ble_advertising.h +4 -0
  79. esphome/components/esp32_ble/ble_uuid.cpp +16 -42
  80. esphome/components/esp32_ble_beacon/__init__.py +3 -4
  81. esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +0 -4
  82. esphome/components/esp32_ble_client/ble_client_base.cpp +14 -12
  83. esphome/components/esp32_ble_server/__init__.py +28 -14
  84. esphome/components/esp32_ble_server/ble_characteristic.cpp +67 -57
  85. esphome/components/esp32_ble_server/ble_characteristic.h +27 -16
  86. esphome/components/esp32_ble_server/ble_descriptor.cpp +4 -3
  87. esphome/components/esp32_ble_server/ble_descriptor.h +13 -9
  88. esphome/components/esp32_ble_server/ble_server.cpp +59 -24
  89. esphome/components/esp32_ble_server/ble_server.h +38 -20
  90. esphome/components/esp32_ble_server/ble_server_automations.cpp +49 -33
  91. esphome/components/esp32_ble_server/ble_server_automations.h +39 -24
  92. esphome/components/esp32_ble_tracker/__init__.py +25 -80
  93. esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +2 -8
  94. esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +0 -3
  95. esphome/components/esp32_camera/__init__.py +1 -3
  96. esphome/components/esp32_can/esp32_can.cpp +22 -4
  97. esphome/components/esp32_can/esp32_can.h +3 -0
  98. esphome/components/esp32_hosted/__init__.py +2 -1
  99. esphome/components/esp32_improv/esp32_improv_component.cpp +135 -65
  100. esphome/components/esp32_improv/esp32_improv_component.h +7 -1
  101. esphome/components/esp32_rmt_led_strip/led_strip.cpp +1 -1
  102. esphome/components/esp8266/__init__.py +3 -3
  103. esphome/components/esphome/ota/__init__.py +21 -2
  104. esphome/components/esphome/ota/ota_esphome.cpp +456 -146
  105. esphome/components/esphome/ota/ota_esphome.h +49 -2
  106. esphome/components/ethernet/__init__.py +39 -22
  107. esphome/components/ethernet/ethernet_component.cpp +28 -5
  108. esphome/components/ethernet/ethernet_component.h +5 -1
  109. esphome/components/external_components/__init__.py +8 -6
  110. esphome/components/fingerprint_grow/fingerprint_grow.cpp +1 -1
  111. esphome/components/fingerprint_grow/fingerprint_grow.h +2 -1
  112. esphome/components/font/__init__.py +5 -5
  113. esphome/components/graph/graph.cpp +1 -1
  114. esphome/components/graphical_display_menu/graphical_display_menu.cpp +3 -2
  115. esphome/components/haier/hon_climate.cpp +2 -2
  116. esphome/components/haier/hon_climate.h +1 -1
  117. esphome/components/hdc1080/hdc1080.cpp +42 -34
  118. esphome/components/hdc1080/hdc1080.h +1 -3
  119. esphome/components/homeassistant/number/homeassistant_number.cpp +2 -2
  120. esphome/components/homeassistant/switch/homeassistant_switch.cpp +2 -2
  121. esphome/components/http_request/__init__.py +3 -3
  122. esphome/components/htu21d/htu21d.cpp +13 -18
  123. esphome/components/htu21d/htu21d.h +1 -1
  124. esphome/components/i2s_audio/__init__.py +1 -2
  125. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +1 -1
  126. esphome/components/ili9xxx/ili9xxx_display.cpp +2 -2
  127. esphome/components/improv_serial/improv_serial_component.cpp +12 -15
  128. esphome/components/improv_serial/improv_serial_component.h +6 -8
  129. esphome/components/json/json_util.cpp +42 -44
  130. esphome/components/json/json_util.h +57 -0
  131. esphome/components/kamstrup_kmp/kamstrup_kmp.cpp +2 -2
  132. esphome/components/key_collector/key_collector.h +4 -4
  133. esphome/components/libretiny/__init__.py +6 -6
  134. esphome/components/libretiny/preferences.cpp +23 -16
  135. esphome/components/light/light_call.cpp +98 -120
  136. esphome/components/light/light_call.h +17 -7
  137. esphome/components/lm75b/__init__.py +0 -0
  138. esphome/components/lm75b/lm75b.cpp +39 -0
  139. esphome/components/lm75b/lm75b.h +19 -0
  140. esphome/components/lm75b/sensor.py +34 -0
  141. esphome/components/lock/lock.h +12 -6
  142. esphome/components/logger/__init__.py +15 -27
  143. esphome/components/logger/logger.cpp +10 -20
  144. esphome/components/logger/logger.h +105 -62
  145. esphome/components/logger/logger_esp32.cpp +0 -48
  146. esphome/components/logger/logger_zephyr.cpp +2 -3
  147. esphome/components/logger/select/logger_level_select.cpp +6 -7
  148. esphome/components/logger/select/logger_level_select.h +7 -0
  149. esphome/components/ltr501/ltr501.cpp +7 -6
  150. esphome/components/ltr_als_ps/ltr_als_ps.cpp +7 -6
  151. esphome/components/matrix_keypad/matrix_keypad.h +4 -4
  152. esphome/components/max7219digit/max7219digit.cpp +1 -1
  153. esphome/components/mcp23xxx_base/mcp23xxx_base.h +3 -3
  154. esphome/components/mcp2515/mcp2515.cpp +31 -3
  155. esphome/components/mcp2515/mcp2515_defs.h +3 -1
  156. esphome/components/md5/md5.cpp +0 -26
  157. esphome/components/md5/md5.h +10 -20
  158. esphome/components/mdns/__init__.py +93 -19
  159. esphome/components/mdns/mdns_component.cpp +57 -94
  160. esphome/components/mdns/mdns_component.h +35 -11
  161. esphome/components/mdns/mdns_esp32.cpp +7 -13
  162. esphome/components/mdns/mdns_esp8266.cpp +7 -7
  163. esphome/components/mdns/mdns_libretiny.cpp +3 -4
  164. esphome/components/mdns/mdns_rp2040.cpp +3 -4
  165. esphome/components/mipi/__init__.py +1 -5
  166. esphome/components/mipi_spi/display.py +24 -8
  167. esphome/components/mipi_spi/mipi_spi.h +3 -3
  168. esphome/components/mixer/speaker/mixer_speaker.cpp +3 -3
  169. esphome/components/mmc5603/mmc5603.cpp +3 -3
  170. esphome/components/modbus/modbus.cpp +27 -13
  171. esphome/components/modbus/modbus.h +5 -3
  172. esphome/components/modbus/modbus_definitions.h +86 -0
  173. esphome/components/modbus_controller/__init__.py +29 -1
  174. esphome/components/modbus_controller/const.py +4 -0
  175. esphome/components/modbus_controller/modbus_controller.cpp +38 -13
  176. esphome/components/modbus_controller/modbus_controller.h +18 -29
  177. esphome/components/mpr121/mpr121.cpp +41 -42
  178. esphome/components/mpr121/mpr121.h +0 -1
  179. esphome/components/nau7802/nau7802.cpp +2 -2
  180. esphome/components/network/__init__.py +7 -3
  181. esphome/components/nextion/display.py +4 -4
  182. esphome/components/nextion/nextion.cpp +8 -8
  183. esphome/components/number/__init__.py +2 -0
  184. esphome/components/number/number_call.cpp +23 -12
  185. esphome/components/number/number_call.h +5 -0
  186. esphome/components/online_image/bmp_image.cpp +2 -1
  187. esphome/components/online_image/jpeg_image.cpp +4 -2
  188. esphome/components/opentherm/opentherm.cpp +5 -5
  189. esphome/components/opentherm/opentherm.h +3 -3
  190. esphome/components/openthread/openthread.cpp +11 -10
  191. esphome/components/openthread/openthread.h +0 -1
  192. esphome/components/ota/ota_backend.h +1 -0
  193. esphome/components/packages/__init__.py +10 -8
  194. esphome/components/packet_transport/packet_transport.cpp +2 -0
  195. esphome/components/pid/pid_controller.cpp +1 -1
  196. esphome/components/prometheus/prometheus_handler.cpp +239 -239
  197. esphome/components/psram/__init__.py +30 -28
  198. esphome/components/qmc5883l/qmc5883l.cpp +15 -0
  199. esphome/components/qmc5883l/qmc5883l.h +3 -0
  200. esphome/components/qmc5883l/sensor.py +31 -12
  201. esphome/components/remote_base/gobox_protocol.cpp +3 -3
  202. esphome/components/remote_receiver/__init__.py +14 -2
  203. esphome/components/remote_receiver/{remote_receiver_esp8266.cpp → remote_receiver.cpp} +2 -2
  204. esphome/components/remote_receiver/remote_receiver.h +4 -0
  205. esphome/components/remote_receiver/remote_receiver_esp32.cpp +18 -1
  206. esphome/components/remote_transmitter/__init__.py +2 -2
  207. esphome/components/remote_transmitter/remote_transmitter.cpp +103 -0
  208. esphome/components/rp2040/__init__.py +11 -11
  209. esphome/components/rtttl/rtttl.cpp +2 -2
  210. esphome/components/scd30/sensor.py +1 -1
  211. esphome/components/script/__init__.py +1 -1
  212. esphome/components/script/script.h +7 -7
  213. esphome/components/select/select.cpp +5 -4
  214. esphome/components/select/select_call.cpp +1 -1
  215. esphome/components/sensirion_common/i2c_sensirion.cpp +2 -1
  216. esphome/components/sensor/__init__.py +2 -0
  217. esphome/components/sha256/__init__.py +22 -0
  218. esphome/components/sha256/sha256.cpp +116 -0
  219. esphome/components/sha256/sha256.h +60 -0
  220. esphome/components/socket/lwip_raw_tcp_impl.cpp +34 -6
  221. esphome/components/sonoff_d1/sonoff_d1.cpp +1 -1
  222. esphome/components/spi/__init__.py +0 -3
  223. esphome/components/split_buffer/__init__.py +5 -0
  224. esphome/components/split_buffer/split_buffer.cpp +133 -0
  225. esphome/components/split_buffer/split_buffer.h +40 -0
  226. esphome/components/sps30/sps30.cpp +14 -10
  227. esphome/components/sps30/sps30.h +2 -0
  228. esphome/components/st7567_i2c/st7567_i2c.cpp +3 -1
  229. esphome/components/st7789v/st7789v.cpp +3 -2
  230. esphome/components/statsd/statsd.cpp +1 -1
  231. esphome/components/substitutions/__init__.py +3 -1
  232. esphome/components/substitutions/jinja.py +13 -3
  233. esphome/components/sx126x/__init__.py +16 -0
  234. esphome/components/sx126x/sx126x.cpp +15 -1
  235. esphome/components/sx126x/sx126x.h +9 -1
  236. esphome/components/sx126x/sx126x_reg.h +2 -0
  237. esphome/components/text_sensor/text_sensor.cpp +16 -0
  238. esphome/components/text_sensor/text_sensor.h +3 -10
  239. esphome/components/tormatic/tormatic_cover.cpp +1 -1
  240. esphome/components/tuya/select/tuya_select.cpp +1 -1
  241. esphome/components/tuya/tuya.cpp +29 -4
  242. esphome/components/uart/__init__.py +37 -27
  243. esphome/components/uart/uart.h +6 -0
  244. esphome/components/uart/uart_component.cpp +8 -0
  245. esphome/components/uart/uart_component.h +28 -0
  246. esphome/components/uart/uart_component_esp_idf.cpp +64 -10
  247. esphome/components/uart/uart_component_esp_idf.h +5 -2
  248. esphome/components/uponor_smatrix/climate/uponor_smatrix_climate.cpp +1 -1
  249. esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp +1 -1
  250. esphome/components/uponor_smatrix/uponor_smatrix.cpp +3 -3
  251. esphome/components/usb_host/__init__.py +12 -2
  252. esphome/components/usb_host/usb_host.h +89 -14
  253. esphome/components/usb_host/usb_host_client.cpp +157 -22
  254. esphome/components/usb_host/usb_host_component.cpp +1 -1
  255. esphome/components/usb_uart/__init__.py +0 -1
  256. esphome/components/usb_uart/ch34x.cpp +4 -4
  257. esphome/components/usb_uart/cp210x.cpp +3 -3
  258. esphome/components/usb_uart/usb_uart.cpp +88 -32
  259. esphome/components/usb_uart/usb_uart.h +30 -6
  260. esphome/components/valve/valve.cpp +1 -0
  261. esphome/components/veml7700/veml7700.cpp +7 -6
  262. esphome/components/version/version_text_sensor.cpp +2 -1
  263. esphome/components/voice_assistant/voice_assistant.cpp +3 -2
  264. esphome/components/waveshare_epaper/waveshare_epaper.cpp +4 -4
  265. esphome/components/web_server/list_entities.cpp +3 -4
  266. esphome/components/web_server/list_entities.h +8 -10
  267. esphome/components/web_server/ota/__init__.py +1 -1
  268. esphome/components/web_server/ota/ota_web_server.cpp +9 -3
  269. esphome/components/web_server/web_server.cpp +509 -404
  270. esphome/components/web_server/web_server.h +5 -6
  271. esphome/components/web_server/web_server_v1.cpp +21 -19
  272. esphome/components/web_server_base/__init__.py +5 -2
  273. esphome/components/web_server_base/web_server_base.h +27 -7
  274. esphome/components/web_server_idf/__init__.py +1 -1
  275. esphome/components/web_server_idf/multipart.cpp +2 -2
  276. esphome/components/web_server_idf/multipart.h +2 -2
  277. esphome/components/web_server_idf/utils.cpp +2 -2
  278. esphome/components/web_server_idf/utils.h +2 -2
  279. esphome/components/web_server_idf/web_server_idf.cpp +118 -26
  280. esphome/components/web_server_idf/web_server_idf.h +12 -10
  281. esphome/components/wifi/__init__.py +13 -11
  282. esphome/components/wifi/wifi_component.cpp +74 -56
  283. esphome/components/wifi/wifi_component.h +4 -4
  284. esphome/components/wifi/wifi_component_esp8266.cpp +1 -1
  285. esphome/components/wifi/wifi_component_esp_idf.cpp +24 -4
  286. esphome/components/wireguard/__init__.py +1 -1
  287. esphome/components/wts01/__init__.py +0 -0
  288. esphome/components/wts01/sensor.py +41 -0
  289. esphome/components/wts01/wts01.cpp +91 -0
  290. esphome/components/wts01/wts01.h +27 -0
  291. esphome/components/zephyr/__init__.py +5 -5
  292. esphome/components/zwave_proxy/__init__.py +43 -0
  293. esphome/components/zwave_proxy/zwave_proxy.cpp +346 -0
  294. esphome/components/zwave_proxy/zwave_proxy.h +93 -0
  295. esphome/config.py +79 -24
  296. esphome/config_validation.py +13 -15
  297. esphome/const.py +9 -2
  298. esphome/core/__init__.py +33 -22
  299. esphome/core/component.cpp +28 -18
  300. esphome/core/component_iterator.h +2 -1
  301. esphome/core/config.py +15 -15
  302. esphome/core/defines.h +21 -0
  303. esphome/core/entity_helpers.py +9 -6
  304. esphome/core/hash_base.h +56 -0
  305. esphome/core/helpers.cpp +19 -3
  306. esphome/core/helpers.h +26 -0
  307. esphome/core/scheduler.cpp +5 -21
  308. esphome/core/scheduler.h +19 -8
  309. esphome/core/string_ref.h +1 -1
  310. esphome/core/time.cpp +5 -5
  311. esphome/cpp_generator.py +4 -29
  312. esphome/dashboard/const.py +21 -4
  313. esphome/dashboard/core.py +10 -8
  314. esphome/dashboard/dns.py +15 -0
  315. esphome/dashboard/entries.py +15 -21
  316. esphome/dashboard/models.py +76 -0
  317. esphome/dashboard/settings.py +7 -7
  318. esphome/dashboard/status/mdns.py +46 -2
  319. esphome/dashboard/web_server.py +367 -93
  320. esphome/espota2.py +112 -32
  321. esphome/external_files.py +6 -7
  322. esphome/git.py +8 -0
  323. esphome/helpers.py +124 -77
  324. esphome/loader.py +8 -9
  325. esphome/pins.py +2 -2
  326. esphome/platformio_api.py +56 -18
  327. esphome/storage_json.py +26 -21
  328. esphome/types.py +30 -2
  329. esphome/util.py +32 -16
  330. esphome/vscode.py +8 -8
  331. esphome/wizard.py +10 -10
  332. esphome/writer.py +50 -15
  333. esphome/yaml_util.py +37 -31
  334. esphome/zeroconf.py +12 -3
  335. {esphome-2025.9.3.dist-info → esphome-2025.10.0b2.dist-info}/METADATA +12 -12
  336. {esphome-2025.9.3.dist-info → esphome-2025.10.0b2.dist-info}/RECORD +340 -320
  337. esphome/components/event_emitter/__init__.py +0 -5
  338. esphome/components/event_emitter/event_emitter.cpp +0 -14
  339. esphome/components/event_emitter/event_emitter.h +0 -63
  340. esphome/components/remote_receiver/remote_receiver_libretiny.cpp +0 -125
  341. esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +0 -107
  342. esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +0 -110
  343. esphome/components/uart/uart_component_esp32_arduino.cpp +0 -214
  344. esphome/components/uart/uart_component_esp32_arduino.h +0 -60
  345. esphome/components/wifi/wifi_component_esp32_arduino.cpp +0 -860
  346. esphome/core/string_ref.cpp +0 -12
  347. esphome/dashboard/util/file.py +0 -63
  348. {esphome-2025.9.3.dist-info → esphome-2025.10.0b2.dist-info}/WHEEL +0 -0
  349. {esphome-2025.9.3.dist-info → esphome-2025.10.0b2.dist-info}/entry_points.txt +0 -0
  350. {esphome-2025.9.3.dist-info → esphome-2025.10.0b2.dist-info}/licenses/LICENSE +0 -0
  351. {esphome-2025.9.3.dist-info → esphome-2025.10.0b2.dist-info}/top_level.txt +0 -0
@@ -112,6 +112,12 @@ void ModbusController::on_modbus_read_registers(uint8_t function_code, uint16_t
112
112
  "0x%X.",
113
113
  this->address_, function_code, start_address, number_of_registers);
114
114
 
115
+ if (number_of_registers == 0 || number_of_registers > modbus::MAX_NUM_OF_REGISTERS_TO_READ) {
116
+ ESP_LOGW(TAG, "Invalid number of registers %d. Sending exception response.", number_of_registers);
117
+ this->send_error(function_code, ModbusExceptionCode::ILLEGAL_DATA_ADDRESS);
118
+ return;
119
+ }
120
+
115
121
  std::vector<uint16_t> sixteen_bit_response;
116
122
  for (uint16_t current_address = start_address; current_address < start_address + number_of_registers;) {
117
123
  bool found = false;
@@ -136,9 +142,21 @@ void ModbusController::on_modbus_read_registers(uint8_t function_code, uint16_t
136
142
  }
137
143
 
138
144
  if (!found) {
139
- ESP_LOGW(TAG, "Could not match any register to address %02X. Sending exception response.", current_address);
140
- send_error(function_code, 0x02);
141
- return;
145
+ if (this->server_courtesy_response_.enabled &&
146
+ (current_address <= this->server_courtesy_response_.register_last_address)) {
147
+ ESP_LOGD(TAG,
148
+ "Could not match any register to address 0x%02X, but default allowed. "
149
+ "Returning default value: %d.",
150
+ current_address, this->server_courtesy_response_.register_value);
151
+ sixteen_bit_response.push_back(this->server_courtesy_response_.register_value);
152
+ current_address += 1; // Just increment by 1, as the default response is a single register
153
+ } else {
154
+ ESP_LOGW(TAG,
155
+ "Could not match any register to address 0x%02X and default not allowed. Sending exception response.",
156
+ current_address);
157
+ this->send_error(function_code, ModbusExceptionCode::ILLEGAL_DATA_ADDRESS);
158
+ return;
159
+ }
142
160
  }
143
161
  }
144
162
 
@@ -156,27 +174,27 @@ void ModbusController::on_modbus_write_registers(uint8_t function_code, const st
156
174
  uint16_t number_of_registers;
157
175
  uint16_t payload_offset;
158
176
 
159
- if (function_code == 0x10) {
177
+ if (function_code == ModbusFunctionCode::WRITE_MULTIPLE_REGISTERS) {
160
178
  number_of_registers = uint16_t(data[3]) | (uint16_t(data[2]) << 8);
161
- if (number_of_registers == 0 || number_of_registers > 0x7B) {
179
+ if (number_of_registers == 0 || number_of_registers > modbus::MAX_NUM_OF_REGISTERS_TO_WRITE) {
162
180
  ESP_LOGW(TAG, "Invalid number of registers %d. Sending exception response.", number_of_registers);
163
- send_error(function_code, 3);
181
+ this->send_error(function_code, ModbusExceptionCode::ILLEGAL_DATA_VALUE);
164
182
  return;
165
183
  }
166
184
  uint16_t payload_size = data[4];
167
185
  if (payload_size != number_of_registers * 2) {
168
186
  ESP_LOGW(TAG, "Payload size of %d bytes is not 2 times the number of registers (%d). Sending exception response.",
169
187
  payload_size, number_of_registers);
170
- send_error(function_code, 3);
188
+ this->send_error(function_code, ModbusExceptionCode::ILLEGAL_DATA_VALUE);
171
189
  return;
172
190
  }
173
191
  payload_offset = 5;
174
- } else if (function_code == 0x06) {
192
+ } else if (function_code == ModbusFunctionCode::WRITE_SINGLE_REGISTER) {
175
193
  number_of_registers = 1;
176
194
  payload_offset = 2;
177
195
  } else {
178
196
  ESP_LOGW(TAG, "Invalid function code 0x%X. Sending exception response.", function_code);
179
- send_error(function_code, 1);
197
+ this->send_error(function_code, ModbusExceptionCode::ILLEGAL_FUNCTION);
180
198
  return;
181
199
  }
182
200
 
@@ -211,7 +229,7 @@ void ModbusController::on_modbus_write_registers(uint8_t function_code, const st
211
229
  if (!for_each_register([](ServerRegister *server_register, uint16_t offset) -> bool {
212
230
  return server_register->write_lambda != nullptr;
213
231
  })) {
214
- send_error(function_code, 1);
232
+ this->send_error(function_code, ModbusExceptionCode::ILLEGAL_FUNCTION);
215
233
  return;
216
234
  }
217
235
 
@@ -220,7 +238,7 @@ void ModbusController::on_modbus_write_registers(uint8_t function_code, const st
220
238
  int64_t number = payload_to_number(data, server_register->value_type, offset, 0xFFFFFFFF);
221
239
  return server_register->write_lambda(number);
222
240
  })) {
223
- send_error(function_code, 4);
241
+ this->send_error(function_code, ModbusExceptionCode::SERVICE_DEVICE_FAILURE);
224
242
  return;
225
243
  }
226
244
 
@@ -431,8 +449,15 @@ void ModbusController::dump_config() {
431
449
  "ModbusController:\n"
432
450
  " Address: 0x%02X\n"
433
451
  " Max Command Retries: %d\n"
434
- " Offline Skip Updates: %d",
435
- this->address_, this->max_cmd_retries_, this->offline_skip_updates_);
452
+ " Offline Skip Updates: %d\n"
453
+ " Server Courtesy Response:\n"
454
+ " Enabled: %s\n"
455
+ " Register Last Address: 0x%02X\n"
456
+ " Register Value: %d",
457
+ this->address_, this->max_cmd_retries_, this->offline_skip_updates_,
458
+ this->server_courtesy_response_.enabled ? "true" : "false",
459
+ this->server_courtesy_response_.register_last_address, this->server_courtesy_response_.register_value);
460
+
436
461
  #if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE
437
462
  ESP_LOGCONFIG(TAG, "sensormap");
438
463
  for (auto &it : this->sensorset_) {
@@ -16,35 +16,9 @@ namespace modbus_controller {
16
16
 
17
17
  class ModbusController;
18
18
 
19
- enum class ModbusFunctionCode {
20
- CUSTOM = 0x00,
21
- READ_COILS = 0x01,
22
- READ_DISCRETE_INPUTS = 0x02,
23
- READ_HOLDING_REGISTERS = 0x03,
24
- READ_INPUT_REGISTERS = 0x04,
25
- WRITE_SINGLE_COIL = 0x05,
26
- WRITE_SINGLE_REGISTER = 0x06,
27
- READ_EXCEPTION_STATUS = 0x07, // not implemented
28
- DIAGNOSTICS = 0x08, // not implemented
29
- GET_COMM_EVENT_COUNTER = 0x0B, // not implemented
30
- GET_COMM_EVENT_LOG = 0x0C, // not implemented
31
- WRITE_MULTIPLE_COILS = 0x0F,
32
- WRITE_MULTIPLE_REGISTERS = 0x10,
33
- REPORT_SERVER_ID = 0x11, // not implemented
34
- READ_FILE_RECORD = 0x14, // not implemented
35
- WRITE_FILE_RECORD = 0x15, // not implemented
36
- MASK_WRITE_REGISTER = 0x16, // not implemented
37
- READ_WRITE_MULTIPLE_REGISTERS = 0x17, // not implemented
38
- READ_FIFO_QUEUE = 0x18, // not implemented
39
- };
40
-
41
- enum class ModbusRegisterType : uint8_t {
42
- CUSTOM = 0x0,
43
- COIL = 0x01,
44
- DISCRETE_INPUT = 0x02,
45
- HOLDING = 0x03,
46
- READ = 0x04,
47
- };
19
+ using modbus::ModbusFunctionCode;
20
+ using modbus::ModbusRegisterType;
21
+ using modbus::ModbusExceptionCode;
48
22
 
49
23
  enum class SensorValueType : uint8_t {
50
24
  RAW = 0x00, // variable length
@@ -256,6 +230,12 @@ class SensorItem {
256
230
  bool force_new_range{false};
257
231
  };
258
232
 
233
+ struct ServerCourtesyResponse {
234
+ bool enabled{false};
235
+ uint16_t register_last_address{0xFFFF};
236
+ uint16_t register_value{0};
237
+ };
238
+
259
239
  class ServerRegister {
260
240
  using ReadLambda = std::function<int64_t()>;
261
241
  using WriteLambda = std::function<bool(int64_t value)>;
@@ -530,6 +510,12 @@ class ModbusController : public PollingComponent, public modbus::ModbusDevice {
530
510
  void set_max_cmd_retries(uint8_t max_cmd_retries) { this->max_cmd_retries_ = max_cmd_retries; }
531
511
  /// get how many times a command will be (re)sent if no response is received
532
512
  uint8_t get_max_cmd_retries() { return this->max_cmd_retries_; }
513
+ /// Called by esphome generated code to set the server courtesy response object
514
+ void set_server_courtesy_response(const ServerCourtesyResponse &server_courtesy_response) {
515
+ this->server_courtesy_response_ = server_courtesy_response;
516
+ }
517
+ /// Get the server courtesy response object
518
+ ServerCourtesyResponse get_server_courtesy_response() const { return this->server_courtesy_response_; }
533
519
 
534
520
  protected:
535
521
  /// parse sensormap_ and create range of sequential addresses
@@ -572,6 +558,9 @@ class ModbusController : public PollingComponent, public modbus::ModbusDevice {
572
558
  CallbackManager<void(int, int)> online_callback_{};
573
559
  /// Server offline callback
574
560
  CallbackManager<void(int, int)> offline_callback_{};
561
+ /// Server courtesy response
562
+ ServerCourtesyResponse server_courtesy_response_{
563
+ .enabled = false, .register_last_address = 0xFFFF, .register_value = 0};
575
564
  };
576
565
 
577
566
  /** Convert vector<uint8_t> response payload to float.
@@ -11,47 +11,49 @@ namespace mpr121 {
11
11
  static const char *const TAG = "mpr121";
12
12
 
13
13
  void MPR121Component::setup() {
14
+ this->disable_loop();
14
15
  // soft reset device
15
16
  this->write_byte(MPR121_SOFTRESET, 0x63);
16
- delay(100); // NOLINT
17
- if (!this->write_byte(MPR121_ECR, 0x0)) {
18
- this->error_code_ = COMMUNICATION_FAILED;
19
- this->mark_failed();
20
- return;
21
- }
22
-
23
- // set touch sensitivity for all 12 channels
24
- for (auto *channel : this->channels_) {
25
- channel->setup();
26
- }
27
- this->write_byte(MPR121_MHDR, 0x01);
28
- this->write_byte(MPR121_NHDR, 0x01);
29
- this->write_byte(MPR121_NCLR, 0x0E);
30
- this->write_byte(MPR121_FDLR, 0x00);
31
-
32
- this->write_byte(MPR121_MHDF, 0x01);
33
- this->write_byte(MPR121_NHDF, 0x05);
34
- this->write_byte(MPR121_NCLF, 0x01);
35
- this->write_byte(MPR121_FDLF, 0x00);
36
-
37
- this->write_byte(MPR121_NHDT, 0x00);
38
- this->write_byte(MPR121_NCLT, 0x00);
39
- this->write_byte(MPR121_FDLT, 0x00);
40
-
41
- this->write_byte(MPR121_DEBOUNCE, 0);
42
- // default, 16uA charge current
43
- this->write_byte(MPR121_CONFIG1, 0x10);
44
- // 0.5uS encoding, 1ms period
45
- this->write_byte(MPR121_CONFIG2, 0x20);
46
-
47
- // Write the Electrode Configuration Register
48
- // * Highest 2 bits is "Calibration Lock", which we set to a value corresponding to 5 bits.
49
- // * The 2 bits below is "Proximity Enable" and are left at 0.
50
- // * The 4 least significant bits control how many electrodes are enabled. Electrodes are enabled
51
- // as a range, starting at 0 up to the highest channel index used.
52
- this->write_byte(MPR121_ECR, 0x80 | (this->max_touch_channel_ + 1));
53
-
54
- this->flush_gpio_();
17
+ this->set_timeout(100, [this]() {
18
+ if (!this->write_byte(MPR121_ECR, 0x0)) {
19
+ this->error_code_ = COMMUNICATION_FAILED;
20
+ this->mark_failed();
21
+ return;
22
+ }
23
+ // set touch sensitivity for all 12 channels
24
+ for (auto *channel : this->channels_) {
25
+ channel->setup();
26
+ }
27
+ this->write_byte(MPR121_MHDR, 0x01);
28
+ this->write_byte(MPR121_NHDR, 0x01);
29
+ this->write_byte(MPR121_NCLR, 0x0E);
30
+ this->write_byte(MPR121_FDLR, 0x00);
31
+
32
+ this->write_byte(MPR121_MHDF, 0x01);
33
+ this->write_byte(MPR121_NHDF, 0x05);
34
+ this->write_byte(MPR121_NCLF, 0x01);
35
+ this->write_byte(MPR121_FDLF, 0x00);
36
+
37
+ this->write_byte(MPR121_NHDT, 0x00);
38
+ this->write_byte(MPR121_NCLT, 0x00);
39
+ this->write_byte(MPR121_FDLT, 0x00);
40
+
41
+ this->write_byte(MPR121_DEBOUNCE, 0);
42
+ // default, 16uA charge current
43
+ this->write_byte(MPR121_CONFIG1, 0x10);
44
+ // 0.5uS encoding, 1ms period
45
+ this->write_byte(MPR121_CONFIG2, 0x20);
46
+
47
+ // Write the Electrode Configuration Register
48
+ // * Highest 2 bits is "Calibration Lock", which we set to a value corresponding to 5 bits.
49
+ // * The 2 bits below is "Proximity Enable" and are left at 0.
50
+ // * The 4 least significant bits control how many electrodes are enabled. Electrodes are enabled
51
+ // as a range, starting at 0 up to the highest channel index used.
52
+ this->write_byte(MPR121_ECR, 0x80 | (this->max_touch_channel_ + 1));
53
+
54
+ this->flush_gpio_();
55
+ this->enable_loop();
56
+ });
55
57
  }
56
58
 
57
59
  void MPR121Component::set_touch_debounce(uint8_t debounce) {
@@ -73,9 +75,6 @@ void MPR121Component::dump_config() {
73
75
  case COMMUNICATION_FAILED:
74
76
  ESP_LOGE(TAG, ESP_LOG_MSG_COMM_FAIL);
75
77
  break;
76
- case WRONG_CHIP_STATE:
77
- ESP_LOGE(TAG, "MPR121 has wrong default value for CONFIG2?");
78
- break;
79
78
  case NONE:
80
79
  default:
81
80
  break;
@@ -88,7 +88,6 @@ class MPR121Component : public Component, public i2c::I2CDevice {
88
88
  enum ErrorCode {
89
89
  NONE = 0,
90
90
  COMMUNICATION_FAILED,
91
- WRONG_CHIP_STATE,
92
91
  } error_code_{NONE};
93
92
 
94
93
  bool flush_gpio_();
@@ -218,7 +218,7 @@ void NAU7802Sensor::dump_config() {
218
218
 
219
219
  void NAU7802Sensor::write_value_(uint8_t start_reg, size_t size, int32_t value) {
220
220
  uint8_t data[4];
221
- for (int i = 0; i < size; i++) {
221
+ for (size_t i = 0; i < size; i++) {
222
222
  data[i] = 0xFF & (value >> (size - 1 - i) * 8);
223
223
  }
224
224
  this->write_register(start_reg, data, size);
@@ -228,7 +228,7 @@ int32_t NAU7802Sensor::read_value_(uint8_t start_reg, size_t size) {
228
228
  uint8_t data[4];
229
229
  this->read_register(start_reg, data, size);
230
230
  int32_t result = 0;
231
- for (int i = 0; i < size; i++) {
231
+ for (size_t i = 0; i < size; i++) {
232
232
  result |= data[i] << (size - 1 - i) * 8;
233
233
  }
234
234
  // extend sign bit
@@ -47,9 +47,13 @@ async def to_code(config):
47
47
  cg.add_define(
48
48
  "USE_NETWORK_MIN_IPV6_ADDR_COUNT", config[CONF_MIN_IPV6_ADDR_COUNT]
49
49
  )
50
- if CORE.using_esp_idf:
51
- add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
52
- add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
50
+ if CORE.is_esp32:
51
+ if CORE.using_esp_idf:
52
+ add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6)
53
+ add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6)
54
+ else:
55
+ add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", True)
56
+ add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", True)
53
57
  elif enable_ipv6:
54
58
  cg.add_build_flag("-DCONFIG_LWIP_IPV6")
55
59
  cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG")
@@ -153,10 +153,10 @@ async def to_code(config):
153
153
  if CONF_TFT_URL in config:
154
154
  cg.add_define("USE_NEXTION_TFT_UPLOAD")
155
155
  cg.add(var.set_tft_url(config[CONF_TFT_URL]))
156
- if CORE.is_esp32 and CORE.using_arduino:
157
- cg.add_library("NetworkClientSecure", None)
158
- cg.add_library("HTTPClient", None)
159
- elif CORE.is_esp32 and CORE.using_esp_idf:
156
+ if CORE.is_esp32:
157
+ if CORE.using_arduino:
158
+ cg.add_library("NetworkClientSecure", None)
159
+ cg.add_library("HTTPClient", None)
160
160
  esp32.add_idf_sdkconfig_option("CONFIG_ESP_TLS_INSECURE", True)
161
161
  esp32.add_idf_sdkconfig_option(
162
162
  "CONFIG_ESP_TLS_SKIP_SERVER_CERT_VERIFY", True
@@ -77,7 +77,7 @@ bool Nextion::check_connect_() {
77
77
  this->recv_ret_string_(response, 0, false);
78
78
  if (!response.empty() && response[0] == 0x1A) {
79
79
  // Swallow invalid variable name responses that may be caused by the above commands
80
- ESP_LOGD(TAG, "0x1A error ignored (setup)");
80
+ ESP_LOGV(TAG, "0x1A error ignored (setup)");
81
81
  return false;
82
82
  }
83
83
  if (response.empty() || response.find("comok") == std::string::npos) {
@@ -334,7 +334,7 @@ void Nextion::loop() {
334
334
  this->started_ms_ = App.get_loop_component_start_time();
335
335
 
336
336
  if (this->started_ms_ + this->startup_override_ms_ < App.get_loop_component_start_time()) {
337
- ESP_LOGD(TAG, "Manual ready set");
337
+ ESP_LOGV(TAG, "Manual ready set");
338
338
  this->connection_state_.nextion_reports_is_setup_ = true;
339
339
  }
340
340
  }
@@ -544,7 +544,7 @@ void Nextion::process_nextion_commands_() {
544
544
  uint8_t page_id = to_process[0];
545
545
  uint8_t component_id = to_process[1];
546
546
  uint8_t touch_event = to_process[2]; // 0 -> release, 1 -> press
547
- ESP_LOGD(TAG, "Touch %s: page %u comp %u", touch_event ? "PRESS" : "RELEASE", page_id, component_id);
547
+ ESP_LOGV(TAG, "Touch %s: page %u comp %u", touch_event ? "PRESS" : "RELEASE", page_id, component_id);
548
548
  for (auto *touch : this->touch_) {
549
549
  touch->process_touch(page_id, component_id, touch_event != 0);
550
550
  }
@@ -559,7 +559,7 @@ void Nextion::process_nextion_commands_() {
559
559
  }
560
560
 
561
561
  uint8_t page_id = to_process[0];
562
- ESP_LOGD(TAG, "New page: %u", page_id);
562
+ ESP_LOGV(TAG, "New page: %u", page_id);
563
563
  this->page_callback_.call(page_id);
564
564
  break;
565
565
  }
@@ -577,7 +577,7 @@ void Nextion::process_nextion_commands_() {
577
577
  const uint16_t x = (uint16_t(to_process[0]) << 8) | to_process[1];
578
578
  const uint16_t y = (uint16_t(to_process[2]) << 8) | to_process[3];
579
579
  const uint8_t touch_event = to_process[4]; // 0 -> release, 1 -> press
580
- ESP_LOGD(TAG, "Touch %s at %u,%u", touch_event ? "PRESS" : "RELEASE", x, y);
580
+ ESP_LOGV(TAG, "Touch %s at %u,%u", touch_event ? "PRESS" : "RELEASE", x, y);
581
581
  break;
582
582
  }
583
583
 
@@ -676,7 +676,7 @@ void Nextion::process_nextion_commands_() {
676
676
  }
677
677
  case 0x88: // system successful start up
678
678
  {
679
- ESP_LOGD(TAG, "System start: %zu", to_process_length);
679
+ ESP_LOGV(TAG, "System start: %zu", to_process_length);
680
680
  this->connection_state_.nextion_reports_is_setup_ = true;
681
681
  break;
682
682
  }
@@ -922,7 +922,7 @@ void Nextion::set_nextion_sensor_state(NextionQueueType queue_type, const std::s
922
922
  }
923
923
 
924
924
  void Nextion::set_nextion_text_state(const std::string &name, const std::string &state) {
925
- ESP_LOGD(TAG, "State: %s='%s'", name.c_str(), state.c_str());
925
+ ESP_LOGV(TAG, "State: %s='%s'", name.c_str(), state.c_str());
926
926
 
927
927
  for (auto *sensor : this->textsensortype_) {
928
928
  if (name == sensor->get_variable_name()) {
@@ -933,7 +933,7 @@ void Nextion::set_nextion_text_state(const std::string &name, const std::string
933
933
  }
934
934
 
935
935
  void Nextion::all_components_send_state_(bool force_update) {
936
- ESP_LOGD(TAG, "Send states");
936
+ ESP_LOGV(TAG, "Send states");
937
937
  for (auto *binarysensortype : this->binarysensortype_) {
938
938
  if (force_update || binarysensortype->get_needs_to_send_update())
939
939
  binarysensortype->send_state_to_nextion();
@@ -51,6 +51,7 @@ from esphome.const import (
51
51
  DEVICE_CLASS_OZONE,
52
52
  DEVICE_CLASS_PH,
53
53
  DEVICE_CLASS_PM1,
54
+ DEVICE_CLASS_PM4,
54
55
  DEVICE_CLASS_PM10,
55
56
  DEVICE_CLASS_PM25,
56
57
  DEVICE_CLASS_POWER,
@@ -116,6 +117,7 @@ DEVICE_CLASSES = [
116
117
  DEVICE_CLASS_PM1,
117
118
  DEVICE_CLASS_PM10,
118
119
  DEVICE_CLASS_PM25,
120
+ DEVICE_CLASS_PM4,
119
121
  DEVICE_CLASS_POWER,
120
122
  DEVICE_CLASS_POWER_FACTOR,
121
123
  DEVICE_CLASS_PRECIPITATION,
@@ -7,6 +7,17 @@ namespace number {
7
7
 
8
8
  static const char *const TAG = "number";
9
9
 
10
+ // Helper functions to reduce code size for logging
11
+ void NumberCall::log_perform_warning_(const LogString *message) {
12
+ ESP_LOGW(TAG, "'%s': %s", this->parent_->get_name().c_str(), LOG_STR_ARG(message));
13
+ }
14
+
15
+ void NumberCall::log_perform_warning_value_range_(const LogString *comparison, const LogString *limit_type, float val,
16
+ float limit) {
17
+ ESP_LOGW(TAG, "'%s': %f %s %s %f", this->parent_->get_name().c_str(), val, LOG_STR_ARG(comparison),
18
+ LOG_STR_ARG(limit_type), limit);
19
+ }
20
+
10
21
  NumberCall &NumberCall::set_value(float value) { return this->with_operation(NUMBER_OP_SET).with_value(value); }
11
22
 
12
23
  NumberCall &NumberCall::number_increment(bool cycle) {
@@ -42,7 +53,7 @@ void NumberCall::perform() {
42
53
  const auto &traits = parent->traits;
43
54
 
44
55
  if (this->operation_ == NUMBER_OP_NONE) {
45
- ESP_LOGW(TAG, "'%s' - NumberCall performed without selecting an operation", name);
56
+ this->log_perform_warning_(LOG_STR("No operation"));
46
57
  return;
47
58
  }
48
59
 
@@ -51,28 +62,28 @@ void NumberCall::perform() {
51
62
  float max_value = traits.get_max_value();
52
63
 
53
64
  if (this->operation_ == NUMBER_OP_SET) {
54
- ESP_LOGD(TAG, "'%s' - Setting number value", name);
65
+ ESP_LOGD(TAG, "'%s': Setting value", name);
55
66
  if (!this->value_.has_value() || std::isnan(*this->value_)) {
56
- ESP_LOGW(TAG, "'%s' - No value set for NumberCall", name);
67
+ this->log_perform_warning_(LOG_STR("No value"));
57
68
  return;
58
69
  }
59
70
  target_value = this->value_.value();
60
71
  } else if (this->operation_ == NUMBER_OP_TO_MIN) {
61
72
  if (std::isnan(min_value)) {
62
- ESP_LOGW(TAG, "'%s' - Can't set to min value through NumberCall: no min_value defined", name);
73
+ this->log_perform_warning_(LOG_STR("min undefined"));
63
74
  } else {
64
75
  target_value = min_value;
65
76
  }
66
77
  } else if (this->operation_ == NUMBER_OP_TO_MAX) {
67
78
  if (std::isnan(max_value)) {
68
- ESP_LOGW(TAG, "'%s' - Can't set to max value through NumberCall: no max_value defined", name);
79
+ this->log_perform_warning_(LOG_STR("max undefined"));
69
80
  } else {
70
81
  target_value = max_value;
71
82
  }
72
83
  } else if (this->operation_ == NUMBER_OP_INCREMENT) {
73
- ESP_LOGD(TAG, "'%s' - Increment number, with%s cycling", name, this->cycle_ ? "" : "out");
84
+ ESP_LOGD(TAG, "'%s': Increment with%s cycling", name, this->cycle_ ? "" : "out");
74
85
  if (!parent->has_state()) {
75
- ESP_LOGW(TAG, "'%s' - Can't increment number through NumberCall: no active state to modify", name);
86
+ this->log_perform_warning_(LOG_STR("Can't increment, no state"));
76
87
  return;
77
88
  }
78
89
  auto step = traits.get_step();
@@ -85,9 +96,9 @@ void NumberCall::perform() {
85
96
  }
86
97
  }
87
98
  } else if (this->operation_ == NUMBER_OP_DECREMENT) {
88
- ESP_LOGD(TAG, "'%s' - Decrement number, with%s cycling", name, this->cycle_ ? "" : "out");
99
+ ESP_LOGD(TAG, "'%s': Decrement with%s cycling", name, this->cycle_ ? "" : "out");
89
100
  if (!parent->has_state()) {
90
- ESP_LOGW(TAG, "'%s' - Can't decrement number through NumberCall: no active state to modify", name);
101
+ this->log_perform_warning_(LOG_STR("Can't decrement, no state"));
91
102
  return;
92
103
  }
93
104
  auto step = traits.get_step();
@@ -102,15 +113,15 @@ void NumberCall::perform() {
102
113
  }
103
114
 
104
115
  if (target_value < min_value) {
105
- ESP_LOGW(TAG, "'%s' - Value %f must not be less than minimum %f", name, target_value, min_value);
116
+ this->log_perform_warning_value_range_(LOG_STR("<"), LOG_STR("min"), target_value, min_value);
106
117
  return;
107
118
  }
108
119
  if (target_value > max_value) {
109
- ESP_LOGW(TAG, "'%s' - Value %f must not be greater than maximum %f", name, target_value, max_value);
120
+ this->log_perform_warning_value_range_(LOG_STR(">"), LOG_STR("max"), target_value, max_value);
110
121
  return;
111
122
  }
112
123
 
113
- ESP_LOGD(TAG, " New number value: %f", target_value);
124
+ ESP_LOGD(TAG, " New value: %f", target_value);
114
125
  this->parent_->control(target_value);
115
126
  }
116
127
 
@@ -1,6 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #include "esphome/core/helpers.h"
4
+ #include "esphome/core/log.h"
4
5
  #include "number_traits.h"
5
6
 
6
7
  namespace esphome {
@@ -33,6 +34,10 @@ class NumberCall {
33
34
  NumberCall &with_cycle(bool cycle);
34
35
 
35
36
  protected:
37
+ void log_perform_warning_(const LogString *message);
38
+ void log_perform_warning_value_range_(const LogString *comparison, const LogString *limit_type, float val,
39
+ float limit);
40
+
36
41
  Number *const parent_;
37
42
  NumberOperation operation_{NUMBER_OP_NONE};
38
43
  optional<float> value_;
@@ -117,7 +117,8 @@ int HOT BmpDecoder::decode(uint8_t *buffer, size_t size) {
117
117
  this->paint_index_++;
118
118
  this->current_index_ += 3;
119
119
  index += 3;
120
- if (x == this->width_ - 1 && this->padding_bytes_ > 0) {
120
+ size_t last_col = static_cast<size_t>(this->width_) - 1;
121
+ if (x == last_col && this->padding_bytes_ > 0) {
121
122
  index += this->padding_bytes_;
122
123
  this->current_index_ += this->padding_bytes_;
123
124
  }
@@ -25,8 +25,10 @@ static int draw_callback(JPEGDRAW *jpeg) {
25
25
  // to avoid crashing.
26
26
  App.feed_wdt();
27
27
  size_t position = 0;
28
- for (size_t y = 0; y < jpeg->iHeight; y++) {
29
- for (size_t x = 0; x < jpeg->iWidth; x++) {
28
+ size_t height = static_cast<size_t>(jpeg->iHeight);
29
+ size_t width = static_cast<size_t>(jpeg->iWidth);
30
+ for (size_t y = 0; y < height; y++) {
31
+ for (size_t x = 0; x < width; x++) {
30
32
  auto rg = decode_value(jpeg->pPixels[position++]);
31
33
  auto ba = decode_value(jpeg->pPixels[position++]);
32
34
  Color color(rg[1], rg[0], ba[1], ba[0]);
@@ -7,7 +7,7 @@
7
7
 
8
8
  #include "opentherm.h"
9
9
  #include "esphome/core/helpers.h"
10
- #if defined(ESP32) || defined(USE_ESP_IDF)
10
+ #ifdef USE_ESP32
11
11
  #include "driver/timer.h"
12
12
  #include "esp_err.h"
13
13
  #endif
@@ -31,7 +31,7 @@ OpenTherm *OpenTherm::instance = nullptr;
31
31
  OpenTherm::OpenTherm(InternalGPIOPin *in_pin, InternalGPIOPin *out_pin, int32_t device_timeout)
32
32
  : in_pin_(in_pin),
33
33
  out_pin_(out_pin),
34
- #if defined(ESP32) || defined(USE_ESP_IDF)
34
+ #ifdef USE_ESP32
35
35
  timer_group_(TIMER_GROUP_0),
36
36
  timer_idx_(TIMER_0),
37
37
  #endif
@@ -57,7 +57,7 @@ bool OpenTherm::initialize() {
57
57
  this->out_pin_->setup();
58
58
  this->out_pin_->digital_write(true);
59
59
 
60
- #if defined(ESP32) || defined(USE_ESP_IDF)
60
+ #ifdef USE_ESP32
61
61
  return this->init_esp32_timer_();
62
62
  #else
63
63
  return true;
@@ -238,7 +238,7 @@ void IRAM_ATTR OpenTherm::write_bit_(uint8_t high, uint8_t clock) {
238
238
  }
239
239
  }
240
240
 
241
- #if defined(ESP32) || defined(USE_ESP_IDF)
241
+ #ifdef USE_ESP32
242
242
 
243
243
  bool OpenTherm::init_esp32_timer_() {
244
244
  // Search for a free timer. Maybe unstable, we'll see.
@@ -365,7 +365,7 @@ void IRAM_ATTR OpenTherm::stop_timer_() {
365
365
  }
366
366
  }
367
367
 
368
- #endif // END ESP32
368
+ #endif // USE_ESP32
369
369
 
370
370
  #ifdef ESP8266
371
371
  // 5 kHz timer_
@@ -12,7 +12,7 @@
12
12
  #include "esphome/core/helpers.h"
13
13
  #include "esphome/core/log.h"
14
14
 
15
- #if defined(ESP32) || defined(USE_ESP_IDF)
15
+ #ifdef USE_ESP32
16
16
  #include "driver/timer.h"
17
17
  #endif
18
18
 
@@ -356,7 +356,7 @@ class OpenTherm {
356
356
  ISRInternalGPIOPin isr_in_pin_;
357
357
  ISRInternalGPIOPin isr_out_pin_;
358
358
 
359
- #if defined(ESP32) || defined(USE_ESP_IDF)
359
+ #ifdef USE_ESP32
360
360
  timer_group_t timer_group_;
361
361
  timer_idx_t timer_idx_;
362
362
  #endif
@@ -370,7 +370,7 @@ class OpenTherm {
370
370
  int32_t timeout_counter_; // <0 no timeout
371
371
  int32_t device_timeout_;
372
372
 
373
- #if defined(ESP32) || defined(USE_ESP_IDF)
373
+ #ifdef USE_ESP32
374
374
  esp_err_t timer_error_ = ESP_OK;
375
375
  TimerErrorType timer_error_type_ = TimerErrorType::NO_TIMER_ERROR;
376
376