esphome 2024.7.2__py3-none-any.whl → 2024.8.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 (353) hide show
  1. esphome/__main__.py +15 -81
  2. esphome/automation.py +1 -1
  3. esphome/codegen.py +53 -53
  4. esphome/components/ade7953/sensor.py +1 -1
  5. esphome/components/ade7953_spi/ade7953_spi.cpp +1 -1
  6. esphome/components/airthings_wave_plus/airthings_wave_plus.cpp +5 -2
  7. esphome/components/airthings_wave_plus/airthings_wave_plus.h +2 -0
  8. esphome/components/airthings_wave_plus/sensor.py +12 -0
  9. esphome/components/alarm_control_panel/__init__.py +75 -66
  10. esphome/components/apds9306/__init__.py +4 -0
  11. esphome/components/apds9306/apds9306.cpp +151 -0
  12. esphome/components/apds9306/apds9306.h +66 -0
  13. esphome/components/apds9306/sensor.py +95 -0
  14. esphome/components/api/__init__.py +80 -52
  15. esphome/components/api/api_connection.cpp +14 -1
  16. esphome/components/api/api_pb2.cpp +33 -4
  17. esphome/components/api/api_pb2.h +8 -1
  18. esphome/components/api/api_server.cpp +10 -0
  19. esphome/components/api/api_server.h +3 -0
  20. esphome/components/atm90e32/__init__.py +7 -0
  21. esphome/components/atm90e32/atm90e32.cpp +68 -16
  22. esphome/components/atm90e32/atm90e32.h +20 -7
  23. esphome/components/atm90e32/atm90e32_reg.h +2 -0
  24. esphome/components/atm90e32/button/__init__.py +43 -0
  25. esphome/components/atm90e32/button/atm90e32_button.cpp +20 -0
  26. esphome/components/atm90e32/button/atm90e32_button.h +27 -0
  27. esphome/components/atm90e32/sensor.py +15 -11
  28. esphome/components/bedjet/bedjet_codec.h +1 -1
  29. esphome/components/binary/light/binary_light_output.h +3 -2
  30. esphome/components/binary_sensor/__init__.py +5 -5
  31. esphome/components/ble_client/__init__.py +3 -3
  32. esphome/components/ble_client/output/__init__.py +1 -1
  33. esphome/components/ble_client/sensor/__init__.py +4 -3
  34. esphome/components/ble_client/switch/__init__.py +2 -1
  35. esphome/components/ble_client/text_sensor/__init__.py +4 -3
  36. esphome/components/ble_presence/binary_sensor.py +3 -3
  37. esphome/components/ble_rssi/sensor.py +2 -2
  38. esphome/components/ble_scanner/text_sensor.py +1 -1
  39. esphome/components/bluetooth_proxy/__init__.py +3 -3
  40. esphome/components/bme68x_bsec2/__init__.py +196 -0
  41. esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +523 -0
  42. esphome/components/bme68x_bsec2/bme68x_bsec2.h +163 -0
  43. esphome/components/bme68x_bsec2/sensor.py +130 -0
  44. esphome/components/bme68x_bsec2/text_sensor.py +33 -0
  45. esphome/components/bme68x_bsec2_i2c/__init__.py +28 -0
  46. esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.cpp +53 -0
  47. esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.h +28 -0
  48. esphome/components/bmp3xx/sensor.py +1 -1
  49. esphome/components/button/__init__.py +4 -4
  50. esphome/components/climate/__init__.py +5 -5
  51. esphome/components/climate/climate.h +1 -1
  52. esphome/components/cover/__init__.py +8 -8
  53. esphome/components/cst226/touchscreen/cst226_touchscreen.cpp +11 -7
  54. esphome/components/cst226/touchscreen/cst226_touchscreen.h +1 -1
  55. esphome/components/datetime/__init__.py +11 -13
  56. esphome/components/demo/demo_sensor.h +3 -2
  57. esphome/components/display/display.cpp +31 -0
  58. esphome/components/display/display.h +3 -0
  59. esphome/components/display_menu_base/__init__.py +14 -13
  60. esphome/components/ens160/sensor.py +1 -1
  61. esphome/components/esp32/__init__.py +22 -10
  62. esphome/components/esp32/boards.py +1 -1
  63. esphome/components/esp32/gpio.py +12 -13
  64. esphome/components/esp32/gpio_esp32.py +1 -2
  65. esphome/components/esp32/gpio_esp32_c2.py +1 -2
  66. esphome/components/esp32/gpio_esp32_c3.py +1 -5
  67. esphome/components/esp32/gpio_esp32_c6.py +1 -2
  68. esphome/components/esp32/gpio_esp32_h2.py +1 -2
  69. esphome/components/esp32/gpio_esp32_s2.py +1 -2
  70. esphome/components/esp32/gpio_esp32_s3.py +1 -6
  71. esphome/components/esp32_ble/__init__.py +20 -3
  72. esphome/components/esp32_ble/ble.cpp +9 -1
  73. esphome/components/esp32_ble/ble.h +9 -0
  74. esphome/components/esp32_ble/ble_advertising.cpp +42 -9
  75. esphome/components/esp32_ble/ble_advertising.h +21 -1
  76. esphome/components/esp32_ble_beacon/__init__.py +17 -7
  77. esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +45 -113
  78. esphome/components/esp32_ble_beacon/esp32_ble_beacon.h +17 -19
  79. esphome/components/esp32_ble_client/__init__.py +0 -1
  80. esphome/components/esp32_ble_server/__init__.py +2 -3
  81. esphome/components/esp32_ble_tracker/__init__.py +2 -2
  82. esphome/components/esp32_improv/__init__.py +2 -4
  83. esphome/components/ethernet/__init__.py +17 -17
  84. esphome/components/ethernet_info/text_sensor.py +2 -2
  85. esphome/components/event/__init__.py +5 -5
  86. esphome/components/fan/__init__.py +14 -14
  87. esphome/components/fan/fan.cpp +2 -2
  88. esphome/components/fingerprint_grow/fingerprint_grow.cpp +1 -1
  89. esphome/components/fingerprint_grow/fingerprint_grow.h +1 -1
  90. esphome/components/graphical_display_menu/__init__.py +11 -8
  91. esphome/components/haier/haier_base.h +2 -2
  92. esphome/components/homeassistant/__init__.py +8 -1
  93. esphome/components/homeassistant/number/__init__.py +33 -0
  94. esphome/components/homeassistant/number/homeassistant_number.cpp +100 -0
  95. esphome/components/homeassistant/number/homeassistant_number.h +31 -0
  96. esphome/components/homeassistant/switch/__init__.py +30 -0
  97. esphome/components/homeassistant/switch/homeassistant_switch.cpp +59 -0
  98. esphome/components/homeassistant/switch/homeassistant_switch.h +22 -0
  99. esphome/components/host/__init__.py +3 -7
  100. esphome/components/http_request/__init__.py +12 -1
  101. esphome/components/http_request/http_request_arduino.cpp +2 -2
  102. esphome/components/http_request/http_request_idf.cpp +11 -2
  103. esphome/components/http_request/http_request_idf.h +10 -0
  104. esphome/components/http_request/ota/ota_http_request.cpp +1 -1
  105. esphome/components/http_request/update/http_request_update.cpp +2 -2
  106. esphome/components/http_request/update/http_request_update.h +2 -1
  107. esphome/components/hx711/hx711.cpp +10 -1
  108. esphome/components/hydreon_rgxx/hydreon_rgxx.cpp +1 -1
  109. esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +11 -2
  110. esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +2 -0
  111. esphome/components/ili9xxx/ili9xxx_defines.h +3 -1
  112. esphome/components/ili9xxx/ili9xxx_display.cpp +9 -22
  113. esphome/components/ili9xxx/ili9xxx_display.h +5 -7
  114. esphome/components/ili9xxx/ili9xxx_init.h +4 -4
  115. esphome/components/improv_base/__init__.py +2 -3
  116. esphome/components/improv_serial/__init__.py +4 -10
  117. esphome/components/improv_serial/improv_serial_component.cpp +4 -0
  118. esphome/components/jsn_sr04t/jsn_sr04t.cpp +18 -1
  119. esphome/components/jsn_sr04t/jsn_sr04t.h +7 -1
  120. esphome/components/jsn_sr04t/sensor.py +13 -0
  121. esphome/components/kalman_combinator/sensor.py +1 -1
  122. esphome/components/light/__init__.py +16 -15
  123. esphome/components/light/addressable_light_effect.h +12 -8
  124. esphome/components/light/automation.h +16 -1
  125. esphome/components/light/automation.py +21 -0
  126. esphome/components/light/base_light_effects.h +5 -5
  127. esphome/components/light/esp_color_correction.h +8 -8
  128. esphome/components/light/types.py +7 -0
  129. esphome/components/lock/__init__.py +3 -3
  130. esphome/components/logger/__init__.py +15 -18
  131. esphome/components/lvgl/__init__.py +346 -0
  132. esphome/components/lvgl/automation.py +226 -0
  133. esphome/components/lvgl/binary_sensor/__init__.py +43 -0
  134. esphome/components/lvgl/defines.py +508 -0
  135. esphome/components/lvgl/encoders.py +77 -0
  136. esphome/components/lvgl/font.cpp +76 -0
  137. esphome/components/lvgl/helpers.py +49 -0
  138. esphome/components/lvgl/light/__init__.py +32 -0
  139. esphome/components/lvgl/light/lvgl_light.h +48 -0
  140. esphome/components/lvgl/lv_validation.py +303 -0
  141. esphome/components/lvgl/lvcode.py +349 -0
  142. esphome/components/lvgl/lvgl_esphome.cpp +407 -0
  143. esphome/components/lvgl/lvgl_esphome.h +274 -0
  144. esphome/components/lvgl/lvgl_hal.h +21 -0
  145. esphome/components/lvgl/number/__init__.py +66 -0
  146. esphome/components/lvgl/number/lvgl_number.h +34 -0
  147. esphome/components/lvgl/schemas.py +436 -0
  148. esphome/components/lvgl/select/__init__.py +55 -0
  149. esphome/components/lvgl/select/lvgl_select.h +62 -0
  150. esphome/components/lvgl/sensor/__init__.py +47 -0
  151. esphome/components/lvgl/styles.py +58 -0
  152. esphome/components/lvgl/switch/__init__.py +56 -0
  153. esphome/components/lvgl/switch/lvgl_switch.h +34 -0
  154. esphome/components/lvgl/text/__init__.py +50 -0
  155. esphome/components/lvgl/text/lvgl_text.h +34 -0
  156. esphome/components/lvgl/text_sensor/__init__.py +42 -0
  157. esphome/components/lvgl/touchscreens.py +45 -0
  158. esphome/components/lvgl/trigger.py +74 -0
  159. esphome/components/lvgl/types.py +191 -0
  160. esphome/components/lvgl/widgets/__init__.py +419 -0
  161. esphome/components/lvgl/widgets/animimg.py +117 -0
  162. esphome/components/lvgl/widgets/arc.py +78 -0
  163. esphome/components/lvgl/widgets/button.py +20 -0
  164. esphome/components/lvgl/widgets/buttonmatrix.py +275 -0
  165. esphome/components/lvgl/widgets/checkbox.py +27 -0
  166. esphome/components/lvgl/widgets/dropdown.py +76 -0
  167. esphome/components/lvgl/widgets/img.py +85 -0
  168. esphome/components/lvgl/widgets/keyboard.py +49 -0
  169. esphome/components/lvgl/widgets/label.py +42 -0
  170. esphome/components/lvgl/widgets/led.py +29 -0
  171. esphome/components/lvgl/widgets/line.py +50 -0
  172. esphome/components/lvgl/widgets/lv_bar.py +55 -0
  173. esphome/components/lvgl/widgets/meter.py +302 -0
  174. esphome/components/lvgl/widgets/msgbox.py +134 -0
  175. esphome/components/lvgl/widgets/obj.py +28 -0
  176. esphome/components/lvgl/widgets/page.py +113 -0
  177. esphome/components/lvgl/widgets/roller.py +77 -0
  178. esphome/components/lvgl/widgets/slider.py +63 -0
  179. esphome/components/lvgl/widgets/spinbox.py +178 -0
  180. esphome/components/lvgl/widgets/spinner.py +43 -0
  181. esphome/components/lvgl/widgets/switch.py +20 -0
  182. esphome/components/lvgl/widgets/tabview.py +114 -0
  183. esphome/components/lvgl/widgets/textarea.py +66 -0
  184. esphome/components/lvgl/widgets/tileview.py +128 -0
  185. esphome/components/m5stack_8angle/__init__.py +33 -0
  186. esphome/components/m5stack_8angle/binary_sensor/__init__.py +30 -0
  187. esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.cpp +17 -0
  188. esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.h +19 -0
  189. esphome/components/m5stack_8angle/light/__init__.py +31 -0
  190. esphome/components/m5stack_8angle/light/m5stack_8angle_light.cpp +45 -0
  191. esphome/components/m5stack_8angle/light/m5stack_8angle_light.h +37 -0
  192. esphome/components/m5stack_8angle/m5stack_8angle.cpp +74 -0
  193. esphome/components/m5stack_8angle/m5stack_8angle.h +34 -0
  194. esphome/components/m5stack_8angle/sensor/__init__.py +66 -0
  195. esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.cpp +24 -0
  196. esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.h +27 -0
  197. esphome/components/matrix_keypad/matrix_keypad.cpp +2 -0
  198. esphome/components/max31856/sensor.py +5 -5
  199. esphome/components/media_player/__init__.py +3 -5
  200. esphome/components/media_player/automation.h +31 -27
  201. esphome/components/micro_wake_word/__init__.py +20 -25
  202. esphome/components/micro_wake_word/streaming_model.cpp +6 -4
  203. esphome/components/microphone/microphone.h +4 -1
  204. esphome/components/mitsubishi/mitsubishi.cpp +7 -1
  205. esphome/components/modbus_controller/__init__.py +26 -2
  206. esphome/components/modbus_controller/automation.h +19 -0
  207. esphome/components/modbus_controller/const.py +1 -0
  208. esphome/components/modbus_controller/modbus_controller.cpp +8 -0
  209. esphome/components/modbus_controller/modbus_controller.h +3 -0
  210. esphome/components/mqtt/__init__.py +20 -9
  211. esphome/components/mqtt/mqtt_alarm_control_panel.cpp +128 -0
  212. esphome/components/mqtt/mqtt_alarm_control_panel.h +39 -0
  213. esphome/components/mqtt/mqtt_backend.h +3 -1
  214. esphome/components/mqtt/mqtt_backend_esp32.cpp +4 -1
  215. esphome/components/mqtt/mqtt_backend_esp32.h +3 -1
  216. esphome/components/mqtt/mqtt_backend_esp8266.h +3 -1
  217. esphome/components/mqtt/mqtt_backend_libretiny.h +3 -1
  218. esphome/components/mqtt/mqtt_client.cpp +16 -3
  219. esphome/components/mqtt/mqtt_client.h +5 -1
  220. esphome/components/mqtt/mqtt_component.cpp +32 -4
  221. esphome/components/mqtt/mqtt_const.h +2 -0
  222. esphome/components/network/__init__.py +15 -12
  223. esphome/components/network/ip_address.h +3 -0
  224. esphome/components/network/util.cpp +2 -1
  225. esphome/components/network/util.h +3 -1
  226. esphome/components/nextion/base_component.py +5 -8
  227. esphome/components/number/__init__.py +7 -8
  228. esphome/components/online_image/__init__.py +167 -0
  229. esphome/components/online_image/image_decoder.cpp +44 -0
  230. esphome/components/online_image/image_decoder.h +112 -0
  231. esphome/components/online_image/online_image.cpp +283 -0
  232. esphome/components/online_image/online_image.h +195 -0
  233. esphome/components/online_image/png_image.cpp +68 -0
  234. esphome/components/online_image/png_image.h +33 -0
  235. esphome/components/ota/__init__.py +8 -4
  236. esphome/components/pid/pid_climate.h +2 -0
  237. esphome/components/pmwcs3/pmwcs3.cpp +31 -30
  238. esphome/components/remote_base/pronto_protocol.cpp +0 -3
  239. esphome/components/remote_transmitter/remote_transmitter.h +1 -1
  240. esphome/components/rgbct/rgbct_light_output.h +3 -2
  241. esphome/components/rgbw/rgbw_light_output.h +3 -2
  242. esphome/components/rgbww/rgbww_light_output.h +3 -2
  243. esphome/components/rp2040_pio_led_strip/led_strip.cpp +31 -5
  244. esphome/components/rp2040_pio_led_strip/led_strip.h +5 -0
  245. esphome/components/rtttl/rtttl.cpp +108 -21
  246. esphome/components/rtttl/rtttl.h +15 -6
  247. esphome/components/select/__init__.py +7 -7
  248. esphome/components/sensor/__init__.py +29 -10
  249. esphome/components/sensor/filter.cpp +8 -0
  250. esphome/components/sensor/filter.h +9 -0
  251. esphome/components/sml/sml_parser.cpp +48 -22
  252. esphome/components/socket/socket.cpp +11 -14
  253. esphome/components/speaker/__init__.py +14 -5
  254. esphome/components/speaker/automation.h +10 -0
  255. esphome/components/speaker/speaker.h +9 -0
  256. esphome/components/spi/spi.cpp +0 -6
  257. esphome/components/spi/spi.h +2 -19
  258. esphome/components/spi_led_strip/spi_led_strip.h +5 -4
  259. esphome/components/sprinkler/sprinkler.cpp +2 -2
  260. esphome/components/sprinkler/sprinkler.h +1 -1
  261. esphome/components/switch/__init__.py +3 -3
  262. esphome/components/text/__init__.py +5 -5
  263. esphome/components/text_sensor/__init__.py +7 -7
  264. esphome/components/time/__init__.py +8 -8
  265. esphome/components/touchscreen/binary_sensor/__init__.py +24 -10
  266. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.cpp +3 -2
  267. esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.h +4 -2
  268. esphome/components/uart/uart_component_host.cpp +6 -2
  269. esphome/components/update/__init__.py +33 -15
  270. esphome/components/update/automation.h +23 -0
  271. esphome/components/update/update_entity.h +3 -1
  272. esphome/components/valve/__init__.py +3 -3
  273. esphome/components/voice_assistant/__init__.py +7 -8
  274. esphome/components/wake_on_lan/wake_on_lan.cpp +2 -0
  275. esphome/components/wake_on_lan/wake_on_lan.h +3 -1
  276. esphome/components/watchdog/__init__.py +1 -0
  277. esphome/components/{http_request → watchdog}/watchdog.cpp +0 -2
  278. esphome/components/{http_request → watchdog}/watchdog.h +0 -2
  279. esphome/components/waveshare_epaper/waveshare_epaper.cpp +5 -5
  280. esphome/components/web_server/server_index_v3.h +3615 -3603
  281. esphome/components/web_server/web_server.cpp +0 -209
  282. esphome/components/web_server/web_server.h +1 -1
  283. esphome/components/web_server/web_server_v1.cpp +217 -0
  284. esphome/components/web_server_base/web_server_base.h +1 -0
  285. esphome/components/wifi/__init__.py +15 -14
  286. esphome/components/wifi/wifi_component.cpp +2 -0
  287. esphome/components/wifi/wifi_component.h +7 -1
  288. esphome/components/wifi/wifi_component_esp32_arduino.cpp +5 -2
  289. esphome/components/wifi/wifi_component_esp8266.cpp +2 -0
  290. esphome/components/wifi/wifi_component_esp_idf.cpp +43 -7
  291. esphome/components/wifi/wifi_component_libretiny.cpp +2 -0
  292. esphome/components/wifi/wifi_component_pico_w.cpp +2 -0
  293. esphome/components/wifi/wpa2_eap.py +6 -7
  294. esphome/components/wifi_info/text_sensor.py +3 -3
  295. esphome/components/wifi_info/wifi_info_text_sensor.cpp +2 -0
  296. esphome/components/wifi_info/wifi_info_text_sensor.h +2 -0
  297. esphome/components/wifi_signal/sensor.py +1 -1
  298. esphome/components/wifi_signal/wifi_signal_sensor.cpp +2 -0
  299. esphome/components/wifi_signal/wifi_signal_sensor.h +2 -1
  300. esphome/components/xiaomi_ble/xiaomi_ble.cpp +20 -3
  301. esphome/components/xiaomi_ble/xiaomi_ble.h +1 -0
  302. esphome/components/xiaomi_lywsd02mmc/__init__.py +0 -0
  303. esphome/components/xiaomi_lywsd02mmc/sensor.py +77 -0
  304. esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.cpp +73 -0
  305. esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.h +37 -0
  306. esphome/config.py +17 -19
  307. esphome/config_validation.py +55 -23
  308. esphome/const.py +25 -9
  309. esphome/core/__init__.py +17 -14
  310. esphome/core/application.h +42 -21
  311. esphome/core/automation.h +5 -3
  312. esphome/core/base_automation.h +3 -2
  313. esphome/core/bytebuffer.cpp +134 -0
  314. esphome/core/bytebuffer.h +96 -0
  315. esphome/core/color.h +24 -16
  316. esphome/core/config.py +3 -3
  317. esphome/core/defines.h +14 -1
  318. esphome/core/entity_base.h +2 -2
  319. esphome/core/entity_helpers.py +1 -2
  320. esphome/core/gpio.h +0 -18
  321. esphome/core/helpers.h +1 -1
  322. esphome/core/optional.h +15 -16
  323. esphome/coroutine.py +1 -1
  324. esphome/cpp_generator.py +1 -1
  325. esphome/cpp_helpers.py +3 -5
  326. esphome/dashboard/core.py +3 -3
  327. esphome/dashboard/dashboard.py +3 -3
  328. esphome/dashboard/entries.py +1 -1
  329. esphome/dashboard/util/file.py +1 -1
  330. esphome/dashboard/web_server.py +3 -3
  331. esphome/external_files.py +5 -3
  332. esphome/final_validate.py +2 -2
  333. esphome/git.py +4 -4
  334. esphome/helpers.py +5 -5
  335. esphome/loader.py +15 -10
  336. esphome/mqtt.py +4 -8
  337. esphome/pins.py +6 -6
  338. esphome/platformio_api.py +5 -5
  339. esphome/storage_json.py +2 -1
  340. esphome/types.py +1 -1
  341. esphome/util.py +2 -3
  342. esphome/voluptuous_schema.py +1 -0
  343. esphome/vscode.py +5 -4
  344. esphome/wizard.py +1 -1
  345. esphome/writer.py +7 -7
  346. esphome/yaml_util.py +3 -3
  347. esphome/zeroconf.py +1 -1
  348. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/METADATA +3 -3
  349. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/RECORD +353 -247
  350. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/LICENSE +0 -0
  351. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/WHEEL +0 -0
  352. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/entry_points.txt +0 -0
  353. {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/top_level.txt +0 -0
@@ -46,29 +46,6 @@ static const char *const HEADER_CORS_REQ_PNA = "Access-Control-Request-Private-N
46
46
  static const char *const HEADER_CORS_ALLOW_PNA = "Access-Control-Allow-Private-Network";
47
47
  #endif
48
48
 
49
- #if USE_WEBSERVER_VERSION == 1
50
- void write_row(AsyncResponseStream *stream, EntityBase *obj, const std::string &klass, const std::string &action,
51
- const std::function<void(AsyncResponseStream &stream, EntityBase *obj)> &action_func = nullptr) {
52
- stream->print("<tr class=\"");
53
- stream->print(klass.c_str());
54
- if (obj->is_internal())
55
- stream->print(" internal");
56
- stream->print("\" id=\"");
57
- stream->print(klass.c_str());
58
- stream->print("-");
59
- stream->print(obj->get_object_id().c_str());
60
- stream->print("\"><td>");
61
- stream->print(obj->get_name().c_str());
62
- stream->print("</td><td></td><td>");
63
- stream->print(action.c_str());
64
- if (action_func) {
65
- action_func(*stream, obj);
66
- }
67
- stream->print("</td>");
68
- stream->print("</tr>");
69
- }
70
- #endif
71
-
72
49
  UrlMatch match_url(const std::string &url, bool only_domain = false) {
73
50
  UrlMatch match;
74
51
  match.valid = false;
@@ -102,11 +79,6 @@ WebServer::WebServer(web_server_base::WebServerBase *base)
102
79
  #endif
103
80
  }
104
81
 
105
- #if USE_WEBSERVER_VERSION == 1
106
- void WebServer::set_css_url(const char *css_url) { this->css_url_ = css_url; }
107
- void WebServer::set_js_url(const char *js_url) { this->js_url_ = js_url; }
108
- #endif
109
-
110
82
  #ifdef USE_WEBSERVER_CSS_INCLUDE
111
83
  void WebServer::set_css_include(const char *css_include) { this->css_include_ = css_include; }
112
84
  #endif
@@ -181,187 +153,6 @@ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
181
153
  response->addHeader("Content-Encoding", "gzip");
182
154
  request->send(response);
183
155
  }
184
- #elif USE_WEBSERVER_VERSION == 1
185
- void WebServer::handle_index_request(AsyncWebServerRequest *request) {
186
- AsyncResponseStream *stream = request->beginResponseStream("text/html");
187
- const std::string &title = App.get_name();
188
- stream->print(F("<!DOCTYPE html><html lang=\"en\"><head><meta charset=UTF-8><meta "
189
- "name=viewport content=\"width=device-width, initial-scale=1,user-scalable=no\"><title>"));
190
- stream->print(title.c_str());
191
- stream->print(F("</title>"));
192
- #ifdef USE_WEBSERVER_CSS_INCLUDE
193
- stream->print(F("<link rel=\"stylesheet\" href=\"/0.css\">"));
194
- #endif
195
- if (strlen(this->css_url_) > 0) {
196
- stream->print(F(R"(<link rel="stylesheet" href=")"));
197
- stream->print(this->css_url_);
198
- stream->print(F("\">"));
199
- }
200
- stream->print(F("</head><body>"));
201
- stream->print(F("<article class=\"markdown-body\"><h1>"));
202
- stream->print(title.c_str());
203
- stream->print(F("</h1>"));
204
- stream->print(F("<h2>States</h2><table id=\"states\"><thead><tr><th>Name<th>State<th>Actions<tbody>"));
205
-
206
- #ifdef USE_SENSOR
207
- for (auto *obj : App.get_sensors()) {
208
- if (this->include_internal_ || !obj->is_internal())
209
- write_row(stream, obj, "sensor", "");
210
- }
211
- #endif
212
-
213
- #ifdef USE_SWITCH
214
- for (auto *obj : App.get_switches()) {
215
- if (this->include_internal_ || !obj->is_internal())
216
- write_row(stream, obj, "switch", "<button>Toggle</button>");
217
- }
218
- #endif
219
-
220
- #ifdef USE_BUTTON
221
- for (auto *obj : App.get_buttons())
222
- write_row(stream, obj, "button", "<button>Press</button>");
223
- #endif
224
-
225
- #ifdef USE_BINARY_SENSOR
226
- for (auto *obj : App.get_binary_sensors()) {
227
- if (this->include_internal_ || !obj->is_internal())
228
- write_row(stream, obj, "binary_sensor", "");
229
- }
230
- #endif
231
-
232
- #ifdef USE_FAN
233
- for (auto *obj : App.get_fans()) {
234
- if (this->include_internal_ || !obj->is_internal())
235
- write_row(stream, obj, "fan", "<button>Toggle</button>");
236
- }
237
- #endif
238
-
239
- #ifdef USE_LIGHT
240
- for (auto *obj : App.get_lights()) {
241
- if (this->include_internal_ || !obj->is_internal())
242
- write_row(stream, obj, "light", "<button>Toggle</button>");
243
- }
244
- #endif
245
-
246
- #ifdef USE_TEXT_SENSOR
247
- for (auto *obj : App.get_text_sensors()) {
248
- if (this->include_internal_ || !obj->is_internal())
249
- write_row(stream, obj, "text_sensor", "");
250
- }
251
- #endif
252
-
253
- #ifdef USE_COVER
254
- for (auto *obj : App.get_covers()) {
255
- if (this->include_internal_ || !obj->is_internal())
256
- write_row(stream, obj, "cover", "<button>Open</button><button>Close</button>");
257
- }
258
- #endif
259
-
260
- #ifdef USE_NUMBER
261
- for (auto *obj : App.get_numbers()) {
262
- if (this->include_internal_ || !obj->is_internal()) {
263
- write_row(stream, obj, "number", "", [](AsyncResponseStream &stream, EntityBase *obj) {
264
- number::Number *number = (number::Number *) obj;
265
- stream.print(R"(<input type="number" min=")");
266
- stream.print(number->traits.get_min_value());
267
- stream.print(R"(" max=")");
268
- stream.print(number->traits.get_max_value());
269
- stream.print(R"(" step=")");
270
- stream.print(number->traits.get_step());
271
- stream.print(R"(" value=")");
272
- stream.print(number->state);
273
- stream.print(R"("/>)");
274
- });
275
- }
276
- }
277
- #endif
278
-
279
- #ifdef USE_TEXT
280
- for (auto *obj : App.get_texts()) {
281
- if (this->include_internal_ || !obj->is_internal()) {
282
- write_row(stream, obj, "text", "", [](AsyncResponseStream &stream, EntityBase *obj) {
283
- text::Text *text = (text::Text *) obj;
284
- auto mode = (int) text->traits.get_mode();
285
- stream.print(R"(<input type=")");
286
- if (mode == 2) {
287
- stream.print(R"(password)");
288
- } else { // default
289
- stream.print(R"(text)");
290
- }
291
- stream.print(R"(" minlength=")");
292
- stream.print(text->traits.get_min_length());
293
- stream.print(R"(" maxlength=")");
294
- stream.print(text->traits.get_max_length());
295
- stream.print(R"(" pattern=")");
296
- stream.print(text->traits.get_pattern().c_str());
297
- stream.print(R"(" value=")");
298
- stream.print(text->state.c_str());
299
- stream.print(R"("/>)");
300
- });
301
- }
302
- }
303
- #endif
304
-
305
- #ifdef USE_SELECT
306
- for (auto *obj : App.get_selects()) {
307
- if (this->include_internal_ || !obj->is_internal()) {
308
- write_row(stream, obj, "select", "", [](AsyncResponseStream &stream, EntityBase *obj) {
309
- select::Select *select = (select::Select *) obj;
310
- stream.print("<select>");
311
- stream.print("<option></option>");
312
- for (auto const &option : select->traits.get_options()) {
313
- stream.print("<option>");
314
- stream.print(option.c_str());
315
- stream.print("</option>");
316
- }
317
- stream.print("</select>");
318
- });
319
- }
320
- }
321
- #endif
322
-
323
- #ifdef USE_LOCK
324
- for (auto *obj : App.get_locks()) {
325
- if (this->include_internal_ || !obj->is_internal()) {
326
- write_row(stream, obj, "lock", "", [](AsyncResponseStream &stream, EntityBase *obj) {
327
- lock::Lock *lock = (lock::Lock *) obj;
328
- stream.print("<button>Lock</button><button>Unlock</button>");
329
- if (lock->traits.get_supports_open()) {
330
- stream.print("<button>Open</button>");
331
- }
332
- });
333
- }
334
- }
335
- #endif
336
-
337
- #ifdef USE_CLIMATE
338
- for (auto *obj : App.get_climates()) {
339
- if (this->include_internal_ || !obj->is_internal())
340
- write_row(stream, obj, "climate", "");
341
- }
342
- #endif
343
-
344
- stream->print(F("</tbody></table><p>See <a href=\"https://esphome.io/web-api/index.html\">ESPHome Web API</a> for "
345
- "REST API documentation.</p>"));
346
- if (this->allow_ota_) {
347
- stream->print(
348
- F("<h2>OTA Update</h2><form method=\"POST\" action=\"/update\" enctype=\"multipart/form-data\"><input "
349
- "type=\"file\" name=\"update\"><input type=\"submit\" value=\"Update\"></form>"));
350
- }
351
- stream->print(F("<h2>Debug Log</h2><pre id=\"log\"></pre>"));
352
- #ifdef USE_WEBSERVER_JS_INCLUDE
353
- if (this->js_include_ != nullptr) {
354
- stream->print(F("<script type=\"module\" src=\"/0.js\"></script>"));
355
- }
356
- #endif
357
- if (strlen(this->js_url_) > 0) {
358
- stream->print(F("<script src=\""));
359
- stream->print(this->js_url_);
360
- stream->print(F("\"></script>"));
361
- }
362
- stream->print(F("</article></body></html>"));
363
- request->send(stream);
364
- }
365
156
  #elif USE_WEBSERVER_VERSION >= 2
366
157
  void WebServer::handle_index_request(AsyncWebServerRequest *request) {
367
158
  AsyncWebServerResponse *response =
@@ -334,7 +334,7 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
334
334
  /// Override the web handler's handleRequest method.
335
335
  void handleRequest(AsyncWebServerRequest *request) override;
336
336
  /// This web handle is not trivial.
337
- bool isRequestHandlerTrivial() override;
337
+ bool isRequestHandlerTrivial() override; // NOLINT(readability-identifier-naming)
338
338
 
339
339
  void add_entity_to_sorting_list(EntityBase *entity, float weight);
340
340
 
@@ -0,0 +1,217 @@
1
+ #include "web_server.h"
2
+ #include "esphome/core/application.h"
3
+
4
+ #if USE_WEBSERVER_VERSION == 1
5
+
6
+ namespace esphome {
7
+ namespace web_server {
8
+
9
+ void write_row(AsyncResponseStream *stream, EntityBase *obj, const std::string &klass, const std::string &action,
10
+ const std::function<void(AsyncResponseStream &stream, EntityBase *obj)> &action_func = nullptr) {
11
+ stream->print("<tr class=\"");
12
+ stream->print(klass.c_str());
13
+ if (obj->is_internal())
14
+ stream->print(" internal");
15
+ stream->print("\" id=\"");
16
+ stream->print(klass.c_str());
17
+ stream->print("-");
18
+ stream->print(obj->get_object_id().c_str());
19
+ stream->print("\"><td>");
20
+ stream->print(obj->get_name().c_str());
21
+ stream->print("</td><td></td><td>");
22
+ stream->print(action.c_str());
23
+ if (action_func) {
24
+ action_func(*stream, obj);
25
+ }
26
+ stream->print("</td>");
27
+ stream->print("</tr>");
28
+ }
29
+
30
+ void WebServer::set_css_url(const char *css_url) { this->css_url_ = css_url; }
31
+
32
+ void WebServer::set_js_url(const char *js_url) { this->js_url_ = js_url; }
33
+
34
+ void WebServer::handle_index_request(AsyncWebServerRequest *request) {
35
+ AsyncResponseStream *stream = request->beginResponseStream("text/html");
36
+ const std::string &title = App.get_name();
37
+ stream->print(F("<!DOCTYPE html><html lang=\"en\"><head><meta charset=UTF-8><meta "
38
+ "name=viewport content=\"width=device-width, initial-scale=1,user-scalable=no\"><title>"));
39
+ stream->print(title.c_str());
40
+ stream->print(F("</title>"));
41
+ #ifdef USE_WEBSERVER_CSS_INCLUDE
42
+ stream->print(F("<link rel=\"stylesheet\" href=\"/0.css\">"));
43
+ #endif
44
+ if (strlen(this->css_url_) > 0) {
45
+ stream->print(F(R"(<link rel="stylesheet" href=")"));
46
+ stream->print(this->css_url_);
47
+ stream->print(F("\">"));
48
+ }
49
+ stream->print(F("</head><body>"));
50
+ stream->print(F("<article class=\"markdown-body\"><h1>"));
51
+ stream->print(title.c_str());
52
+ stream->print(F("</h1>"));
53
+ stream->print(F("<h2>States</h2><table id=\"states\"><thead><tr><th>Name<th>State<th>Actions<tbody>"));
54
+
55
+ #ifdef USE_SENSOR
56
+ for (auto *obj : App.get_sensors()) {
57
+ if (this->include_internal_ || !obj->is_internal())
58
+ write_row(stream, obj, "sensor", "");
59
+ }
60
+ #endif
61
+
62
+ #ifdef USE_SWITCH
63
+ for (auto *obj : App.get_switches()) {
64
+ if (this->include_internal_ || !obj->is_internal())
65
+ write_row(stream, obj, "switch", "<button>Toggle</button>");
66
+ }
67
+ #endif
68
+
69
+ #ifdef USE_BUTTON
70
+ for (auto *obj : App.get_buttons())
71
+ write_row(stream, obj, "button", "<button>Press</button>");
72
+ #endif
73
+
74
+ #ifdef USE_BINARY_SENSOR
75
+ for (auto *obj : App.get_binary_sensors()) {
76
+ if (this->include_internal_ || !obj->is_internal())
77
+ write_row(stream, obj, "binary_sensor", "");
78
+ }
79
+ #endif
80
+
81
+ #ifdef USE_FAN
82
+ for (auto *obj : App.get_fans()) {
83
+ if (this->include_internal_ || !obj->is_internal())
84
+ write_row(stream, obj, "fan", "<button>Toggle</button>");
85
+ }
86
+ #endif
87
+
88
+ #ifdef USE_LIGHT
89
+ for (auto *obj : App.get_lights()) {
90
+ if (this->include_internal_ || !obj->is_internal())
91
+ write_row(stream, obj, "light", "<button>Toggle</button>");
92
+ }
93
+ #endif
94
+
95
+ #ifdef USE_TEXT_SENSOR
96
+ for (auto *obj : App.get_text_sensors()) {
97
+ if (this->include_internal_ || !obj->is_internal())
98
+ write_row(stream, obj, "text_sensor", "");
99
+ }
100
+ #endif
101
+
102
+ #ifdef USE_COVER
103
+ for (auto *obj : App.get_covers()) {
104
+ if (this->include_internal_ || !obj->is_internal())
105
+ write_row(stream, obj, "cover", "<button>Open</button><button>Close</button>");
106
+ }
107
+ #endif
108
+
109
+ #ifdef USE_NUMBER
110
+ for (auto *obj : App.get_numbers()) {
111
+ if (this->include_internal_ || !obj->is_internal()) {
112
+ write_row(stream, obj, "number", "", [](AsyncResponseStream &stream, EntityBase *obj) {
113
+ number::Number *number = (number::Number *) obj;
114
+ stream.print(R"(<input type="number" min=")");
115
+ stream.print(number->traits.get_min_value());
116
+ stream.print(R"(" max=")");
117
+ stream.print(number->traits.get_max_value());
118
+ stream.print(R"(" step=")");
119
+ stream.print(number->traits.get_step());
120
+ stream.print(R"(" value=")");
121
+ stream.print(number->state);
122
+ stream.print(R"("/>)");
123
+ });
124
+ }
125
+ }
126
+ #endif
127
+
128
+ #ifdef USE_TEXT
129
+ for (auto *obj : App.get_texts()) {
130
+ if (this->include_internal_ || !obj->is_internal()) {
131
+ write_row(stream, obj, "text", "", [](AsyncResponseStream &stream, EntityBase *obj) {
132
+ text::Text *text = (text::Text *) obj;
133
+ auto mode = (int) text->traits.get_mode();
134
+ stream.print(R"(<input type=")");
135
+ if (mode == 2) {
136
+ stream.print(R"(password)");
137
+ } else { // default
138
+ stream.print(R"(text)");
139
+ }
140
+ stream.print(R"(" minlength=")");
141
+ stream.print(text->traits.get_min_length());
142
+ stream.print(R"(" maxlength=")");
143
+ stream.print(text->traits.get_max_length());
144
+ stream.print(R"(" pattern=")");
145
+ stream.print(text->traits.get_pattern().c_str());
146
+ stream.print(R"(" value=")");
147
+ stream.print(text->state.c_str());
148
+ stream.print(R"("/>)");
149
+ });
150
+ }
151
+ }
152
+ #endif
153
+
154
+ #ifdef USE_SELECT
155
+ for (auto *obj : App.get_selects()) {
156
+ if (this->include_internal_ || !obj->is_internal()) {
157
+ write_row(stream, obj, "select", "", [](AsyncResponseStream &stream, EntityBase *obj) {
158
+ select::Select *select = (select::Select *) obj;
159
+ stream.print("<select>");
160
+ stream.print("<option></option>");
161
+ for (auto const &option : select->traits.get_options()) {
162
+ stream.print("<option>");
163
+ stream.print(option.c_str());
164
+ stream.print("</option>");
165
+ }
166
+ stream.print("</select>");
167
+ });
168
+ }
169
+ }
170
+ #endif
171
+
172
+ #ifdef USE_LOCK
173
+ for (auto *obj : App.get_locks()) {
174
+ if (this->include_internal_ || !obj->is_internal()) {
175
+ write_row(stream, obj, "lock", "", [](AsyncResponseStream &stream, EntityBase *obj) {
176
+ lock::Lock *lock = (lock::Lock *) obj;
177
+ stream.print("<button>Lock</button><button>Unlock</button>");
178
+ if (lock->traits.get_supports_open()) {
179
+ stream.print("<button>Open</button>");
180
+ }
181
+ });
182
+ }
183
+ }
184
+ #endif
185
+
186
+ #ifdef USE_CLIMATE
187
+ for (auto *obj : App.get_climates()) {
188
+ if (this->include_internal_ || !obj->is_internal())
189
+ write_row(stream, obj, "climate", "");
190
+ }
191
+ #endif
192
+
193
+ stream->print(F("</tbody></table><p>See <a href=\"https://esphome.io/web-api/index.html\">ESPHome Web API</a> for "
194
+ "REST API documentation.</p>"));
195
+ if (this->allow_ota_) {
196
+ stream->print(
197
+ F("<h2>OTA Update</h2><form method=\"POST\" action=\"/update\" enctype=\"multipart/form-data\"><input "
198
+ "type=\"file\" name=\"update\"><input type=\"submit\" value=\"Update\"></form>"));
199
+ }
200
+ stream->print(F("<h2>Debug Log</h2><pre id=\"log\"></pre>"));
201
+ #ifdef USE_WEBSERVER_JS_INCLUDE
202
+ if (this->js_include_ != nullptr) {
203
+ stream->print(F("<script type=\"module\" src=\"/0.js\"></script>"));
204
+ }
205
+ #endif
206
+ if (strlen(this->js_url_) > 0) {
207
+ stream->print(F("<script src=\""));
208
+ stream->print(this->js_url_);
209
+ stream->print(F("\"></script>"));
210
+ }
211
+ stream->print(F("</article></body></html>"));
212
+ request->send(stream);
213
+ }
214
+
215
+ } // namespace web_server
216
+ } // namespace esphome
217
+ #endif
@@ -134,6 +134,7 @@ class OTARequestHandler : public AsyncWebHandler {
134
134
  return request->url() == "/update" && request->method() == HTTP_POST;
135
135
  }
136
136
 
137
+ // NOLINTNEXTLINE(readability-identifier-naming)
137
138
  bool isRequestHandlerTrivial() override { return false; }
138
139
 
139
140
  protected:
@@ -1,15 +1,19 @@
1
- import esphome.codegen as cg
2
- import esphome.config_validation as cv
3
- import esphome.final_validate as fv
4
1
  from esphome import automation
5
2
  from esphome.automation import Condition
3
+ import esphome.codegen as cg
4
+ from esphome.components.esp32 import add_idf_sdkconfig_option, const, get_esp32_variant
5
+ from esphome.components.network import IPAddress
6
+ import esphome.config_validation as cv
6
7
  from esphome.const import (
7
8
  CONF_AP,
8
9
  CONF_BSSID,
10
+ CONF_CERTIFICATE,
11
+ CONF_CERTIFICATE_AUTHORITY,
9
12
  CONF_CHANNEL,
10
13
  CONF_DNS1,
11
14
  CONF_DNS2,
12
15
  CONF_DOMAIN,
16
+ CONF_EAP,
13
17
  CONF_ENABLE_BTM,
14
18
  CONF_ENABLE_ON_BOOT,
15
19
  CONF_ENABLE_RRM,
@@ -17,29 +21,26 @@ from esphome.const import (
17
21
  CONF_GATEWAY,
18
22
  CONF_HIDDEN,
19
23
  CONF_ID,
24
+ CONF_IDENTITY,
25
+ CONF_KEY,
20
26
  CONF_MANUAL_IP,
21
27
  CONF_NETWORKS,
28
+ CONF_ON_CONNECT,
29
+ CONF_ON_DISCONNECT,
22
30
  CONF_PASSWORD,
23
31
  CONF_POWER_SAVE_MODE,
32
+ CONF_PRIORITY,
24
33
  CONF_REBOOT_TIMEOUT,
25
34
  CONF_SSID,
26
35
  CONF_STATIC_IP,
27
36
  CONF_SUBNET,
37
+ CONF_TTLS_PHASE_2,
28
38
  CONF_USE_ADDRESS,
29
- CONF_PRIORITY,
30
- CONF_IDENTITY,
31
- CONF_CERTIFICATE_AUTHORITY,
32
- CONF_CERTIFICATE,
33
- CONF_KEY,
34
39
  CONF_USERNAME,
35
- CONF_EAP,
36
- CONF_TTLS_PHASE_2,
37
- CONF_ON_CONNECT,
38
- CONF_ON_DISCONNECT,
39
40
  )
40
41
  from esphome.core import CORE, HexInt, coroutine_with_priority
41
- from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant, const
42
- from esphome.components.network import IPAddress
42
+ import esphome.final_validate as fv
43
+
43
44
  from . import wpa2_eap
44
45
 
45
46
  AUTO_LOAD = ["network"]
@@ -1,4 +1,5 @@
1
1
  #include "wifi_component.h"
2
+ #ifdef USE_WIFI
2
3
  #include <cinttypes>
3
4
  #include <map>
4
5
 
@@ -856,3 +857,4 @@ WiFiComponent *global_wifi_component; // NOLINT(cppcoreguidelines-avoid-non-con
856
857
 
857
858
  } // namespace wifi
858
859
  } // namespace esphome
860
+ #endif
@@ -1,9 +1,10 @@
1
1
  #pragma once
2
2
 
3
+ #include "esphome/core/defines.h"
4
+ #ifdef USE_WIFI
3
5
  #include "esphome/components/network/ip_address.h"
4
6
  #include "esphome/core/automation.h"
5
7
  #include "esphome/core/component.h"
6
- #include "esphome/core/defines.h"
7
8
  #include "esphome/core/helpers.h"
8
9
 
9
10
  #include <string>
@@ -20,8 +21,12 @@
20
21
  #endif
21
22
 
22
23
  #if defined(USE_ESP_IDF) && defined(USE_WIFI_WPA2_EAP)
24
+ #if (ESP_IDF_VERSION_MAJOR >= 5) && (ESP_IDF_VERSION_MINOR >= 1)
25
+ #include <esp_eap_client.h>
26
+ #else
23
27
  #include <esp_wpa2.h>
24
28
  #endif
29
+ #endif
25
30
 
26
31
  #ifdef USE_ESP8266
27
32
  #include <ESP8266WiFi.h>
@@ -438,3 +443,4 @@ template<typename... Ts> class WiFiDisableAction : public Action<Ts...> {
438
443
 
439
444
  } // namespace wifi
440
445
  } // namespace esphome
446
+ #endif
@@ -1,5 +1,6 @@
1
1
  #include "wifi_component.h"
2
2
 
3
+ #ifdef USE_WIFI
3
4
  #ifdef USE_ESP32_FRAMEWORK_ARDUINO
4
5
 
5
6
  #include <esp_netif.h>
@@ -82,8 +83,8 @@ bool WiFiComponent::wifi_mode_(optional<bool> sta, optional<bool> ap) {
82
83
 
83
84
  // WiFiClass::mode above calls esp_netif_create_default_wifi_sta() and
84
85
  // esp_netif_create_default_wifi_ap(), which creates the interfaces.
85
- if (set_sta)
86
- s_sta_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
86
+ // s_sta_netif handle is set during ESPHOME_EVENT_ID_WIFI_STA_START event
87
+
87
88
  #ifdef USE_WIFI_AP
88
89
  if (set_ap)
89
90
  s_ap_netif = esp_netif_get_handle_from_ifkey("WIFI_AP_DEF");
@@ -495,6 +496,7 @@ void WiFiComponent::wifi_event_callback_(esphome_wifi_event_id_t event, esphome_
495
496
  case ESPHOME_EVENT_ID_WIFI_STA_START: {
496
497
  ESP_LOGV(TAG, "Event: WiFi STA start");
497
498
  // apply hostname
499
+ s_sta_netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
498
500
  esp_err_t err = esp_netif_set_hostname(s_sta_netif, App.get_name().c_str());
499
501
  if (err != ERR_OK) {
500
502
  ESP_LOGW(TAG, "esp_netif_set_hostname failed: %s", esp_err_to_name(err));
@@ -801,3 +803,4 @@ network::IPAddress WiFiComponent::wifi_dns_ip_(int num) { return network::IPAddr
801
803
  } // namespace esphome
802
804
 
803
805
  #endif // USE_ESP32_FRAMEWORK_ARDUINO
806
+ #endif
@@ -1,6 +1,7 @@
1
1
  #include "wifi_component.h"
2
2
  #include "esphome/core/defines.h"
3
3
 
4
+ #ifdef USE_WIFI
4
5
  #ifdef USE_ESP8266
5
6
 
6
7
  #include <user_interface.h>
@@ -834,3 +835,4 @@ void WiFiComponent::wifi_loop_() {}
834
835
  } // namespace esphome
835
836
 
836
837
  #endif
838
+ #endif