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.
- esphome/__main__.py +15 -81
- esphome/automation.py +1 -1
- esphome/codegen.py +53 -53
- esphome/components/ade7953/sensor.py +1 -1
- esphome/components/ade7953_spi/ade7953_spi.cpp +1 -1
- esphome/components/airthings_wave_plus/airthings_wave_plus.cpp +5 -2
- esphome/components/airthings_wave_plus/airthings_wave_plus.h +2 -0
- esphome/components/airthings_wave_plus/sensor.py +12 -0
- esphome/components/alarm_control_panel/__init__.py +75 -66
- esphome/components/apds9306/__init__.py +4 -0
- esphome/components/apds9306/apds9306.cpp +151 -0
- esphome/components/apds9306/apds9306.h +66 -0
- esphome/components/apds9306/sensor.py +95 -0
- esphome/components/api/__init__.py +80 -52
- esphome/components/api/api_connection.cpp +14 -1
- esphome/components/api/api_pb2.cpp +33 -4
- esphome/components/api/api_pb2.h +8 -1
- esphome/components/api/api_server.cpp +10 -0
- esphome/components/api/api_server.h +3 -0
- esphome/components/atm90e32/__init__.py +7 -0
- esphome/components/atm90e32/atm90e32.cpp +68 -16
- esphome/components/atm90e32/atm90e32.h +20 -7
- esphome/components/atm90e32/atm90e32_reg.h +2 -0
- esphome/components/atm90e32/button/__init__.py +43 -0
- esphome/components/atm90e32/button/atm90e32_button.cpp +20 -0
- esphome/components/atm90e32/button/atm90e32_button.h +27 -0
- esphome/components/atm90e32/sensor.py +15 -11
- esphome/components/bedjet/bedjet_codec.h +1 -1
- esphome/components/binary/light/binary_light_output.h +3 -2
- esphome/components/binary_sensor/__init__.py +5 -5
- esphome/components/ble_client/__init__.py +3 -3
- esphome/components/ble_client/output/__init__.py +1 -1
- esphome/components/ble_client/sensor/__init__.py +4 -3
- esphome/components/ble_client/switch/__init__.py +2 -1
- esphome/components/ble_client/text_sensor/__init__.py +4 -3
- esphome/components/ble_presence/binary_sensor.py +3 -3
- esphome/components/ble_rssi/sensor.py +2 -2
- esphome/components/ble_scanner/text_sensor.py +1 -1
- esphome/components/bluetooth_proxy/__init__.py +3 -3
- esphome/components/bme68x_bsec2/__init__.py +196 -0
- esphome/components/bme68x_bsec2/bme68x_bsec2.cpp +523 -0
- esphome/components/bme68x_bsec2/bme68x_bsec2.h +163 -0
- esphome/components/bme68x_bsec2/sensor.py +130 -0
- esphome/components/bme68x_bsec2/text_sensor.py +33 -0
- esphome/components/bme68x_bsec2_i2c/__init__.py +28 -0
- esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.cpp +53 -0
- esphome/components/bme68x_bsec2_i2c/bme68x_bsec2_i2c.h +28 -0
- esphome/components/bmp3xx/sensor.py +1 -1
- esphome/components/button/__init__.py +4 -4
- esphome/components/climate/__init__.py +5 -5
- esphome/components/climate/climate.h +1 -1
- esphome/components/cover/__init__.py +8 -8
- esphome/components/cst226/touchscreen/cst226_touchscreen.cpp +11 -7
- esphome/components/cst226/touchscreen/cst226_touchscreen.h +1 -1
- esphome/components/datetime/__init__.py +11 -13
- esphome/components/demo/demo_sensor.h +3 -2
- esphome/components/display/display.cpp +31 -0
- esphome/components/display/display.h +3 -0
- esphome/components/display_menu_base/__init__.py +14 -13
- esphome/components/ens160/sensor.py +1 -1
- esphome/components/esp32/__init__.py +22 -10
- esphome/components/esp32/boards.py +1 -1
- esphome/components/esp32/gpio.py +12 -13
- esphome/components/esp32/gpio_esp32.py +1 -2
- esphome/components/esp32/gpio_esp32_c2.py +1 -2
- esphome/components/esp32/gpio_esp32_c3.py +1 -5
- esphome/components/esp32/gpio_esp32_c6.py +1 -2
- esphome/components/esp32/gpio_esp32_h2.py +1 -2
- esphome/components/esp32/gpio_esp32_s2.py +1 -2
- esphome/components/esp32/gpio_esp32_s3.py +1 -6
- esphome/components/esp32_ble/__init__.py +20 -3
- esphome/components/esp32_ble/ble.cpp +9 -1
- esphome/components/esp32_ble/ble.h +9 -0
- esphome/components/esp32_ble/ble_advertising.cpp +42 -9
- esphome/components/esp32_ble/ble_advertising.h +21 -1
- esphome/components/esp32_ble_beacon/__init__.py +17 -7
- esphome/components/esp32_ble_beacon/esp32_ble_beacon.cpp +45 -113
- esphome/components/esp32_ble_beacon/esp32_ble_beacon.h +17 -19
- esphome/components/esp32_ble_client/__init__.py +0 -1
- esphome/components/esp32_ble_server/__init__.py +2 -3
- esphome/components/esp32_ble_tracker/__init__.py +2 -2
- esphome/components/esp32_improv/__init__.py +2 -4
- esphome/components/ethernet/__init__.py +17 -17
- esphome/components/ethernet_info/text_sensor.py +2 -2
- esphome/components/event/__init__.py +5 -5
- esphome/components/fan/__init__.py +14 -14
- esphome/components/fan/fan.cpp +2 -2
- esphome/components/fingerprint_grow/fingerprint_grow.cpp +1 -1
- esphome/components/fingerprint_grow/fingerprint_grow.h +1 -1
- esphome/components/graphical_display_menu/__init__.py +11 -8
- esphome/components/haier/haier_base.h +2 -2
- esphome/components/homeassistant/__init__.py +8 -1
- esphome/components/homeassistant/number/__init__.py +33 -0
- esphome/components/homeassistant/number/homeassistant_number.cpp +100 -0
- esphome/components/homeassistant/number/homeassistant_number.h +31 -0
- esphome/components/homeassistant/switch/__init__.py +30 -0
- esphome/components/homeassistant/switch/homeassistant_switch.cpp +59 -0
- esphome/components/homeassistant/switch/homeassistant_switch.h +22 -0
- esphome/components/host/__init__.py +3 -7
- esphome/components/http_request/__init__.py +12 -1
- esphome/components/http_request/http_request_arduino.cpp +2 -2
- esphome/components/http_request/http_request_idf.cpp +11 -2
- esphome/components/http_request/http_request_idf.h +10 -0
- esphome/components/http_request/ota/ota_http_request.cpp +1 -1
- esphome/components/http_request/update/http_request_update.cpp +2 -2
- esphome/components/http_request/update/http_request_update.h +2 -1
- esphome/components/hx711/hx711.cpp +10 -1
- esphome/components/hydreon_rgxx/hydreon_rgxx.cpp +1 -1
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +11 -2
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +2 -0
- esphome/components/ili9xxx/ili9xxx_defines.h +3 -1
- esphome/components/ili9xxx/ili9xxx_display.cpp +9 -22
- esphome/components/ili9xxx/ili9xxx_display.h +5 -7
- esphome/components/ili9xxx/ili9xxx_init.h +4 -4
- esphome/components/improv_base/__init__.py +2 -3
- esphome/components/improv_serial/__init__.py +4 -10
- esphome/components/improv_serial/improv_serial_component.cpp +4 -0
- esphome/components/jsn_sr04t/jsn_sr04t.cpp +18 -1
- esphome/components/jsn_sr04t/jsn_sr04t.h +7 -1
- esphome/components/jsn_sr04t/sensor.py +13 -0
- esphome/components/kalman_combinator/sensor.py +1 -1
- esphome/components/light/__init__.py +16 -15
- esphome/components/light/addressable_light_effect.h +12 -8
- esphome/components/light/automation.h +16 -1
- esphome/components/light/automation.py +21 -0
- esphome/components/light/base_light_effects.h +5 -5
- esphome/components/light/esp_color_correction.h +8 -8
- esphome/components/light/types.py +7 -0
- esphome/components/lock/__init__.py +3 -3
- esphome/components/logger/__init__.py +15 -18
- esphome/components/lvgl/__init__.py +346 -0
- esphome/components/lvgl/automation.py +226 -0
- esphome/components/lvgl/binary_sensor/__init__.py +43 -0
- esphome/components/lvgl/defines.py +508 -0
- esphome/components/lvgl/encoders.py +77 -0
- esphome/components/lvgl/font.cpp +76 -0
- esphome/components/lvgl/helpers.py +49 -0
- esphome/components/lvgl/light/__init__.py +32 -0
- esphome/components/lvgl/light/lvgl_light.h +48 -0
- esphome/components/lvgl/lv_validation.py +303 -0
- esphome/components/lvgl/lvcode.py +349 -0
- esphome/components/lvgl/lvgl_esphome.cpp +407 -0
- esphome/components/lvgl/lvgl_esphome.h +274 -0
- esphome/components/lvgl/lvgl_hal.h +21 -0
- esphome/components/lvgl/number/__init__.py +66 -0
- esphome/components/lvgl/number/lvgl_number.h +34 -0
- esphome/components/lvgl/schemas.py +436 -0
- esphome/components/lvgl/select/__init__.py +55 -0
- esphome/components/lvgl/select/lvgl_select.h +62 -0
- esphome/components/lvgl/sensor/__init__.py +47 -0
- esphome/components/lvgl/styles.py +58 -0
- esphome/components/lvgl/switch/__init__.py +56 -0
- esphome/components/lvgl/switch/lvgl_switch.h +34 -0
- esphome/components/lvgl/text/__init__.py +50 -0
- esphome/components/lvgl/text/lvgl_text.h +34 -0
- esphome/components/lvgl/text_sensor/__init__.py +42 -0
- esphome/components/lvgl/touchscreens.py +45 -0
- esphome/components/lvgl/trigger.py +74 -0
- esphome/components/lvgl/types.py +191 -0
- esphome/components/lvgl/widgets/__init__.py +419 -0
- esphome/components/lvgl/widgets/animimg.py +117 -0
- esphome/components/lvgl/widgets/arc.py +78 -0
- esphome/components/lvgl/widgets/button.py +20 -0
- esphome/components/lvgl/widgets/buttonmatrix.py +275 -0
- esphome/components/lvgl/widgets/checkbox.py +27 -0
- esphome/components/lvgl/widgets/dropdown.py +76 -0
- esphome/components/lvgl/widgets/img.py +85 -0
- esphome/components/lvgl/widgets/keyboard.py +49 -0
- esphome/components/lvgl/widgets/label.py +42 -0
- esphome/components/lvgl/widgets/led.py +29 -0
- esphome/components/lvgl/widgets/line.py +50 -0
- esphome/components/lvgl/widgets/lv_bar.py +55 -0
- esphome/components/lvgl/widgets/meter.py +302 -0
- esphome/components/lvgl/widgets/msgbox.py +134 -0
- esphome/components/lvgl/widgets/obj.py +28 -0
- esphome/components/lvgl/widgets/page.py +113 -0
- esphome/components/lvgl/widgets/roller.py +77 -0
- esphome/components/lvgl/widgets/slider.py +63 -0
- esphome/components/lvgl/widgets/spinbox.py +178 -0
- esphome/components/lvgl/widgets/spinner.py +43 -0
- esphome/components/lvgl/widgets/switch.py +20 -0
- esphome/components/lvgl/widgets/tabview.py +114 -0
- esphome/components/lvgl/widgets/textarea.py +66 -0
- esphome/components/lvgl/widgets/tileview.py +128 -0
- esphome/components/m5stack_8angle/__init__.py +33 -0
- esphome/components/m5stack_8angle/binary_sensor/__init__.py +30 -0
- esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.cpp +17 -0
- esphome/components/m5stack_8angle/binary_sensor/m5stack_8angle_binary_sensor.h +19 -0
- esphome/components/m5stack_8angle/light/__init__.py +31 -0
- esphome/components/m5stack_8angle/light/m5stack_8angle_light.cpp +45 -0
- esphome/components/m5stack_8angle/light/m5stack_8angle_light.h +37 -0
- esphome/components/m5stack_8angle/m5stack_8angle.cpp +74 -0
- esphome/components/m5stack_8angle/m5stack_8angle.h +34 -0
- esphome/components/m5stack_8angle/sensor/__init__.py +66 -0
- esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.cpp +24 -0
- esphome/components/m5stack_8angle/sensor/m5stack_8angle_sensor.h +27 -0
- esphome/components/matrix_keypad/matrix_keypad.cpp +2 -0
- esphome/components/max31856/sensor.py +5 -5
- esphome/components/media_player/__init__.py +3 -5
- esphome/components/media_player/automation.h +31 -27
- esphome/components/micro_wake_word/__init__.py +20 -25
- esphome/components/micro_wake_word/streaming_model.cpp +6 -4
- esphome/components/microphone/microphone.h +4 -1
- esphome/components/mitsubishi/mitsubishi.cpp +7 -1
- esphome/components/modbus_controller/__init__.py +26 -2
- esphome/components/modbus_controller/automation.h +19 -0
- esphome/components/modbus_controller/const.py +1 -0
- esphome/components/modbus_controller/modbus_controller.cpp +8 -0
- esphome/components/modbus_controller/modbus_controller.h +3 -0
- esphome/components/mqtt/__init__.py +20 -9
- esphome/components/mqtt/mqtt_alarm_control_panel.cpp +128 -0
- esphome/components/mqtt/mqtt_alarm_control_panel.h +39 -0
- esphome/components/mqtt/mqtt_backend.h +3 -1
- esphome/components/mqtt/mqtt_backend_esp32.cpp +4 -1
- esphome/components/mqtt/mqtt_backend_esp32.h +3 -1
- esphome/components/mqtt/mqtt_backend_esp8266.h +3 -1
- esphome/components/mqtt/mqtt_backend_libretiny.h +3 -1
- esphome/components/mqtt/mqtt_client.cpp +16 -3
- esphome/components/mqtt/mqtt_client.h +5 -1
- esphome/components/mqtt/mqtt_component.cpp +32 -4
- esphome/components/mqtt/mqtt_const.h +2 -0
- esphome/components/network/__init__.py +15 -12
- esphome/components/network/ip_address.h +3 -0
- esphome/components/network/util.cpp +2 -1
- esphome/components/network/util.h +3 -1
- esphome/components/nextion/base_component.py +5 -8
- esphome/components/number/__init__.py +7 -8
- esphome/components/online_image/__init__.py +167 -0
- esphome/components/online_image/image_decoder.cpp +44 -0
- esphome/components/online_image/image_decoder.h +112 -0
- esphome/components/online_image/online_image.cpp +283 -0
- esphome/components/online_image/online_image.h +195 -0
- esphome/components/online_image/png_image.cpp +68 -0
- esphome/components/online_image/png_image.h +33 -0
- esphome/components/ota/__init__.py +8 -4
- esphome/components/pid/pid_climate.h +2 -0
- esphome/components/pmwcs3/pmwcs3.cpp +31 -30
- esphome/components/remote_base/pronto_protocol.cpp +0 -3
- esphome/components/remote_transmitter/remote_transmitter.h +1 -1
- esphome/components/rgbct/rgbct_light_output.h +3 -2
- esphome/components/rgbw/rgbw_light_output.h +3 -2
- esphome/components/rgbww/rgbww_light_output.h +3 -2
- esphome/components/rp2040_pio_led_strip/led_strip.cpp +31 -5
- esphome/components/rp2040_pio_led_strip/led_strip.h +5 -0
- esphome/components/rtttl/rtttl.cpp +108 -21
- esphome/components/rtttl/rtttl.h +15 -6
- esphome/components/select/__init__.py +7 -7
- esphome/components/sensor/__init__.py +29 -10
- esphome/components/sensor/filter.cpp +8 -0
- esphome/components/sensor/filter.h +9 -0
- esphome/components/sml/sml_parser.cpp +48 -22
- esphome/components/socket/socket.cpp +11 -14
- esphome/components/speaker/__init__.py +14 -5
- esphome/components/speaker/automation.h +10 -0
- esphome/components/speaker/speaker.h +9 -0
- esphome/components/spi/spi.cpp +0 -6
- esphome/components/spi/spi.h +2 -19
- esphome/components/spi_led_strip/spi_led_strip.h +5 -4
- esphome/components/sprinkler/sprinkler.cpp +2 -2
- esphome/components/sprinkler/sprinkler.h +1 -1
- esphome/components/switch/__init__.py +3 -3
- esphome/components/text/__init__.py +5 -5
- esphome/components/text_sensor/__init__.py +7 -7
- esphome/components/time/__init__.py +8 -8
- esphome/components/touchscreen/binary_sensor/__init__.py +24 -10
- esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.cpp +3 -2
- esphome/components/touchscreen/binary_sensor/touchscreen_binary_sensor.h +4 -2
- esphome/components/uart/uart_component_host.cpp +6 -2
- esphome/components/update/__init__.py +33 -15
- esphome/components/update/automation.h +23 -0
- esphome/components/update/update_entity.h +3 -1
- esphome/components/valve/__init__.py +3 -3
- esphome/components/voice_assistant/__init__.py +7 -8
- esphome/components/wake_on_lan/wake_on_lan.cpp +2 -0
- esphome/components/wake_on_lan/wake_on_lan.h +3 -1
- esphome/components/watchdog/__init__.py +1 -0
- esphome/components/{http_request → watchdog}/watchdog.cpp +0 -2
- esphome/components/{http_request → watchdog}/watchdog.h +0 -2
- esphome/components/waveshare_epaper/waveshare_epaper.cpp +5 -5
- esphome/components/web_server/server_index_v3.h +3615 -3603
- esphome/components/web_server/web_server.cpp +0 -209
- esphome/components/web_server/web_server.h +1 -1
- esphome/components/web_server/web_server_v1.cpp +217 -0
- esphome/components/web_server_base/web_server_base.h +1 -0
- esphome/components/wifi/__init__.py +15 -14
- esphome/components/wifi/wifi_component.cpp +2 -0
- esphome/components/wifi/wifi_component.h +7 -1
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +5 -2
- esphome/components/wifi/wifi_component_esp8266.cpp +2 -0
- esphome/components/wifi/wifi_component_esp_idf.cpp +43 -7
- esphome/components/wifi/wifi_component_libretiny.cpp +2 -0
- esphome/components/wifi/wifi_component_pico_w.cpp +2 -0
- esphome/components/wifi/wpa2_eap.py +6 -7
- esphome/components/wifi_info/text_sensor.py +3 -3
- esphome/components/wifi_info/wifi_info_text_sensor.cpp +2 -0
- esphome/components/wifi_info/wifi_info_text_sensor.h +2 -0
- esphome/components/wifi_signal/sensor.py +1 -1
- esphome/components/wifi_signal/wifi_signal_sensor.cpp +2 -0
- esphome/components/wifi_signal/wifi_signal_sensor.h +2 -1
- esphome/components/xiaomi_ble/xiaomi_ble.cpp +20 -3
- esphome/components/xiaomi_ble/xiaomi_ble.h +1 -0
- esphome/components/xiaomi_lywsd02mmc/__init__.py +0 -0
- esphome/components/xiaomi_lywsd02mmc/sensor.py +77 -0
- esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.cpp +73 -0
- esphome/components/xiaomi_lywsd02mmc/xiaomi_lywsd02mmc.h +37 -0
- esphome/config.py +17 -19
- esphome/config_validation.py +55 -23
- esphome/const.py +25 -9
- esphome/core/__init__.py +17 -14
- esphome/core/application.h +42 -21
- esphome/core/automation.h +5 -3
- esphome/core/base_automation.h +3 -2
- esphome/core/bytebuffer.cpp +134 -0
- esphome/core/bytebuffer.h +96 -0
- esphome/core/color.h +24 -16
- esphome/core/config.py +3 -3
- esphome/core/defines.h +14 -1
- esphome/core/entity_base.h +2 -2
- esphome/core/entity_helpers.py +1 -2
- esphome/core/gpio.h +0 -18
- esphome/core/helpers.h +1 -1
- esphome/core/optional.h +15 -16
- esphome/coroutine.py +1 -1
- esphome/cpp_generator.py +1 -1
- esphome/cpp_helpers.py +3 -5
- esphome/dashboard/core.py +3 -3
- esphome/dashboard/dashboard.py +3 -3
- esphome/dashboard/entries.py +1 -1
- esphome/dashboard/util/file.py +1 -1
- esphome/dashboard/web_server.py +3 -3
- esphome/external_files.py +5 -3
- esphome/final_validate.py +2 -2
- esphome/git.py +4 -4
- esphome/helpers.py +5 -5
- esphome/loader.py +15 -10
- esphome/mqtt.py +4 -8
- esphome/pins.py +6 -6
- esphome/platformio_api.py +5 -5
- esphome/storage_json.py +2 -1
- esphome/types.py +1 -1
- esphome/util.py +2 -3
- esphome/voluptuous_schema.py +1 -0
- esphome/vscode.py +5 -4
- esphome/wizard.py +1 -1
- esphome/writer.py +7 -7
- esphome/yaml_util.py +3 -3
- esphome/zeroconf.py +1 -1
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/METADATA +3 -3
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/RECORD +353 -247
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/LICENSE +0 -0
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/WHEEL +0 -0
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/entry_points.txt +0 -0
- {esphome-2024.7.2.dist-info → esphome-2024.8.0.dist-info}/top_level.txt +0 -0
esphome/components/esp32/gpio.py
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
from dataclasses import dataclass
|
2
|
-
from typing import Any
|
3
2
|
import logging
|
3
|
+
from typing import Any
|
4
4
|
|
5
|
+
from esphome import pins
|
6
|
+
import esphome.codegen as cg
|
7
|
+
import esphome.config_validation as cv
|
5
8
|
from esphome.const import (
|
6
9
|
CONF_ID,
|
10
|
+
CONF_IGNORE_PIN_VALIDATION_ERROR,
|
11
|
+
CONF_IGNORE_STRAPPING_WARNING,
|
7
12
|
CONF_INVERTED,
|
8
13
|
CONF_MODE,
|
9
14
|
CONF_NUMBER,
|
10
15
|
CONF_OPEN_DRAIN,
|
11
16
|
CONF_OUTPUT,
|
12
|
-
CONF_IGNORE_PIN_VALIDATION_ERROR,
|
13
|
-
CONF_IGNORE_STRAPPING_WARNING,
|
14
17
|
PLATFORM_ESP32,
|
15
18
|
)
|
16
|
-
from esphome import pins
|
17
19
|
from esphome.core import CORE
|
18
|
-
import esphome.config_validation as cv
|
19
|
-
import esphome.codegen as cg
|
20
20
|
|
21
21
|
from . import boards
|
22
22
|
from .const import (
|
@@ -24,22 +24,21 @@ from .const import (
|
|
24
24
|
KEY_ESP32,
|
25
25
|
KEY_VARIANT,
|
26
26
|
VARIANT_ESP32,
|
27
|
-
VARIANT_ESP32C3,
|
28
|
-
VARIANT_ESP32S2,
|
29
|
-
VARIANT_ESP32S3,
|
30
27
|
VARIANT_ESP32C2,
|
28
|
+
VARIANT_ESP32C3,
|
31
29
|
VARIANT_ESP32C6,
|
32
30
|
VARIANT_ESP32H2,
|
31
|
+
VARIANT_ESP32S2,
|
32
|
+
VARIANT_ESP32S3,
|
33
33
|
esp32_ns,
|
34
34
|
)
|
35
|
-
|
36
35
|
from .gpio_esp32 import esp32_validate_gpio_pin, esp32_validate_supports
|
37
|
-
from .gpio_esp32_s2 import esp32_s2_validate_gpio_pin, esp32_s2_validate_supports
|
38
|
-
from .gpio_esp32_c3 import esp32_c3_validate_gpio_pin, esp32_c3_validate_supports
|
39
|
-
from .gpio_esp32_s3 import esp32_s3_validate_gpio_pin, esp32_s3_validate_supports
|
40
36
|
from .gpio_esp32_c2 import esp32_c2_validate_gpio_pin, esp32_c2_validate_supports
|
37
|
+
from .gpio_esp32_c3 import esp32_c3_validate_gpio_pin, esp32_c3_validate_supports
|
41
38
|
from .gpio_esp32_c6 import esp32_c6_validate_gpio_pin, esp32_c6_validate_supports
|
42
39
|
from .gpio_esp32_h2 import esp32_h2_validate_gpio_pin, esp32_h2_validate_supports
|
40
|
+
from .gpio_esp32_s2 import esp32_s2_validate_gpio_pin, esp32_s2_validate_supports
|
41
|
+
from .gpio_esp32_s3 import esp32_s3_validate_gpio_pin, esp32_s3_validate_supports
|
43
42
|
|
44
43
|
ESP32InternalGPIOPin = esp32_ns.class_("ESP32InternalGPIOPin", cg.InternalGPIOPin)
|
45
44
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
|
+
import esphome.config_validation as cv
|
3
4
|
from esphome.const import (
|
4
5
|
CONF_INPUT,
|
5
6
|
CONF_MODE,
|
@@ -8,10 +9,8 @@ from esphome.const import (
|
|
8
9
|
CONF_PULLDOWN,
|
9
10
|
CONF_PULLUP,
|
10
11
|
)
|
11
|
-
import esphome.config_validation as cv
|
12
12
|
from esphome.pins import check_strapping_pin
|
13
13
|
|
14
|
-
|
15
14
|
_ESP_SDIO_PINS = {
|
16
15
|
6: "Flash Clock",
|
17
16
|
7: "Flash Data 0",
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
|
+
import esphome.config_validation as cv
|
3
4
|
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER
|
4
5
|
from esphome.pins import check_strapping_pin
|
5
6
|
|
6
|
-
import esphome.config_validation as cv
|
7
|
-
|
8
7
|
_ESP32C2_STRAPPING_PINS = {8, 9}
|
9
8
|
|
10
9
|
_LOGGER = logging.getLogger(__name__)
|
@@ -1,11 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
|
-
from esphome.const import (
|
4
|
-
CONF_INPUT,
|
5
|
-
CONF_MODE,
|
6
|
-
CONF_NUMBER,
|
7
|
-
)
|
8
3
|
import esphome.config_validation as cv
|
4
|
+
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER
|
9
5
|
from esphome.pins import check_strapping_pin
|
10
6
|
|
11
7
|
_ESP32C3_SPI_PSRAM_PINS = {
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
|
-
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER
|
4
|
-
|
5
3
|
import esphome.config_validation as cv
|
4
|
+
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER
|
6
5
|
from esphome.pins import check_strapping_pin
|
7
6
|
|
8
7
|
_ESP32C6_SPI_PSRAM_PINS = {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
|
+
import esphome.config_validation as cv
|
3
4
|
from esphome.const import (
|
4
5
|
CONF_INPUT,
|
5
6
|
CONF_MODE,
|
@@ -8,8 +9,6 @@ from esphome.const import (
|
|
8
9
|
CONF_PULLDOWN,
|
9
10
|
CONF_PULLUP,
|
10
11
|
)
|
11
|
-
|
12
|
-
import esphome.config_validation as cv
|
13
12
|
from esphome.pins import check_strapping_pin
|
14
13
|
|
15
14
|
_ESP32S2_SPI_PSRAM_PINS = {
|
@@ -1,12 +1,7 @@
|
|
1
1
|
import logging
|
2
2
|
|
3
|
-
from esphome.const import (
|
4
|
-
CONF_INPUT,
|
5
|
-
CONF_MODE,
|
6
|
-
CONF_NUMBER,
|
7
|
-
)
|
8
|
-
|
9
3
|
import esphome.config_validation as cv
|
4
|
+
from esphome.const import CONF_INPUT, CONF_MODE, CONF_NUMBER
|
10
5
|
from esphome.pins import check_strapping_pin
|
11
6
|
|
12
7
|
_ESP_32S3_SPI_PSRAM_PINS = {
|
@@ -1,16 +1,16 @@
|
|
1
|
+
from esphome import automation
|
1
2
|
import esphome.codegen as cg
|
3
|
+
from esphome.components.esp32 import add_idf_sdkconfig_option, const, get_esp32_variant
|
2
4
|
import esphome.config_validation as cv
|
3
|
-
from esphome import automation
|
4
5
|
from esphome.const import CONF_ENABLE_ON_BOOT, CONF_ID
|
5
6
|
from esphome.core import CORE
|
6
|
-
from esphome.components.esp32 import add_idf_sdkconfig_option, get_esp32_variant, const
|
7
7
|
|
8
8
|
DEPENDENCIES = ["esp32"]
|
9
9
|
CODEOWNERS = ["@jesserockz", "@Rapsssito"]
|
10
|
-
CONFLICTS_WITH = ["esp32_ble_beacon"]
|
11
10
|
|
12
11
|
CONF_BLE_ID = "ble_id"
|
13
12
|
CONF_IO_CAPABILITY = "io_capability"
|
13
|
+
CONF_ADVERTISING_CYCLE_TIME = "advertising_cycle_time"
|
14
14
|
|
15
15
|
NO_BLUETOOTH_VARIANTS = [const.VARIANT_ESP32S2]
|
16
16
|
|
@@ -34,6 +34,19 @@ IO_CAPABILITY = {
|
|
34
34
|
"display_yes_no": IoCapability.IO_CAP_IO,
|
35
35
|
}
|
36
36
|
|
37
|
+
esp_power_level_t = cg.global_ns.enum("esp_power_level_t")
|
38
|
+
|
39
|
+
TX_POWER_LEVELS = {
|
40
|
+
-12: esp_power_level_t.ESP_PWR_LVL_N12,
|
41
|
+
-9: esp_power_level_t.ESP_PWR_LVL_N9,
|
42
|
+
-6: esp_power_level_t.ESP_PWR_LVL_N6,
|
43
|
+
-3: esp_power_level_t.ESP_PWR_LVL_N3,
|
44
|
+
0: esp_power_level_t.ESP_PWR_LVL_N0,
|
45
|
+
3: esp_power_level_t.ESP_PWR_LVL_P3,
|
46
|
+
6: esp_power_level_t.ESP_PWR_LVL_P6,
|
47
|
+
9: esp_power_level_t.ESP_PWR_LVL_P9,
|
48
|
+
}
|
49
|
+
|
37
50
|
CONFIG_SCHEMA = cv.Schema(
|
38
51
|
{
|
39
52
|
cv.GenerateID(): cv.declare_id(ESP32BLE),
|
@@ -41,6 +54,9 @@ CONFIG_SCHEMA = cv.Schema(
|
|
41
54
|
IO_CAPABILITY, lower=True
|
42
55
|
),
|
43
56
|
cv.Optional(CONF_ENABLE_ON_BOOT, default=True): cv.boolean,
|
57
|
+
cv.Optional(
|
58
|
+
CONF_ADVERTISING_CYCLE_TIME, default="10s"
|
59
|
+
): cv.positive_time_period_milliseconds,
|
44
60
|
}
|
45
61
|
).extend(cv.COMPONENT_SCHEMA)
|
46
62
|
|
@@ -58,6 +74,7 @@ async def to_code(config):
|
|
58
74
|
var = cg.new_Pvariable(config[CONF_ID])
|
59
75
|
cg.add(var.set_enable_on_boot(config[CONF_ENABLE_ON_BOOT]))
|
60
76
|
cg.add(var.set_io_capability(config[CONF_IO_CAPABILITY]))
|
77
|
+
cg.add(var.set_advertising_cycle_time(config[CONF_ADVERTISING_CYCLE_TIME]))
|
61
78
|
await cg.register_component(var, config)
|
62
79
|
|
63
80
|
if CORE.using_esp_idf:
|
@@ -78,6 +78,11 @@ void ESP32BLE::advertising_set_manufacturer_data(const std::vector<uint8_t> &dat
|
|
78
78
|
this->advertising_start();
|
79
79
|
}
|
80
80
|
|
81
|
+
void ESP32BLE::advertising_register_raw_advertisement_callback(std::function<void(bool)> &&callback) {
|
82
|
+
this->advertising_init_();
|
83
|
+
this->advertising_->register_raw_advertisement_callback(std::move(callback));
|
84
|
+
}
|
85
|
+
|
81
86
|
void ESP32BLE::advertising_add_service_uuid(ESPBTUUID uuid) {
|
82
87
|
this->advertising_init_();
|
83
88
|
this->advertising_->add_service_uuid(uuid);
|
@@ -102,7 +107,7 @@ bool ESP32BLE::ble_pre_setup_() {
|
|
102
107
|
void ESP32BLE::advertising_init_() {
|
103
108
|
if (this->advertising_ != nullptr)
|
104
109
|
return;
|
105
|
-
this->advertising_ = new BLEAdvertising(); // NOLINT(cppcoreguidelines-owning-memory)
|
110
|
+
this->advertising_ = new BLEAdvertising(this->advertising_cycle_time_); // NOLINT(cppcoreguidelines-owning-memory)
|
106
111
|
|
107
112
|
this->advertising_->set_scan_response(true);
|
108
113
|
this->advertising_->set_min_preferred_interval(0x06);
|
@@ -312,6 +317,9 @@ void ESP32BLE::loop() {
|
|
312
317
|
delete ble_event; // NOLINT(cppcoreguidelines-owning-memory)
|
313
318
|
ble_event = this->ble_events_.pop();
|
314
319
|
}
|
320
|
+
if (this->advertising_ != nullptr) {
|
321
|
+
this->advertising_->loop();
|
322
|
+
}
|
315
323
|
}
|
316
324
|
|
317
325
|
void ESP32BLE::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) {
|
@@ -3,6 +3,8 @@
|
|
3
3
|
#include "ble_advertising.h"
|
4
4
|
#include "ble_uuid.h"
|
5
5
|
|
6
|
+
#include <functional>
|
7
|
+
|
6
8
|
#include "esphome/core/automation.h"
|
7
9
|
#include "esphome/core/component.h"
|
8
10
|
#include "esphome/core/defines.h"
|
@@ -76,6 +78,11 @@ class ESP32BLE : public Component {
|
|
76
78
|
public:
|
77
79
|
void set_io_capability(IoCapability io_capability) { this->io_cap_ = (esp_ble_io_cap_t) io_capability; }
|
78
80
|
|
81
|
+
void set_advertising_cycle_time(uint32_t advertising_cycle_time) {
|
82
|
+
this->advertising_cycle_time_ = advertising_cycle_time;
|
83
|
+
}
|
84
|
+
uint32_t get_advertising_cycle_time() const { return this->advertising_cycle_time_; }
|
85
|
+
|
79
86
|
void enable();
|
80
87
|
void disable();
|
81
88
|
bool is_active();
|
@@ -89,6 +96,7 @@ class ESP32BLE : public Component {
|
|
89
96
|
void advertising_set_manufacturer_data(const std::vector<uint8_t> &data);
|
90
97
|
void advertising_add_service_uuid(ESPBTUUID uuid);
|
91
98
|
void advertising_remove_service_uuid(ESPBTUUID uuid);
|
99
|
+
void advertising_register_raw_advertisement_callback(std::function<void(bool)> &&callback);
|
92
100
|
|
93
101
|
void register_gap_event_handler(GAPEventHandler *handler) { this->gap_event_handlers_.push_back(handler); }
|
94
102
|
void register_gattc_event_handler(GATTcEventHandler *handler) { this->gattc_event_handlers_.push_back(handler); }
|
@@ -121,6 +129,7 @@ class ESP32BLE : public Component {
|
|
121
129
|
Queue<BLEEvent> ble_events_;
|
122
130
|
BLEAdvertising *advertising_;
|
123
131
|
esp_ble_io_cap_t io_cap_{ESP_IO_CAP_NONE};
|
132
|
+
uint32_t advertising_cycle_time_;
|
124
133
|
bool enable_on_boot_;
|
125
134
|
};
|
126
135
|
|
@@ -10,9 +10,9 @@
|
|
10
10
|
namespace esphome {
|
11
11
|
namespace esp32_ble {
|
12
12
|
|
13
|
-
static const char *const TAG = "esp32_ble";
|
13
|
+
static const char *const TAG = "esp32_ble.advertising";
|
14
14
|
|
15
|
-
BLEAdvertising::BLEAdvertising() {
|
15
|
+
BLEAdvertising::BLEAdvertising(uint32_t advertising_cycle_time) : advertising_cycle_time_(advertising_cycle_time) {
|
16
16
|
this->advertising_data_.set_scan_rsp = false;
|
17
17
|
this->advertising_data_.include_name = true;
|
18
18
|
this->advertising_data_.include_txpower = true;
|
@@ -64,7 +64,7 @@ void BLEAdvertising::set_manufacturer_data(const std::vector<uint8_t> &data) {
|
|
64
64
|
}
|
65
65
|
}
|
66
66
|
|
67
|
-
|
67
|
+
esp_err_t BLEAdvertising::services_advertisement_() {
|
68
68
|
int num_services = this->advertising_uuids_.size();
|
69
69
|
if (num_services == 0) {
|
70
70
|
this->advertising_data_.service_uuid_len = 0;
|
@@ -87,8 +87,8 @@ void BLEAdvertising::start() {
|
|
87
87
|
this->advertising_data_.include_txpower = !this->scan_response_;
|
88
88
|
err = esp_ble_gap_config_adv_data(&this->advertising_data_);
|
89
89
|
if (err != ESP_OK) {
|
90
|
-
ESP_LOGE(TAG, "esp_ble_gap_config_adv_data failed (Advertising): %
|
91
|
-
return;
|
90
|
+
ESP_LOGE(TAG, "esp_ble_gap_config_adv_data failed (Advertising): %s", esp_err_to_name(err));
|
91
|
+
return err;
|
92
92
|
}
|
93
93
|
|
94
94
|
if (this->scan_response_) {
|
@@ -101,8 +101,8 @@ void BLEAdvertising::start() {
|
|
101
101
|
this->scan_response_data_.flag = 0;
|
102
102
|
err = esp_ble_gap_config_adv_data(&this->scan_response_data_);
|
103
103
|
if (err != ESP_OK) {
|
104
|
-
ESP_LOGE(TAG, "esp_ble_gap_config_adv_data failed (Scan response): %
|
105
|
-
return;
|
104
|
+
ESP_LOGE(TAG, "esp_ble_gap_config_adv_data failed (Scan response): %s", esp_err_to_name(err));
|
105
|
+
return err;
|
106
106
|
}
|
107
107
|
}
|
108
108
|
|
@@ -113,8 +113,18 @@ void BLEAdvertising::start() {
|
|
113
113
|
|
114
114
|
err = esp_ble_gap_start_advertising(&this->advertising_params_);
|
115
115
|
if (err != ESP_OK) {
|
116
|
-
ESP_LOGE(TAG, "esp_ble_gap_start_advertising failed: %
|
117
|
-
return;
|
116
|
+
ESP_LOGE(TAG, "esp_ble_gap_start_advertising failed: %s", esp_err_to_name(err));
|
117
|
+
return err;
|
118
|
+
}
|
119
|
+
|
120
|
+
return ESP_OK;
|
121
|
+
}
|
122
|
+
|
123
|
+
void BLEAdvertising::start() {
|
124
|
+
if (this->current_adv_index_ == -1) {
|
125
|
+
this->services_advertisement_();
|
126
|
+
} else {
|
127
|
+
this->raw_advertisements_callbacks_[this->current_adv_index_](true);
|
118
128
|
}
|
119
129
|
}
|
120
130
|
|
@@ -124,6 +134,29 @@ void BLEAdvertising::stop() {
|
|
124
134
|
ESP_LOGE(TAG, "esp_ble_gap_stop_advertising failed: %d", err);
|
125
135
|
return;
|
126
136
|
}
|
137
|
+
if (this->current_adv_index_ != -1) {
|
138
|
+
this->raw_advertisements_callbacks_[this->current_adv_index_](false);
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
void BLEAdvertising::loop() {
|
143
|
+
if (this->raw_advertisements_callbacks_.empty()) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
const uint32_t now = millis();
|
147
|
+
if (now - this->last_advertisement_time_ > this->advertising_cycle_time_) {
|
148
|
+
this->stop();
|
149
|
+
this->current_adv_index_ += 1;
|
150
|
+
if (this->current_adv_index_ >= this->raw_advertisements_callbacks_.size()) {
|
151
|
+
this->current_adv_index_ = -1;
|
152
|
+
}
|
153
|
+
this->start();
|
154
|
+
this->last_advertisement_time_ = now;
|
155
|
+
}
|
156
|
+
}
|
157
|
+
|
158
|
+
void BLEAdvertising::register_raw_advertisement_callback(std::function<void(bool)> &&callback) {
|
159
|
+
this->raw_advertisements_callbacks_.push_back(std::move(callback));
|
127
160
|
}
|
128
161
|
|
129
162
|
} // namespace esp32_ble
|
@@ -1,20 +1,31 @@
|
|
1
1
|
#pragma once
|
2
2
|
|
3
|
+
#include <array>
|
4
|
+
#include <functional>
|
3
5
|
#include <vector>
|
4
6
|
|
5
7
|
#ifdef USE_ESP32
|
6
8
|
|
9
|
+
#include <esp_bt.h>
|
7
10
|
#include <esp_gap_ble_api.h>
|
8
11
|
#include <esp_gatts_api.h>
|
9
12
|
|
10
13
|
namespace esphome {
|
11
14
|
namespace esp32_ble {
|
12
15
|
|
16
|
+
using raw_adv_data_t = struct {
|
17
|
+
uint8_t *data;
|
18
|
+
size_t length;
|
19
|
+
esp_power_level_t power_level;
|
20
|
+
};
|
21
|
+
|
13
22
|
class ESPBTUUID;
|
14
23
|
|
15
24
|
class BLEAdvertising {
|
16
25
|
public:
|
17
|
-
BLEAdvertising();
|
26
|
+
BLEAdvertising(uint32_t advertising_cycle_time);
|
27
|
+
|
28
|
+
void loop();
|
18
29
|
|
19
30
|
void add_service_uuid(ESPBTUUID uuid);
|
20
31
|
void remove_service_uuid(ESPBTUUID uuid);
|
@@ -22,16 +33,25 @@ class BLEAdvertising {
|
|
22
33
|
void set_min_preferred_interval(uint16_t interval) { this->advertising_data_.min_interval = interval; }
|
23
34
|
void set_manufacturer_data(const std::vector<uint8_t> &data);
|
24
35
|
void set_service_data(const std::vector<uint8_t> &data);
|
36
|
+
void register_raw_advertisement_callback(std::function<void(bool)> &&callback);
|
25
37
|
|
26
38
|
void start();
|
27
39
|
void stop();
|
28
40
|
|
29
41
|
protected:
|
42
|
+
esp_err_t services_advertisement_();
|
43
|
+
|
30
44
|
bool scan_response_;
|
31
45
|
esp_ble_adv_data_t advertising_data_;
|
32
46
|
esp_ble_adv_data_t scan_response_data_;
|
33
47
|
esp_ble_adv_params_t advertising_params_;
|
34
48
|
std::vector<ESPBTUUID> advertising_uuids_;
|
49
|
+
|
50
|
+
std::vector<std::function<void(bool)>> raw_advertisements_callbacks_;
|
51
|
+
|
52
|
+
const uint32_t advertising_cycle_time_;
|
53
|
+
uint32_t last_advertisement_time_{0};
|
54
|
+
int8_t current_adv_index_{-1}; // -1 means standard scan response
|
35
55
|
};
|
36
56
|
|
37
57
|
} // namespace esp32_ble
|
@@ -1,16 +1,21 @@
|
|
1
1
|
import esphome.codegen as cg
|
2
|
+
from esphome.components import esp32_ble
|
3
|
+
from esphome.components.esp32 import add_idf_sdkconfig_option
|
4
|
+
from esphome.components.esp32_ble import CONF_BLE_ID
|
2
5
|
import esphome.config_validation as cv
|
3
|
-
from esphome.const import CONF_ID, CONF_TYPE, CONF_UUID
|
6
|
+
from esphome.const import CONF_ID, CONF_TX_POWER, CONF_TYPE, CONF_UUID
|
4
7
|
from esphome.core import CORE, TimePeriod
|
5
|
-
from esphome.components.esp32 import add_idf_sdkconfig_option
|
6
|
-
from esphome.components import esp32_ble
|
7
8
|
|
9
|
+
AUTO_LOAD = ["esp32_ble"]
|
8
10
|
DEPENDENCIES = ["esp32"]
|
9
|
-
CONFLICTS_WITH = ["esp32_ble_tracker"]
|
10
11
|
|
11
12
|
esp32_ble_beacon_ns = cg.esphome_ns.namespace("esp32_ble_beacon")
|
12
|
-
ESP32BLEBeacon = esp32_ble_beacon_ns.class_(
|
13
|
-
|
13
|
+
ESP32BLEBeacon = esp32_ble_beacon_ns.class_(
|
14
|
+
"ESP32BLEBeacon",
|
15
|
+
cg.Component,
|
16
|
+
esp32_ble.GAPEventHandler,
|
17
|
+
cg.Parented.template(esp32_ble.ESP32BLE),
|
18
|
+
)
|
14
19
|
CONF_MAJOR = "major"
|
15
20
|
CONF_MINOR = "minor"
|
16
21
|
CONF_MIN_INTERVAL = "min_interval"
|
@@ -28,6 +33,7 @@ CONFIG_SCHEMA = cv.All(
|
|
28
33
|
cv.Schema(
|
29
34
|
{
|
30
35
|
cv.GenerateID(): cv.declare_id(ESP32BLEBeacon),
|
36
|
+
cv.GenerateID(CONF_BLE_ID): cv.use_id(esp32_ble.ESP32BLE),
|
31
37
|
cv.Required(CONF_TYPE): cv.one_of("IBEACON", upper=True),
|
32
38
|
cv.Required(CONF_UUID): cv.uuid,
|
33
39
|
cv.Optional(CONF_MAJOR, default=10167): cv.uint16_t,
|
@@ -48,7 +54,7 @@ CONFIG_SCHEMA = cv.All(
|
|
48
54
|
min=-128, max=0
|
49
55
|
),
|
50
56
|
cv.Optional(CONF_TX_POWER, default="3dBm"): cv.All(
|
51
|
-
cv.decibel, cv.
|
57
|
+
cv.decibel, cv.enum(esp32_ble.TX_POWER_LEVELS, int=True)
|
52
58
|
),
|
53
59
|
}
|
54
60
|
).extend(cv.COMPONENT_SCHEMA),
|
@@ -62,6 +68,10 @@ async def to_code(config):
|
|
62
68
|
uuid = config[CONF_UUID].hex
|
63
69
|
uuid_arr = [cg.RawExpression(f"0x{uuid[i:i + 2]}") for i in range(0, len(uuid), 2)]
|
64
70
|
var = cg.new_Pvariable(config[CONF_ID], uuid_arr)
|
71
|
+
|
72
|
+
parent = await cg.get_variable(config[esp32_ble.CONF_BLE_ID])
|
73
|
+
cg.add(parent.register_gap_event_handler(var))
|
74
|
+
|
65
75
|
await cg.register_component(var, config)
|
66
76
|
cg.add(var.set_major(config[CONF_MAJOR]))
|
67
77
|
cg.add(var.set_minor(config[CONF_MINOR]))
|