esphome 2025.9.3__py3-none-any.whl → 2025.10.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.
- esphome/__main__.py +87 -31
- esphome/address_cache.py +142 -0
- esphome/automation.py +130 -32
- esphome/build_gen/platformio.py +1 -3
- esphome/codegen.py +1 -0
- esphome/components/animation/animation.cpp +2 -2
- esphome/components/api/__init__.py +166 -3
- esphome/components/api/api_connection.cpp +84 -41
- esphome/components/api/api_connection.h +22 -16
- esphome/components/api/api_frame_helper.cpp +33 -19
- esphome/components/api/api_frame_helper.h +19 -4
- esphome/components/api/api_frame_helper_noise.cpp +41 -53
- esphome/components/api/api_frame_helper_noise.h +1 -1
- esphome/components/api/api_frame_helper_plaintext.cpp +22 -31
- esphome/components/api/api_frame_helper_plaintext.h +1 -1
- esphome/components/api/api_pb2.cpp +189 -15
- esphome/components/api/api_pb2.h +132 -20
- esphome/components/api/api_pb2_dump.cpp +97 -9
- esphome/components/api/api_pb2_service.cpp +118 -160
- esphome/components/api/api_pb2_service.h +31 -3
- esphome/components/api/api_server.cpp +68 -10
- esphome/components/api/api_server.h +32 -4
- esphome/components/api/custom_api_device.h +8 -8
- esphome/components/api/homeassistant_service.h +123 -6
- esphome/components/api/proto.h +6 -2
- esphome/components/api/user_services.h +2 -2
- esphome/components/as7341/sensor.py +1 -1
- esphome/components/audio/__init__.py +1 -1
- esphome/components/audio/audio.cpp +1 -1
- esphome/components/audio/audio_decoder.cpp +9 -9
- esphome/components/bl0906/bl0906.cpp +2 -2
- esphome/components/bl0942/bl0942.cpp +2 -2
- esphome/components/ble_client/__init__.py +1 -1
- esphome/components/bluetooth_proxy/__init__.py +4 -30
- esphome/components/bluetooth_proxy/bluetooth_connection.cpp +11 -4
- esphome/components/bluetooth_proxy/bluetooth_connection.h +2 -2
- esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +2 -2
- esphome/components/camera_encoder/__init__.py +2 -4
- esphome/components/camera_encoder/esp32_camera_jpeg_encoder.cpp +4 -2
- esphome/components/camera_encoder/esp32_camera_jpeg_encoder.h +3 -1
- esphome/components/canbus/canbus.cpp +7 -5
- esphome/components/canbus/canbus.h +4 -4
- esphome/components/captive_portal/__init__.py +18 -1
- esphome/components/captive_portal/captive_portal.cpp +40 -46
- esphome/components/captive_portal/captive_portal.h +20 -22
- esphome/components/captive_portal/dns_server_esp32_idf.cpp +205 -0
- esphome/components/captive_portal/dns_server_esp32_idf.h +27 -0
- esphome/components/ccs811/ccs811.cpp +1 -1
- esphome/components/climate/climate.cpp +10 -7
- esphome/components/cm1106/cm1106.cpp +1 -1
- esphome/components/copy/lock/copy_lock.cpp +1 -1
- esphome/components/cover/cover.cpp +1 -0
- esphome/components/daikin_arc/daikin_arc.cpp +19 -12
- esphome/components/deep_sleep/__init__.py +9 -2
- esphome/components/deep_sleep/deep_sleep_component.h +11 -9
- esphome/components/deep_sleep/deep_sleep_esp32.cpp +51 -27
- esphome/components/ektf2232/touchscreen/__init__.py +8 -5
- esphome/components/ektf2232/touchscreen/ektf2232.cpp +4 -4
- esphome/components/ektf2232/touchscreen/ektf2232.h +2 -2
- esphome/components/epaper_spi/__init__.py +1 -0
- esphome/components/epaper_spi/display.py +80 -0
- esphome/components/epaper_spi/epaper_spi.cpp +227 -0
- esphome/components/epaper_spi/epaper_spi.h +93 -0
- esphome/components/epaper_spi/epaper_spi_model_7p3in_spectra_e6.cpp +42 -0
- esphome/components/epaper_spi/epaper_spi_model_7p3in_spectra_e6.h +45 -0
- esphome/components/epaper_spi/epaper_spi_spectra_e6.cpp +135 -0
- esphome/components/epaper_spi/epaper_spi_spectra_e6.h +23 -0
- esphome/components/es7210/es7210.cpp +3 -3
- esphome/components/esp32/__init__.py +254 -339
- esphome/components/esp32/boards.py +81 -0
- esphome/components/esp32/preferences.cpp +23 -17
- esphome/components/esp32_ble/__init__.py +159 -44
- esphome/components/esp32_ble/ble.cpp +47 -3
- esphome/components/esp32_ble/ble.h +18 -0
- esphome/components/esp32_ble/ble_advertising.cpp +7 -3
- esphome/components/esp32_ble/ble_advertising.h +4 -0
- esphome/components/esp32_ble/ble_uuid.cpp +16 -42
- esphome/components/esp32_ble_beacon/__init__.py +3 -4
- esphome/components/esp32_ble_client/ble_client_base.cpp +14 -12
- esphome/components/esp32_ble_server/__init__.py +28 -14
- esphome/components/esp32_ble_server/ble_characteristic.cpp +67 -57
- esphome/components/esp32_ble_server/ble_characteristic.h +27 -16
- esphome/components/esp32_ble_server/ble_descriptor.cpp +4 -3
- esphome/components/esp32_ble_server/ble_descriptor.h +13 -9
- esphome/components/esp32_ble_server/ble_server.cpp +59 -24
- esphome/components/esp32_ble_server/ble_server.h +38 -20
- esphome/components/esp32_ble_server/ble_server_automations.cpp +49 -33
- esphome/components/esp32_ble_server/ble_server_automations.h +39 -24
- esphome/components/esp32_ble_tracker/__init__.py +25 -80
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +2 -4
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +0 -3
- esphome/components/esp32_camera/__init__.py +1 -3
- esphome/components/esp32_can/esp32_can.cpp +22 -4
- esphome/components/esp32_can/esp32_can.h +3 -0
- esphome/components/esp32_hosted/__init__.py +2 -1
- esphome/components/esp32_improv/esp32_improv_component.cpp +102 -44
- esphome/components/esp32_improv/esp32_improv_component.h +6 -1
- esphome/components/esp32_rmt_led_strip/led_strip.cpp +1 -1
- esphome/components/esp8266/__init__.py +3 -3
- esphome/components/esphome/ota/__init__.py +21 -2
- esphome/components/esphome/ota/ota_esphome.cpp +455 -145
- esphome/components/esphome/ota/ota_esphome.h +49 -2
- esphome/components/ethernet/__init__.py +39 -22
- esphome/components/ethernet/ethernet_component.cpp +28 -5
- esphome/components/ethernet/ethernet_component.h +5 -1
- esphome/components/external_components/__init__.py +8 -6
- esphome/components/fingerprint_grow/fingerprint_grow.cpp +1 -1
- esphome/components/fingerprint_grow/fingerprint_grow.h +2 -1
- esphome/components/font/__init__.py +5 -5
- esphome/components/graph/graph.cpp +1 -1
- esphome/components/graphical_display_menu/graphical_display_menu.cpp +3 -2
- esphome/components/haier/hon_climate.cpp +2 -2
- esphome/components/haier/hon_climate.h +1 -1
- esphome/components/hdc1080/hdc1080.cpp +42 -34
- esphome/components/hdc1080/hdc1080.h +1 -3
- esphome/components/homeassistant/number/homeassistant_number.cpp +2 -2
- esphome/components/homeassistant/switch/homeassistant_switch.cpp +2 -2
- esphome/components/http_request/__init__.py +3 -3
- esphome/components/htu21d/htu21d.cpp +13 -18
- esphome/components/htu21d/htu21d.h +1 -1
- esphome/components/i2s_audio/__init__.py +1 -2
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +1 -1
- esphome/components/ili9xxx/ili9xxx_display.cpp +2 -2
- esphome/components/improv_serial/improv_serial_component.cpp +12 -15
- esphome/components/improv_serial/improv_serial_component.h +6 -8
- esphome/components/json/json_util.cpp +35 -43
- esphome/components/json/json_util.h +57 -0
- esphome/components/kamstrup_kmp/kamstrup_kmp.cpp +2 -2
- esphome/components/key_collector/key_collector.h +4 -4
- esphome/components/libretiny/__init__.py +6 -6
- esphome/components/libretiny/preferences.cpp +23 -16
- esphome/components/light/light_call.cpp +98 -120
- esphome/components/light/light_call.h +17 -7
- esphome/components/lm75b/__init__.py +0 -0
- esphome/components/lm75b/lm75b.cpp +39 -0
- esphome/components/lm75b/lm75b.h +19 -0
- esphome/components/lm75b/sensor.py +34 -0
- esphome/components/lock/lock.h +12 -6
- esphome/components/logger/__init__.py +15 -27
- esphome/components/logger/logger.cpp +10 -20
- esphome/components/logger/logger.h +105 -62
- esphome/components/logger/logger_esp32.cpp +0 -48
- esphome/components/logger/logger_zephyr.cpp +2 -3
- esphome/components/logger/select/logger_level_select.cpp +6 -7
- esphome/components/logger/select/logger_level_select.h +7 -0
- esphome/components/ltr501/ltr501.cpp +7 -6
- esphome/components/ltr_als_ps/ltr_als_ps.cpp +7 -6
- esphome/components/matrix_keypad/matrix_keypad.h +4 -4
- esphome/components/max7219digit/max7219digit.cpp +1 -1
- esphome/components/mcp2515/mcp2515.cpp +31 -3
- esphome/components/mcp2515/mcp2515_defs.h +3 -1
- esphome/components/md5/md5.cpp +0 -26
- esphome/components/md5/md5.h +10 -20
- esphome/components/mdns/__init__.py +19 -6
- esphome/components/mdns/mdns_component.cpp +27 -59
- esphome/components/mdns/mdns_component.h +23 -10
- esphome/components/mdns/mdns_esp32.cpp +7 -7
- esphome/components/mdns/mdns_esp8266.cpp +6 -6
- esphome/components/mdns/mdns_libretiny.cpp +3 -3
- esphome/components/mdns/mdns_rp2040.cpp +3 -3
- esphome/components/mipi/__init__.py +1 -5
- esphome/components/mipi_spi/display.py +24 -8
- esphome/components/mipi_spi/mipi_spi.h +3 -3
- esphome/components/mixer/speaker/mixer_speaker.cpp +3 -3
- esphome/components/mmc5603/mmc5603.cpp +3 -3
- esphome/components/modbus/modbus.cpp +27 -13
- esphome/components/modbus/modbus.h +5 -3
- esphome/components/modbus/modbus_definitions.h +86 -0
- esphome/components/modbus_controller/__init__.py +29 -1
- esphome/components/modbus_controller/const.py +4 -0
- esphome/components/modbus_controller/modbus_controller.cpp +38 -13
- esphome/components/modbus_controller/modbus_controller.h +18 -29
- esphome/components/mpr121/mpr121.cpp +41 -42
- esphome/components/mpr121/mpr121.h +0 -1
- esphome/components/nau7802/nau7802.cpp +2 -2
- esphome/components/network/__init__.py +7 -3
- esphome/components/nextion/display.py +4 -4
- esphome/components/nextion/nextion.cpp +8 -8
- esphome/components/number/__init__.py +2 -0
- esphome/components/number/number_call.cpp +23 -12
- esphome/components/number/number_call.h +5 -0
- esphome/components/online_image/bmp_image.cpp +2 -1
- esphome/components/online_image/jpeg_image.cpp +4 -2
- esphome/components/openthread/openthread.cpp +6 -7
- esphome/components/openthread/openthread.h +0 -1
- esphome/components/ota/ota_backend.h +1 -0
- esphome/components/packages/__init__.py +10 -8
- esphome/components/packet_transport/packet_transport.cpp +2 -0
- esphome/components/pid/pid_controller.cpp +1 -1
- esphome/components/prometheus/prometheus_handler.cpp +239 -239
- esphome/components/psram/__init__.py +30 -28
- esphome/components/qmc5883l/qmc5883l.cpp +15 -0
- esphome/components/qmc5883l/qmc5883l.h +3 -0
- esphome/components/qmc5883l/sensor.py +31 -12
- esphome/components/remote_base/gobox_protocol.cpp +3 -3
- esphome/components/remote_receiver/__init__.py +14 -2
- esphome/components/remote_receiver/{remote_receiver_esp8266.cpp → remote_receiver.cpp} +2 -2
- esphome/components/remote_receiver/remote_receiver.h +4 -0
- esphome/components/remote_receiver/remote_receiver_esp32.cpp +18 -1
- esphome/components/remote_transmitter/__init__.py +2 -2
- esphome/components/remote_transmitter/remote_transmitter.cpp +103 -0
- esphome/components/rp2040/__init__.py +11 -11
- esphome/components/rtttl/rtttl.cpp +2 -2
- esphome/components/scd30/sensor.py +1 -1
- esphome/components/script/__init__.py +1 -1
- esphome/components/script/script.h +7 -7
- esphome/components/select/select.cpp +5 -4
- esphome/components/select/select_call.cpp +1 -1
- esphome/components/sensirion_common/i2c_sensirion.cpp +2 -1
- esphome/components/sensor/__init__.py +2 -0
- esphome/components/sha256/__init__.py +22 -0
- esphome/components/sha256/sha256.cpp +116 -0
- esphome/components/sha256/sha256.h +60 -0
- esphome/components/socket/lwip_raw_tcp_impl.cpp +34 -6
- esphome/components/sonoff_d1/sonoff_d1.cpp +1 -1
- esphome/components/spi/__init__.py +0 -3
- esphome/components/split_buffer/__init__.py +5 -0
- esphome/components/split_buffer/split_buffer.cpp +133 -0
- esphome/components/split_buffer/split_buffer.h +40 -0
- esphome/components/sps30/sps30.cpp +14 -10
- esphome/components/sps30/sps30.h +2 -0
- esphome/components/st7567_i2c/st7567_i2c.cpp +3 -1
- esphome/components/st7789v/st7789v.cpp +3 -2
- esphome/components/statsd/statsd.cpp +1 -1
- esphome/components/substitutions/__init__.py +3 -1
- esphome/components/substitutions/jinja.py +13 -3
- esphome/components/sx126x/__init__.py +16 -0
- esphome/components/sx126x/sx126x.cpp +15 -1
- esphome/components/sx126x/sx126x.h +9 -1
- esphome/components/sx126x/sx126x_reg.h +2 -0
- esphome/components/text_sensor/text_sensor.cpp +16 -0
- esphome/components/text_sensor/text_sensor.h +3 -10
- esphome/components/tormatic/tormatic_cover.cpp +1 -1
- esphome/components/tuya/select/tuya_select.cpp +1 -1
- esphome/components/tuya/tuya.cpp +29 -4
- esphome/components/uart/__init__.py +36 -26
- esphome/components/uart/uart.h +6 -0
- esphome/components/uart/uart_component.cpp +8 -0
- esphome/components/uart/uart_component.h +28 -0
- esphome/components/uart/uart_component_esp_idf.cpp +64 -10
- esphome/components/uart/uart_component_esp_idf.h +5 -2
- esphome/components/uponor_smatrix/climate/uponor_smatrix_climate.cpp +1 -1
- esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp +1 -1
- esphome/components/uponor_smatrix/uponor_smatrix.cpp +3 -3
- esphome/components/usb_host/__init__.py +2 -1
- esphome/components/usb_host/usb_host.h +82 -13
- esphome/components/usb_host/usb_host_client.cpp +180 -24
- esphome/components/usb_host/usb_host_component.cpp +1 -1
- esphome/components/usb_uart/__init__.py +0 -1
- esphome/components/usb_uart/ch34x.cpp +4 -4
- esphome/components/usb_uart/cp210x.cpp +3 -3
- esphome/components/usb_uart/usb_uart.cpp +88 -32
- esphome/components/usb_uart/usb_uart.h +30 -6
- esphome/components/valve/valve.cpp +1 -0
- esphome/components/veml7700/veml7700.cpp +7 -6
- esphome/components/version/version_text_sensor.cpp +2 -1
- esphome/components/voice_assistant/voice_assistant.cpp +3 -2
- esphome/components/waveshare_epaper/waveshare_epaper.cpp +4 -4
- esphome/components/web_server/list_entities.cpp +3 -4
- esphome/components/web_server/list_entities.h +8 -10
- esphome/components/web_server/ota/__init__.py +1 -1
- esphome/components/web_server/ota/ota_web_server.cpp +9 -3
- esphome/components/web_server/web_server.cpp +509 -404
- esphome/components/web_server/web_server.h +5 -6
- esphome/components/web_server/web_server_v1.cpp +21 -19
- esphome/components/web_server_base/__init__.py +5 -2
- esphome/components/web_server_base/web_server_base.h +27 -7
- esphome/components/web_server_idf/__init__.py +1 -1
- esphome/components/web_server_idf/multipart.cpp +2 -2
- esphome/components/web_server_idf/multipart.h +2 -2
- esphome/components/web_server_idf/utils.cpp +2 -2
- esphome/components/web_server_idf/utils.h +2 -2
- esphome/components/web_server_idf/web_server_idf.cpp +118 -26
- esphome/components/web_server_idf/web_server_idf.h +12 -10
- esphome/components/wifi/__init__.py +13 -11
- esphome/components/wifi/wifi_component.cpp +73 -56
- esphome/components/wifi/wifi_component.h +4 -4
- esphome/components/wifi/wifi_component_esp8266.cpp +1 -1
- esphome/components/wifi/wifi_component_esp_idf.cpp +24 -4
- esphome/components/wireguard/__init__.py +1 -1
- esphome/components/wts01/__init__.py +0 -0
- esphome/components/wts01/sensor.py +41 -0
- esphome/components/wts01/wts01.cpp +91 -0
- esphome/components/wts01/wts01.h +27 -0
- esphome/components/zephyr/__init__.py +5 -5
- esphome/components/zwave_proxy/__init__.py +43 -0
- esphome/components/zwave_proxy/zwave_proxy.cpp +346 -0
- esphome/components/zwave_proxy/zwave_proxy.h +93 -0
- esphome/config.py +79 -24
- esphome/config_validation.py +13 -15
- esphome/const.py +9 -2
- esphome/core/__init__.py +31 -22
- esphome/core/component.cpp +28 -18
- esphome/core/component_iterator.h +2 -1
- esphome/core/config.py +15 -15
- esphome/core/defines.h +19 -0
- esphome/core/hash_base.h +56 -0
- esphome/core/helpers.cpp +19 -3
- esphome/core/helpers.h +26 -0
- esphome/core/scheduler.cpp +5 -21
- esphome/core/scheduler.h +19 -8
- esphome/core/string_ref.h +1 -1
- esphome/core/time.cpp +5 -5
- esphome/cpp_generator.py +4 -29
- esphome/dashboard/const.py +21 -4
- esphome/dashboard/core.py +10 -8
- esphome/dashboard/dns.py +15 -0
- esphome/dashboard/entries.py +15 -21
- esphome/dashboard/models.py +76 -0
- esphome/dashboard/settings.py +7 -7
- esphome/dashboard/status/mdns.py +46 -2
- esphome/dashboard/web_server.py +367 -93
- esphome/espota2.py +111 -31
- esphome/external_files.py +6 -7
- esphome/git.py +8 -0
- esphome/helpers.py +124 -77
- esphome/loader.py +8 -9
- esphome/platformio_api.py +25 -18
- esphome/storage_json.py +26 -21
- esphome/types.py +30 -2
- esphome/util.py +32 -16
- esphome/vscode.py +8 -8
- esphome/wizard.py +10 -10
- esphome/writer.py +50 -15
- esphome/yaml_util.py +37 -31
- esphome/zeroconf.py +12 -3
- {esphome-2025.9.3.dist-info → esphome-2025.10.0b1.dist-info}/METADATA +11 -11
- {esphome-2025.9.3.dist-info → esphome-2025.10.0b1.dist-info}/RECORD +332 -312
- esphome/components/event_emitter/__init__.py +0 -5
- esphome/components/event_emitter/event_emitter.cpp +0 -14
- esphome/components/event_emitter/event_emitter.h +0 -63
- esphome/components/remote_receiver/remote_receiver_libretiny.cpp +0 -125
- esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +0 -107
- esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +0 -110
- esphome/components/uart/uart_component_esp32_arduino.cpp +0 -214
- esphome/components/uart/uart_component_esp32_arduino.h +0 -60
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +0 -860
- esphome/core/string_ref.cpp +0 -12
- esphome/dashboard/util/file.py +0 -63
- {esphome-2025.9.3.dist-info → esphome-2025.10.0b1.dist-info}/WHEEL +0 -0
- {esphome-2025.9.3.dist-info → esphome-2025.10.0b1.dist-info}/entry_points.txt +0 -0
- {esphome-2025.9.3.dist-info → esphome-2025.10.0b1.dist-info}/licenses/LICENSE +0 -0
- {esphome-2025.9.3.dist-info → esphome-2025.10.0b1.dist-info}/top_level.txt +0 -0
@@ -24,15 +24,17 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
|
|
24
24
|
this->on_hello_request(msg);
|
25
25
|
break;
|
26
26
|
}
|
27
|
-
|
28
|
-
|
27
|
+
#ifdef USE_API_PASSWORD
|
28
|
+
case AuthenticationRequest::MESSAGE_TYPE: {
|
29
|
+
AuthenticationRequest msg;
|
29
30
|
msg.decode(msg_data, msg_size);
|
30
31
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
31
|
-
ESP_LOGVV(TAG, "
|
32
|
+
ESP_LOGVV(TAG, "on_authentication_request: %s", msg.dump().c_str());
|
32
33
|
#endif
|
33
|
-
this->
|
34
|
+
this->on_authentication_request(msg);
|
34
35
|
break;
|
35
36
|
}
|
37
|
+
#endif
|
36
38
|
case DisconnectRequest::MESSAGE_TYPE: {
|
37
39
|
DisconnectRequest msg;
|
38
40
|
// Empty message: no decode needed
|
@@ -546,7 +548,7 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
|
|
546
548
|
#ifdef USE_VOICE_ASSISTANT
|
547
549
|
case VoiceAssistantConfigurationRequest::MESSAGE_TYPE: {
|
548
550
|
VoiceAssistantConfigurationRequest msg;
|
549
|
-
|
551
|
+
msg.decode(msg_data, msg_size);
|
550
552
|
#ifdef HAS_PROTO_MESSAGE_DUMP
|
551
553
|
ESP_LOGVV(TAG, "on_voice_assistant_configuration_request: %s", msg.dump().c_str());
|
552
554
|
#endif
|
@@ -586,6 +588,39 @@ void APIServerConnectionBase::read_message(uint32_t msg_size, uint32_t msg_type,
|
|
586
588
|
this->on_bluetooth_scanner_set_mode_request(msg);
|
587
589
|
break;
|
588
590
|
}
|
591
|
+
#endif
|
592
|
+
#ifdef USE_ZWAVE_PROXY
|
593
|
+
case ZWaveProxyFrame::MESSAGE_TYPE: {
|
594
|
+
ZWaveProxyFrame msg;
|
595
|
+
msg.decode(msg_data, msg_size);
|
596
|
+
#ifdef HAS_PROTO_MESSAGE_DUMP
|
597
|
+
ESP_LOGVV(TAG, "on_z_wave_proxy_frame: %s", msg.dump().c_str());
|
598
|
+
#endif
|
599
|
+
this->on_z_wave_proxy_frame(msg);
|
600
|
+
break;
|
601
|
+
}
|
602
|
+
#endif
|
603
|
+
#ifdef USE_ZWAVE_PROXY
|
604
|
+
case ZWaveProxyRequest::MESSAGE_TYPE: {
|
605
|
+
ZWaveProxyRequest msg;
|
606
|
+
msg.decode(msg_data, msg_size);
|
607
|
+
#ifdef HAS_PROTO_MESSAGE_DUMP
|
608
|
+
ESP_LOGVV(TAG, "on_z_wave_proxy_request: %s", msg.dump().c_str());
|
609
|
+
#endif
|
610
|
+
this->on_z_wave_proxy_request(msg);
|
611
|
+
break;
|
612
|
+
}
|
613
|
+
#endif
|
614
|
+
#ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES
|
615
|
+
case HomeassistantActionResponse::MESSAGE_TYPE: {
|
616
|
+
HomeassistantActionResponse msg;
|
617
|
+
msg.decode(msg_data, msg_size);
|
618
|
+
#ifdef HAS_PROTO_MESSAGE_DUMP
|
619
|
+
ESP_LOGVV(TAG, "on_homeassistant_action_response: %s", msg.dump().c_str());
|
620
|
+
#endif
|
621
|
+
this->on_homeassistant_action_response(msg);
|
622
|
+
break;
|
623
|
+
}
|
589
624
|
#endif
|
590
625
|
default:
|
591
626
|
break;
|
@@ -597,11 +632,13 @@ void APIServerConnection::on_hello_request(const HelloRequest &msg) {
|
|
597
632
|
this->on_fatal_error();
|
598
633
|
}
|
599
634
|
}
|
600
|
-
|
601
|
-
|
635
|
+
#ifdef USE_API_PASSWORD
|
636
|
+
void APIServerConnection::on_authentication_request(const AuthenticationRequest &msg) {
|
637
|
+
if (!this->send_authenticate_response(msg)) {
|
602
638
|
this->on_fatal_error();
|
603
639
|
}
|
604
640
|
}
|
641
|
+
#endif
|
605
642
|
void APIServerConnection::on_disconnect_request(const DisconnectRequest &msg) {
|
606
643
|
if (!this->send_disconnect_response(msg)) {
|
607
644
|
this->on_fatal_error();
|
@@ -613,241 +650,139 @@ void APIServerConnection::on_ping_request(const PingRequest &msg) {
|
|
613
650
|
}
|
614
651
|
}
|
615
652
|
void APIServerConnection::on_device_info_request(const DeviceInfoRequest &msg) {
|
616
|
-
if (
|
653
|
+
if (!this->send_device_info_response(msg)) {
|
617
654
|
this->on_fatal_error();
|
618
655
|
}
|
619
656
|
}
|
620
|
-
void APIServerConnection::on_list_entities_request(const ListEntitiesRequest &msg) {
|
621
|
-
if (this->check_authenticated_()) {
|
622
|
-
this->list_entities(msg);
|
623
|
-
}
|
624
|
-
}
|
657
|
+
void APIServerConnection::on_list_entities_request(const ListEntitiesRequest &msg) { this->list_entities(msg); }
|
625
658
|
void APIServerConnection::on_subscribe_states_request(const SubscribeStatesRequest &msg) {
|
626
|
-
|
627
|
-
this->subscribe_states(msg);
|
628
|
-
}
|
629
|
-
}
|
630
|
-
void APIServerConnection::on_subscribe_logs_request(const SubscribeLogsRequest &msg) {
|
631
|
-
if (this->check_authenticated_()) {
|
632
|
-
this->subscribe_logs(msg);
|
633
|
-
}
|
659
|
+
this->subscribe_states(msg);
|
634
660
|
}
|
661
|
+
void APIServerConnection::on_subscribe_logs_request(const SubscribeLogsRequest &msg) { this->subscribe_logs(msg); }
|
635
662
|
#ifdef USE_API_HOMEASSISTANT_SERVICES
|
636
663
|
void APIServerConnection::on_subscribe_homeassistant_services_request(
|
637
664
|
const SubscribeHomeassistantServicesRequest &msg) {
|
638
|
-
|
639
|
-
this->subscribe_homeassistant_services(msg);
|
640
|
-
}
|
665
|
+
this->subscribe_homeassistant_services(msg);
|
641
666
|
}
|
642
667
|
#endif
|
643
668
|
#ifdef USE_API_HOMEASSISTANT_STATES
|
644
669
|
void APIServerConnection::on_subscribe_home_assistant_states_request(const SubscribeHomeAssistantStatesRequest &msg) {
|
645
|
-
|
646
|
-
this->subscribe_home_assistant_states(msg);
|
647
|
-
}
|
670
|
+
this->subscribe_home_assistant_states(msg);
|
648
671
|
}
|
649
672
|
#endif
|
650
673
|
#ifdef USE_API_SERVICES
|
651
|
-
void APIServerConnection::on_execute_service_request(const ExecuteServiceRequest &msg) {
|
652
|
-
if (this->check_authenticated_()) {
|
653
|
-
this->execute_service(msg);
|
654
|
-
}
|
655
|
-
}
|
674
|
+
void APIServerConnection::on_execute_service_request(const ExecuteServiceRequest &msg) { this->execute_service(msg); }
|
656
675
|
#endif
|
657
676
|
#ifdef USE_API_NOISE
|
658
677
|
void APIServerConnection::on_noise_encryption_set_key_request(const NoiseEncryptionSetKeyRequest &msg) {
|
659
|
-
if (
|
678
|
+
if (!this->send_noise_encryption_set_key_response(msg)) {
|
660
679
|
this->on_fatal_error();
|
661
680
|
}
|
662
681
|
}
|
663
682
|
#endif
|
664
683
|
#ifdef USE_BUTTON
|
665
|
-
void APIServerConnection::on_button_command_request(const ButtonCommandRequest &msg) {
|
666
|
-
if (this->check_authenticated_()) {
|
667
|
-
this->button_command(msg);
|
668
|
-
}
|
669
|
-
}
|
684
|
+
void APIServerConnection::on_button_command_request(const ButtonCommandRequest &msg) { this->button_command(msg); }
|
670
685
|
#endif
|
671
686
|
#ifdef USE_CAMERA
|
672
|
-
void APIServerConnection::on_camera_image_request(const CameraImageRequest &msg) {
|
673
|
-
if (this->check_authenticated_()) {
|
674
|
-
this->camera_image(msg);
|
675
|
-
}
|
676
|
-
}
|
687
|
+
void APIServerConnection::on_camera_image_request(const CameraImageRequest &msg) { this->camera_image(msg); }
|
677
688
|
#endif
|
678
689
|
#ifdef USE_CLIMATE
|
679
|
-
void APIServerConnection::on_climate_command_request(const ClimateCommandRequest &msg) {
|
680
|
-
if (this->check_authenticated_()) {
|
681
|
-
this->climate_command(msg);
|
682
|
-
}
|
683
|
-
}
|
690
|
+
void APIServerConnection::on_climate_command_request(const ClimateCommandRequest &msg) { this->climate_command(msg); }
|
684
691
|
#endif
|
685
692
|
#ifdef USE_COVER
|
686
|
-
void APIServerConnection::on_cover_command_request(const CoverCommandRequest &msg) {
|
687
|
-
if (this->check_authenticated_()) {
|
688
|
-
this->cover_command(msg);
|
689
|
-
}
|
690
|
-
}
|
693
|
+
void APIServerConnection::on_cover_command_request(const CoverCommandRequest &msg) { this->cover_command(msg); }
|
691
694
|
#endif
|
692
695
|
#ifdef USE_DATETIME_DATE
|
693
|
-
void APIServerConnection::on_date_command_request(const DateCommandRequest &msg) {
|
694
|
-
if (this->check_authenticated_()) {
|
695
|
-
this->date_command(msg);
|
696
|
-
}
|
697
|
-
}
|
696
|
+
void APIServerConnection::on_date_command_request(const DateCommandRequest &msg) { this->date_command(msg); }
|
698
697
|
#endif
|
699
698
|
#ifdef USE_DATETIME_DATETIME
|
700
699
|
void APIServerConnection::on_date_time_command_request(const DateTimeCommandRequest &msg) {
|
701
|
-
|
702
|
-
this->datetime_command(msg);
|
703
|
-
}
|
700
|
+
this->datetime_command(msg);
|
704
701
|
}
|
705
702
|
#endif
|
706
703
|
#ifdef USE_FAN
|
707
|
-
void APIServerConnection::on_fan_command_request(const FanCommandRequest &msg) {
|
708
|
-
if (this->check_authenticated_()) {
|
709
|
-
this->fan_command(msg);
|
710
|
-
}
|
711
|
-
}
|
704
|
+
void APIServerConnection::on_fan_command_request(const FanCommandRequest &msg) { this->fan_command(msg); }
|
712
705
|
#endif
|
713
706
|
#ifdef USE_LIGHT
|
714
|
-
void APIServerConnection::on_light_command_request(const LightCommandRequest &msg) {
|
715
|
-
if (this->check_authenticated_()) {
|
716
|
-
this->light_command(msg);
|
717
|
-
}
|
718
|
-
}
|
707
|
+
void APIServerConnection::on_light_command_request(const LightCommandRequest &msg) { this->light_command(msg); }
|
719
708
|
#endif
|
720
709
|
#ifdef USE_LOCK
|
721
|
-
void APIServerConnection::on_lock_command_request(const LockCommandRequest &msg) {
|
722
|
-
if (this->check_authenticated_()) {
|
723
|
-
this->lock_command(msg);
|
724
|
-
}
|
725
|
-
}
|
710
|
+
void APIServerConnection::on_lock_command_request(const LockCommandRequest &msg) { this->lock_command(msg); }
|
726
711
|
#endif
|
727
712
|
#ifdef USE_MEDIA_PLAYER
|
728
713
|
void APIServerConnection::on_media_player_command_request(const MediaPlayerCommandRequest &msg) {
|
729
|
-
|
730
|
-
this->media_player_command(msg);
|
731
|
-
}
|
714
|
+
this->media_player_command(msg);
|
732
715
|
}
|
733
716
|
#endif
|
734
717
|
#ifdef USE_NUMBER
|
735
|
-
void APIServerConnection::on_number_command_request(const NumberCommandRequest &msg) {
|
736
|
-
if (this->check_authenticated_()) {
|
737
|
-
this->number_command(msg);
|
738
|
-
}
|
739
|
-
}
|
718
|
+
void APIServerConnection::on_number_command_request(const NumberCommandRequest &msg) { this->number_command(msg); }
|
740
719
|
#endif
|
741
720
|
#ifdef USE_SELECT
|
742
|
-
void APIServerConnection::on_select_command_request(const SelectCommandRequest &msg) {
|
743
|
-
if (this->check_authenticated_()) {
|
744
|
-
this->select_command(msg);
|
745
|
-
}
|
746
|
-
}
|
721
|
+
void APIServerConnection::on_select_command_request(const SelectCommandRequest &msg) { this->select_command(msg); }
|
747
722
|
#endif
|
748
723
|
#ifdef USE_SIREN
|
749
|
-
void APIServerConnection::on_siren_command_request(const SirenCommandRequest &msg) {
|
750
|
-
if (this->check_authenticated_()) {
|
751
|
-
this->siren_command(msg);
|
752
|
-
}
|
753
|
-
}
|
724
|
+
void APIServerConnection::on_siren_command_request(const SirenCommandRequest &msg) { this->siren_command(msg); }
|
754
725
|
#endif
|
755
726
|
#ifdef USE_SWITCH
|
756
|
-
void APIServerConnection::on_switch_command_request(const SwitchCommandRequest &msg) {
|
757
|
-
if (this->check_authenticated_()) {
|
758
|
-
this->switch_command(msg);
|
759
|
-
}
|
760
|
-
}
|
727
|
+
void APIServerConnection::on_switch_command_request(const SwitchCommandRequest &msg) { this->switch_command(msg); }
|
761
728
|
#endif
|
762
729
|
#ifdef USE_TEXT
|
763
|
-
void APIServerConnection::on_text_command_request(const TextCommandRequest &msg) {
|
764
|
-
if (this->check_authenticated_()) {
|
765
|
-
this->text_command(msg);
|
766
|
-
}
|
767
|
-
}
|
730
|
+
void APIServerConnection::on_text_command_request(const TextCommandRequest &msg) { this->text_command(msg); }
|
768
731
|
#endif
|
769
732
|
#ifdef USE_DATETIME_TIME
|
770
|
-
void APIServerConnection::on_time_command_request(const TimeCommandRequest &msg) {
|
771
|
-
if (this->check_authenticated_()) {
|
772
|
-
this->time_command(msg);
|
773
|
-
}
|
774
|
-
}
|
733
|
+
void APIServerConnection::on_time_command_request(const TimeCommandRequest &msg) { this->time_command(msg); }
|
775
734
|
#endif
|
776
735
|
#ifdef USE_UPDATE
|
777
|
-
void APIServerConnection::on_update_command_request(const UpdateCommandRequest &msg) {
|
778
|
-
if (this->check_authenticated_()) {
|
779
|
-
this->update_command(msg);
|
780
|
-
}
|
781
|
-
}
|
736
|
+
void APIServerConnection::on_update_command_request(const UpdateCommandRequest &msg) { this->update_command(msg); }
|
782
737
|
#endif
|
783
738
|
#ifdef USE_VALVE
|
784
|
-
void APIServerConnection::on_valve_command_request(const ValveCommandRequest &msg) {
|
785
|
-
if (this->check_authenticated_()) {
|
786
|
-
this->valve_command(msg);
|
787
|
-
}
|
788
|
-
}
|
739
|
+
void APIServerConnection::on_valve_command_request(const ValveCommandRequest &msg) { this->valve_command(msg); }
|
789
740
|
#endif
|
790
741
|
#ifdef USE_BLUETOOTH_PROXY
|
791
742
|
void APIServerConnection::on_subscribe_bluetooth_le_advertisements_request(
|
792
743
|
const SubscribeBluetoothLEAdvertisementsRequest &msg) {
|
793
|
-
|
794
|
-
this->subscribe_bluetooth_le_advertisements(msg);
|
795
|
-
}
|
744
|
+
this->subscribe_bluetooth_le_advertisements(msg);
|
796
745
|
}
|
797
746
|
#endif
|
798
747
|
#ifdef USE_BLUETOOTH_PROXY
|
799
748
|
void APIServerConnection::on_bluetooth_device_request(const BluetoothDeviceRequest &msg) {
|
800
|
-
|
801
|
-
this->bluetooth_device_request(msg);
|
802
|
-
}
|
749
|
+
this->bluetooth_device_request(msg);
|
803
750
|
}
|
804
751
|
#endif
|
805
752
|
#ifdef USE_BLUETOOTH_PROXY
|
806
753
|
void APIServerConnection::on_bluetooth_gatt_get_services_request(const BluetoothGATTGetServicesRequest &msg) {
|
807
|
-
|
808
|
-
this->bluetooth_gatt_get_services(msg);
|
809
|
-
}
|
754
|
+
this->bluetooth_gatt_get_services(msg);
|
810
755
|
}
|
811
756
|
#endif
|
812
757
|
#ifdef USE_BLUETOOTH_PROXY
|
813
758
|
void APIServerConnection::on_bluetooth_gatt_read_request(const BluetoothGATTReadRequest &msg) {
|
814
|
-
|
815
|
-
this->bluetooth_gatt_read(msg);
|
816
|
-
}
|
759
|
+
this->bluetooth_gatt_read(msg);
|
817
760
|
}
|
818
761
|
#endif
|
819
762
|
#ifdef USE_BLUETOOTH_PROXY
|
820
763
|
void APIServerConnection::on_bluetooth_gatt_write_request(const BluetoothGATTWriteRequest &msg) {
|
821
|
-
|
822
|
-
this->bluetooth_gatt_write(msg);
|
823
|
-
}
|
764
|
+
this->bluetooth_gatt_write(msg);
|
824
765
|
}
|
825
766
|
#endif
|
826
767
|
#ifdef USE_BLUETOOTH_PROXY
|
827
768
|
void APIServerConnection::on_bluetooth_gatt_read_descriptor_request(const BluetoothGATTReadDescriptorRequest &msg) {
|
828
|
-
|
829
|
-
this->bluetooth_gatt_read_descriptor(msg);
|
830
|
-
}
|
769
|
+
this->bluetooth_gatt_read_descriptor(msg);
|
831
770
|
}
|
832
771
|
#endif
|
833
772
|
#ifdef USE_BLUETOOTH_PROXY
|
834
773
|
void APIServerConnection::on_bluetooth_gatt_write_descriptor_request(const BluetoothGATTWriteDescriptorRequest &msg) {
|
835
|
-
|
836
|
-
this->bluetooth_gatt_write_descriptor(msg);
|
837
|
-
}
|
774
|
+
this->bluetooth_gatt_write_descriptor(msg);
|
838
775
|
}
|
839
776
|
#endif
|
840
777
|
#ifdef USE_BLUETOOTH_PROXY
|
841
778
|
void APIServerConnection::on_bluetooth_gatt_notify_request(const BluetoothGATTNotifyRequest &msg) {
|
842
|
-
|
843
|
-
this->bluetooth_gatt_notify(msg);
|
844
|
-
}
|
779
|
+
this->bluetooth_gatt_notify(msg);
|
845
780
|
}
|
846
781
|
#endif
|
847
782
|
#ifdef USE_BLUETOOTH_PROXY
|
848
783
|
void APIServerConnection::on_subscribe_bluetooth_connections_free_request(
|
849
784
|
const SubscribeBluetoothConnectionsFreeRequest &msg) {
|
850
|
-
if (
|
785
|
+
if (!this->send_subscribe_bluetooth_connections_free_response(msg)) {
|
851
786
|
this->on_fatal_error();
|
852
787
|
}
|
853
788
|
}
|
@@ -855,45 +790,68 @@ void APIServerConnection::on_subscribe_bluetooth_connections_free_request(
|
|
855
790
|
#ifdef USE_BLUETOOTH_PROXY
|
856
791
|
void APIServerConnection::on_unsubscribe_bluetooth_le_advertisements_request(
|
857
792
|
const UnsubscribeBluetoothLEAdvertisementsRequest &msg) {
|
858
|
-
|
859
|
-
this->unsubscribe_bluetooth_le_advertisements(msg);
|
860
|
-
}
|
793
|
+
this->unsubscribe_bluetooth_le_advertisements(msg);
|
861
794
|
}
|
862
795
|
#endif
|
863
796
|
#ifdef USE_BLUETOOTH_PROXY
|
864
797
|
void APIServerConnection::on_bluetooth_scanner_set_mode_request(const BluetoothScannerSetModeRequest &msg) {
|
865
|
-
|
866
|
-
this->bluetooth_scanner_set_mode(msg);
|
867
|
-
}
|
798
|
+
this->bluetooth_scanner_set_mode(msg);
|
868
799
|
}
|
869
800
|
#endif
|
870
801
|
#ifdef USE_VOICE_ASSISTANT
|
871
802
|
void APIServerConnection::on_subscribe_voice_assistant_request(const SubscribeVoiceAssistantRequest &msg) {
|
872
|
-
|
873
|
-
this->subscribe_voice_assistant(msg);
|
874
|
-
}
|
803
|
+
this->subscribe_voice_assistant(msg);
|
875
804
|
}
|
876
805
|
#endif
|
877
806
|
#ifdef USE_VOICE_ASSISTANT
|
878
807
|
void APIServerConnection::on_voice_assistant_configuration_request(const VoiceAssistantConfigurationRequest &msg) {
|
879
|
-
if (
|
808
|
+
if (!this->send_voice_assistant_get_configuration_response(msg)) {
|
880
809
|
this->on_fatal_error();
|
881
810
|
}
|
882
811
|
}
|
883
812
|
#endif
|
884
813
|
#ifdef USE_VOICE_ASSISTANT
|
885
814
|
void APIServerConnection::on_voice_assistant_set_configuration(const VoiceAssistantSetConfiguration &msg) {
|
886
|
-
|
887
|
-
this->voice_assistant_set_configuration(msg);
|
888
|
-
}
|
815
|
+
this->voice_assistant_set_configuration(msg);
|
889
816
|
}
|
890
817
|
#endif
|
891
818
|
#ifdef USE_ALARM_CONTROL_PANEL
|
892
819
|
void APIServerConnection::on_alarm_control_panel_command_request(const AlarmControlPanelCommandRequest &msg) {
|
893
|
-
|
894
|
-
this->alarm_control_panel_command(msg);
|
895
|
-
}
|
820
|
+
this->alarm_control_panel_command(msg);
|
896
821
|
}
|
897
822
|
#endif
|
823
|
+
#ifdef USE_ZWAVE_PROXY
|
824
|
+
void APIServerConnection::on_z_wave_proxy_frame(const ZWaveProxyFrame &msg) { this->zwave_proxy_frame(msg); }
|
825
|
+
#endif
|
826
|
+
#ifdef USE_ZWAVE_PROXY
|
827
|
+
void APIServerConnection::on_z_wave_proxy_request(const ZWaveProxyRequest &msg) { this->zwave_proxy_request(msg); }
|
828
|
+
#endif
|
829
|
+
|
830
|
+
void APIServerConnection::read_message(uint32_t msg_size, uint32_t msg_type, uint8_t *msg_data) {
|
831
|
+
// Check authentication/connection requirements for messages
|
832
|
+
switch (msg_type) {
|
833
|
+
case HelloRequest::MESSAGE_TYPE: // No setup required
|
834
|
+
#ifdef USE_API_PASSWORD
|
835
|
+
case AuthenticationRequest::MESSAGE_TYPE: // No setup required
|
836
|
+
#endif
|
837
|
+
case DisconnectRequest::MESSAGE_TYPE: // No setup required
|
838
|
+
case PingRequest::MESSAGE_TYPE: // No setup required
|
839
|
+
break; // Skip all checks for these messages
|
840
|
+
case DeviceInfoRequest::MESSAGE_TYPE: // Connection setup only
|
841
|
+
if (!this->check_connection_setup_()) {
|
842
|
+
return; // Connection not setup
|
843
|
+
}
|
844
|
+
break;
|
845
|
+
default:
|
846
|
+
// All other messages require authentication (which includes connection check)
|
847
|
+
if (!this->check_authenticated_()) {
|
848
|
+
return; // Authentication failed
|
849
|
+
}
|
850
|
+
break;
|
851
|
+
}
|
852
|
+
|
853
|
+
// Call base implementation to process the message
|
854
|
+
APIServerConnectionBase::read_message(msg_size, msg_type, msg_data);
|
855
|
+
}
|
898
856
|
|
899
857
|
} // namespace esphome::api
|
@@ -26,7 +26,9 @@ class APIServerConnectionBase : public ProtoService {
|
|
26
26
|
|
27
27
|
virtual void on_hello_request(const HelloRequest &value){};
|
28
28
|
|
29
|
-
|
29
|
+
#ifdef USE_API_PASSWORD
|
30
|
+
virtual void on_authentication_request(const AuthenticationRequest &value){};
|
31
|
+
#endif
|
30
32
|
|
31
33
|
virtual void on_disconnect_request(const DisconnectRequest &value){};
|
32
34
|
virtual void on_disconnect_response(const DisconnectResponse &value){};
|
@@ -64,6 +66,9 @@ class APIServerConnectionBase : public ProtoService {
|
|
64
66
|
virtual void on_subscribe_homeassistant_services_request(const SubscribeHomeassistantServicesRequest &value){};
|
65
67
|
#endif
|
66
68
|
|
69
|
+
#ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES
|
70
|
+
virtual void on_homeassistant_action_response(const HomeassistantActionResponse &value){};
|
71
|
+
#endif
|
67
72
|
#ifdef USE_API_HOMEASSISTANT_STATES
|
68
73
|
virtual void on_subscribe_home_assistant_states_request(const SubscribeHomeAssistantStatesRequest &value){};
|
69
74
|
#endif
|
@@ -205,6 +210,12 @@ class APIServerConnectionBase : public ProtoService {
|
|
205
210
|
|
206
211
|
#ifdef USE_UPDATE
|
207
212
|
virtual void on_update_command_request(const UpdateCommandRequest &value){};
|
213
|
+
#endif
|
214
|
+
#ifdef USE_ZWAVE_PROXY
|
215
|
+
virtual void on_z_wave_proxy_frame(const ZWaveProxyFrame &value){};
|
216
|
+
#endif
|
217
|
+
#ifdef USE_ZWAVE_PROXY
|
218
|
+
virtual void on_z_wave_proxy_request(const ZWaveProxyRequest &value){};
|
208
219
|
#endif
|
209
220
|
protected:
|
210
221
|
void read_message(uint32_t msg_size, uint32_t msg_type, uint8_t *msg_data) override;
|
@@ -213,7 +224,9 @@ class APIServerConnectionBase : public ProtoService {
|
|
213
224
|
class APIServerConnection : public APIServerConnectionBase {
|
214
225
|
public:
|
215
226
|
virtual bool send_hello_response(const HelloRequest &msg) = 0;
|
216
|
-
|
227
|
+
#ifdef USE_API_PASSWORD
|
228
|
+
virtual bool send_authenticate_response(const AuthenticationRequest &msg) = 0;
|
229
|
+
#endif
|
217
230
|
virtual bool send_disconnect_response(const DisconnectRequest &msg) = 0;
|
218
231
|
virtual bool send_ping_response(const PingRequest &msg) = 0;
|
219
232
|
virtual bool send_device_info_response(const DeviceInfoRequest &msg) = 0;
|
@@ -331,10 +344,18 @@ class APIServerConnection : public APIServerConnectionBase {
|
|
331
344
|
#endif
|
332
345
|
#ifdef USE_ALARM_CONTROL_PANEL
|
333
346
|
virtual void alarm_control_panel_command(const AlarmControlPanelCommandRequest &msg) = 0;
|
347
|
+
#endif
|
348
|
+
#ifdef USE_ZWAVE_PROXY
|
349
|
+
virtual void zwave_proxy_frame(const ZWaveProxyFrame &msg) = 0;
|
350
|
+
#endif
|
351
|
+
#ifdef USE_ZWAVE_PROXY
|
352
|
+
virtual void zwave_proxy_request(const ZWaveProxyRequest &msg) = 0;
|
334
353
|
#endif
|
335
354
|
protected:
|
336
355
|
void on_hello_request(const HelloRequest &msg) override;
|
337
|
-
|
356
|
+
#ifdef USE_API_PASSWORD
|
357
|
+
void on_authentication_request(const AuthenticationRequest &msg) override;
|
358
|
+
#endif
|
338
359
|
void on_disconnect_request(const DisconnectRequest &msg) override;
|
339
360
|
void on_ping_request(const PingRequest &msg) override;
|
340
361
|
void on_device_info_request(const DeviceInfoRequest &msg) override;
|
@@ -453,6 +474,13 @@ class APIServerConnection : public APIServerConnectionBase {
|
|
453
474
|
#ifdef USE_ALARM_CONTROL_PANEL
|
454
475
|
void on_alarm_control_panel_command_request(const AlarmControlPanelCommandRequest &msg) override;
|
455
476
|
#endif
|
477
|
+
#ifdef USE_ZWAVE_PROXY
|
478
|
+
void on_z_wave_proxy_frame(const ZWaveProxyFrame &msg) override;
|
479
|
+
#endif
|
480
|
+
#ifdef USE_ZWAVE_PROXY
|
481
|
+
void on_z_wave_proxy_request(const ZWaveProxyRequest &msg) override;
|
482
|
+
#endif
|
483
|
+
void read_message(uint32_t msg_size, uint32_t msg_type, uint8_t *msg_data) override;
|
456
484
|
};
|
457
485
|
|
458
486
|
} // namespace esphome::api
|
@@ -9,12 +9,16 @@
|
|
9
9
|
#include "esphome/core/log.h"
|
10
10
|
#include "esphome/core/util.h"
|
11
11
|
#include "esphome/core/version.h"
|
12
|
+
#ifdef USE_API_HOMEASSISTANT_SERVICES
|
13
|
+
#include "homeassistant_service.h"
|
14
|
+
#endif
|
12
15
|
|
13
16
|
#ifdef USE_LOGGER
|
14
17
|
#include "esphome/components/logger/logger.h"
|
15
18
|
#endif
|
16
19
|
|
17
20
|
#include <algorithm>
|
21
|
+
#include <utility>
|
18
22
|
|
19
23
|
namespace esphome::api {
|
20
24
|
|
@@ -87,7 +91,7 @@ void APIServer::setup() {
|
|
87
91
|
return;
|
88
92
|
}
|
89
93
|
|
90
|
-
err = this->socket_->listen(
|
94
|
+
err = this->socket_->listen(this->listen_backlog_);
|
91
95
|
if (err != 0) {
|
92
96
|
ESP_LOGW(TAG, "Socket unable to listen: errno %d", errno);
|
93
97
|
this->mark_failed();
|
@@ -140,9 +144,19 @@ void APIServer::loop() {
|
|
140
144
|
while (true) {
|
141
145
|
struct sockaddr_storage source_addr;
|
142
146
|
socklen_t addr_len = sizeof(source_addr);
|
147
|
+
|
143
148
|
auto sock = this->socket_->accept_loop_monitored((struct sockaddr *) &source_addr, &addr_len);
|
144
149
|
if (!sock)
|
145
150
|
break;
|
151
|
+
|
152
|
+
// Check if we're at the connection limit
|
153
|
+
if (this->clients_.size() >= this->max_connections_) {
|
154
|
+
ESP_LOGW(TAG, "Max connections (%d), rejecting %s", this->max_connections_, sock->getpeername().c_str());
|
155
|
+
// Immediately close - socket destructor will handle cleanup
|
156
|
+
sock.reset();
|
157
|
+
continue;
|
158
|
+
}
|
159
|
+
|
146
160
|
ESP_LOGD(TAG, "Accept %s", sock->getpeername().c_str());
|
147
161
|
|
148
162
|
auto *conn = new APIConnection(std::move(sock), this);
|
@@ -167,7 +181,8 @@ void APIServer::loop() {
|
|
167
181
|
// Network is down - disconnect all clients
|
168
182
|
for (auto &client : this->clients_) {
|
169
183
|
client->on_fatal_error();
|
170
|
-
ESP_LOGW(TAG, "%s: Network down; disconnect", client->
|
184
|
+
ESP_LOGW(TAG, "%s (%s): Network down; disconnect", client->client_info_.name.c_str(),
|
185
|
+
client->client_info_.peername.c_str());
|
171
186
|
}
|
172
187
|
// Continue to process and clean up the clients below
|
173
188
|
}
|
@@ -206,8 +221,10 @@ void APIServer::loop() {
|
|
206
221
|
void APIServer::dump_config() {
|
207
222
|
ESP_LOGCONFIG(TAG,
|
208
223
|
"Server:\n"
|
209
|
-
" Address: %s:%u"
|
210
|
-
|
224
|
+
" Address: %s:%u\n"
|
225
|
+
" Listen backlog: %u\n"
|
226
|
+
" Max connections: %u",
|
227
|
+
network::get_use_address().c_str(), this->port_, this->listen_backlog_, this->max_connections_);
|
211
228
|
#ifdef USE_API_NOISE
|
212
229
|
ESP_LOGCONFIG(TAG, " Noise encryption: %s", YESNO(this->noise_ctx_->has_psk()));
|
213
230
|
if (!this->noise_ctx_->has_psk()) {
|
@@ -219,12 +236,12 @@ void APIServer::dump_config() {
|
|
219
236
|
}
|
220
237
|
|
221
238
|
#ifdef USE_API_PASSWORD
|
222
|
-
bool APIServer::check_password(const
|
239
|
+
bool APIServer::check_password(const uint8_t *password_data, size_t password_len) const {
|
223
240
|
// depend only on input password length
|
224
241
|
const char *a = this->password_.c_str();
|
225
242
|
uint32_t len_a = this->password_.length();
|
226
|
-
const char *b =
|
227
|
-
uint32_t len_b =
|
243
|
+
const char *b = reinterpret_cast<const char *>(password_data);
|
244
|
+
uint32_t len_b = password_len;
|
228
245
|
|
229
246
|
// disable optimization with volatile
|
230
247
|
volatile uint32_t length = len_b;
|
@@ -247,6 +264,7 @@ bool APIServer::check_password(const std::string &password) const {
|
|
247
264
|
|
248
265
|
return result == 0;
|
249
266
|
}
|
267
|
+
|
250
268
|
#endif
|
251
269
|
|
252
270
|
void APIServer::handle_disconnect(APIConnection *conn) {}
|
@@ -357,6 +375,15 @@ void APIServer::on_update(update::UpdateEntity *obj) {
|
|
357
375
|
}
|
358
376
|
#endif
|
359
377
|
|
378
|
+
#ifdef USE_ZWAVE_PROXY
|
379
|
+
void APIServer::on_zwave_proxy_request(const esphome::api::ProtoMessage &msg) {
|
380
|
+
// We could add code to manage a second subscription type, but, since this message type is
|
381
|
+
// very infrequent and small, we simply send it to all clients
|
382
|
+
for (auto &c : this->clients_)
|
383
|
+
c->send_message(msg, api::ZWaveProxyRequest::MESSAGE_TYPE);
|
384
|
+
}
|
385
|
+
#endif
|
386
|
+
|
360
387
|
#ifdef USE_ALARM_CONTROL_PANEL
|
361
388
|
API_DISPATCH_UPDATE(alarm_control_panel::AlarmControlPanel, alarm_control_panel)
|
362
389
|
#endif
|
@@ -372,12 +399,43 @@ void APIServer::set_password(const std::string &password) { this->password_ = pa
|
|
372
399
|
void APIServer::set_batch_delay(uint16_t batch_delay) { this->batch_delay_ = batch_delay; }
|
373
400
|
|
374
401
|
#ifdef USE_API_HOMEASSISTANT_SERVICES
|
375
|
-
void APIServer::
|
402
|
+
void APIServer::send_homeassistant_action(const HomeassistantActionRequest &call) {
|
376
403
|
for (auto &client : this->clients_) {
|
377
|
-
client->
|
404
|
+
client->send_homeassistant_action(call);
|
378
405
|
}
|
379
406
|
}
|
380
|
-
#
|
407
|
+
#ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES
|
408
|
+
void APIServer::register_action_response_callback(uint32_t call_id, ActionResponseCallback callback) {
|
409
|
+
this->action_response_callbacks_.push_back({call_id, std::move(callback)});
|
410
|
+
}
|
411
|
+
|
412
|
+
void APIServer::handle_action_response(uint32_t call_id, bool success, const std::string &error_message) {
|
413
|
+
for (auto it = this->action_response_callbacks_.begin(); it != this->action_response_callbacks_.end(); ++it) {
|
414
|
+
if (it->call_id == call_id) {
|
415
|
+
auto callback = std::move(it->callback);
|
416
|
+
this->action_response_callbacks_.erase(it);
|
417
|
+
ActionResponse response(success, error_message);
|
418
|
+
callback(response);
|
419
|
+
return;
|
420
|
+
}
|
421
|
+
}
|
422
|
+
}
|
423
|
+
#ifdef USE_API_HOMEASSISTANT_ACTION_RESPONSES_JSON
|
424
|
+
void APIServer::handle_action_response(uint32_t call_id, bool success, const std::string &error_message,
|
425
|
+
const uint8_t *response_data, size_t response_data_len) {
|
426
|
+
for (auto it = this->action_response_callbacks_.begin(); it != this->action_response_callbacks_.end(); ++it) {
|
427
|
+
if (it->call_id == call_id) {
|
428
|
+
auto callback = std::move(it->callback);
|
429
|
+
this->action_response_callbacks_.erase(it);
|
430
|
+
ActionResponse response(success, error_message, response_data, response_data_len);
|
431
|
+
callback(response);
|
432
|
+
return;
|
433
|
+
}
|
434
|
+
}
|
435
|
+
}
|
436
|
+
#endif // USE_API_HOMEASSISTANT_ACTION_RESPONSES_JSON
|
437
|
+
#endif // USE_API_HOMEASSISTANT_ACTION_RESPONSES
|
438
|
+
#endif // USE_API_HOMEASSISTANT_SERVICES
|
381
439
|
|
382
440
|
#ifdef USE_API_HOMEASSISTANT_STATES
|
383
441
|
void APIServer::subscribe_home_assistant_state(std::string entity_id, optional<std::string> attribute,
|