esphome 2024.12.4__py3-none-any.whl → 2025.2.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 +16 -3
- esphome/components/adc/__init__.py +17 -11
- esphome/components/adc/adc_sensor.h +17 -0
- esphome/components/adc/adc_sensor_common.cpp +55 -0
- esphome/components/adc/adc_sensor_esp32.cpp +8 -5
- esphome/components/adc/adc_sensor_esp8266.cpp +10 -6
- esphome/components/adc/adc_sensor_libretiny.cpp +11 -6
- esphome/components/adc/adc_sensor_rp2040.cpp +13 -10
- esphome/components/adc/sensor.py +9 -3
- esphome/components/ads1115/ads1115.cpp +56 -7
- esphome/components/ads1115/ads1115.h +13 -1
- esphome/components/ads1115/sensor/__init__.py +16 -0
- esphome/components/ads1115/sensor/ads1115_sensor.cpp +2 -1
- esphome/components/ads1115/sensor/ads1115_sensor.h +2 -0
- esphome/components/animation/__init__.py +23 -261
- esphome/components/animation/animation.cpp +2 -2
- esphome/components/animation/animation.h +2 -1
- esphome/components/api/api_pb2.cpp +14 -0
- esphome/components/api/api_pb2.h +1 -0
- esphome/components/audio/__init__.py +112 -0
- esphome/components/audio/audio.cpp +67 -0
- esphome/components/audio/audio.h +125 -7
- esphome/components/audio/audio_decoder.cpp +361 -0
- esphome/components/audio/audio_decoder.h +135 -0
- esphome/components/audio/audio_reader.cpp +308 -0
- esphome/components/audio/audio_reader.h +85 -0
- esphome/components/audio/audio_resampler.cpp +159 -0
- esphome/components/audio/audio_resampler.h +101 -0
- esphome/components/audio/audio_transfer_buffer.cpp +165 -0
- esphome/components/audio/audio_transfer_buffer.h +139 -0
- esphome/components/audio_adc/__init__.py +41 -0
- esphome/components/audio_adc/audio_adc.h +17 -0
- esphome/components/audio_adc/automation.h +23 -0
- esphome/components/bk72xx/__init__.py +1 -0
- esphome/components/ble_client/ble_client.cpp +1 -2
- esphome/components/ble_client/sensor/__init__.py +1 -1
- esphome/components/ble_client/text_sensor/__init__.py +1 -1
- esphome/components/bluetooth_proxy/bluetooth_connection.cpp +5 -0
- esphome/components/bluetooth_proxy/bluetooth_connection.h +1 -0
- esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +5 -0
- esphome/components/ch422g/ch422g.h +2 -0
- esphome/components/climate/__init__.py +1 -1
- esphome/components/climate_ir/climate_ir.cpp +2 -1
- esphome/components/coolix/coolix.cpp +2 -1
- esphome/components/custom/__init__.py +0 -3
- esphome/components/custom/binary_sensor/__init__.py +2 -28
- esphome/components/custom/climate/__init__.py +2 -27
- esphome/components/custom/cover/__init__.py +2 -27
- esphome/components/custom/light/__init__.py +2 -27
- esphome/components/custom/output/__init__.py +2 -58
- esphome/components/custom/sensor/__init__.py +2 -24
- esphome/components/custom/switch/__init__.py +2 -24
- esphome/components/custom/text_sensor/__init__.py +2 -29
- esphome/components/custom_component/__init__.py +3 -27
- esphome/components/daly_bms/daly_bms.cpp +6 -0
- esphome/components/daly_bms/daly_bms.h +2 -0
- esphome/components/daly_bms/sensor.py +6 -0
- esphome/components/debug/debug_component.cpp +4 -0
- esphome/components/debug/debug_component.h +14 -0
- esphome/components/debug/debug_esp32.cpp +154 -74
- esphome/components/dfplayer/dfplayer.cpp +15 -2
- esphome/components/dfrobot_sen0395/dfrobot_sen0395.cpp +2 -1
- esphome/components/dht/dht.cpp +2 -1
- esphome/components/display/__init__.py +18 -5
- esphome/components/display/display.cpp +2 -1
- esphome/components/display/rect.cpp +2 -1
- esphome/components/es7210/__init__.py +0 -0
- esphome/components/es7210/audio_adc.py +51 -0
- esphome/components/es7210/es7210.cpp +228 -0
- esphome/components/es7210/es7210.h +62 -0
- esphome/components/es7210/es7210_const.h +129 -0
- esphome/components/es7243e/__init__.py +0 -0
- esphome/components/es7243e/audio_adc.py +34 -0
- esphome/components/es7243e/es7243e.cpp +125 -0
- esphome/components/es7243e/es7243e.h +37 -0
- esphome/components/es7243e/es7243e_const.h +54 -0
- esphome/components/es8156/__init__.py +0 -0
- esphome/components/es8156/audio_dac.py +27 -0
- esphome/components/es8156/es8156.cpp +87 -0
- esphome/components/es8156/es8156.h +51 -0
- esphome/components/es8156/es8156_const.h +68 -0
- esphome/components/es8311/audio_dac.py +1 -2
- esphome/components/esp32/__init__.py +1 -0
- esphome/components/esp32/core.cpp +5 -1
- esphome/components/esp32/gpio.h +2 -0
- esphome/components/esp32_ble/__init__.py +39 -0
- esphome/components/esp32_ble/queue.h +4 -4
- esphome/components/esp32_ble_client/ble_client_base.cpp +46 -0
- esphome/components/esp32_ble_client/ble_client_base.h +2 -0
- esphome/components/esp32_ble_server/__init__.py +582 -12
- esphome/components/esp32_ble_server/ble_characteristic.cpp +48 -60
- esphome/components/esp32_ble_server/ble_characteristic.h +24 -17
- esphome/components/esp32_ble_server/ble_descriptor.cpp +21 -9
- esphome/components/esp32_ble_server/ble_descriptor.h +17 -6
- esphome/components/esp32_ble_server/ble_server.cpp +62 -67
- esphome/components/esp32_ble_server/ble_server.h +28 -32
- esphome/components/esp32_ble_server/ble_server_automations.cpp +77 -0
- esphome/components/esp32_ble_server/ble_server_automations.h +115 -0
- esphome/components/esp32_ble_server/ble_service.cpp +17 -15
- esphome/components/esp32_ble_server/ble_service.h +10 -14
- esphome/components/esp32_ble_tracker/__init__.py +6 -39
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +33 -10
- esphome/components/esp32_ble_tracker/esp32_ble_tracker.h +8 -4
- esphome/components/esp32_improv/__init__.py +2 -8
- esphome/components/esp32_improv/esp32_improv_component.cpp +21 -20
- esphome/components/esp32_improv/esp32_improv_component.h +3 -4
- esphome/components/esp32_rmt/__init__.py +28 -3
- esphome/components/esp32_rmt_led_strip/led_strip.cpp +73 -6
- esphome/components/esp32_rmt_led_strip/led_strip.h +21 -3
- esphome/components/esp32_rmt_led_strip/light.py +72 -7
- esphome/components/esp32_touch/esp32_touch.cpp +5 -0
- esphome/components/esp8266/__init__.py +1 -0
- esphome/components/esp8266/gpio.h +1 -0
- esphome/components/ethernet/__init__.py +10 -10
- esphome/components/event/event.cpp +4 -2
- esphome/components/event/event.h +2 -0
- esphome/components/event_emitter/__init__.py +5 -0
- esphome/components/event_emitter/event_emitter.cpp +14 -0
- esphome/components/event_emitter/event_emitter.h +63 -0
- esphome/components/gcja5/gcja5.cpp +2 -1
- esphome/components/haier/haier_base.cpp +2 -1
- esphome/components/haier/hon_climate.cpp +2 -1
- esphome/components/heatpumpir/heatpumpir.cpp +2 -1
- esphome/components/host/__init__.py +1 -0
- esphome/components/host/gpio.h +1 -0
- esphome/components/http_request/http_request.h +2 -2
- esphome/components/http_request/http_request_arduino.cpp +1 -1
- esphome/components/http_request/http_request_idf.cpp +1 -1
- esphome/components/i2c/i2c_bus_esp_idf.cpp +4 -0
- esphome/components/i2s_audio/microphone/i2s_audio_microphone.cpp +7 -5
- esphome/components/i2s_audio/speaker/__init__.py +53 -6
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.cpp +92 -46
- esphome/components/i2s_audio/speaker/i2s_audio_speaker.h +8 -0
- esphome/components/ili9xxx/display.py +29 -11
- esphome/components/ili9xxx/ili9xxx_display.cpp +2 -5
- esphome/components/ili9xxx/ili9xxx_display.h +2 -1
- esphome/components/image/__init__.py +443 -255
- esphome/components/image/image.cpp +115 -61
- esphome/components/image/image.h +15 -24
- esphome/components/json/json_util.cpp +8 -34
- esphome/components/libretiny/__init__.py +1 -0
- esphome/components/libretiny/gpio_arduino.h +1 -0
- esphome/components/light/light_color_values.h +1 -1
- esphome/components/logger/__init__.py +43 -7
- esphome/components/logger/logger.cpp +16 -11
- esphome/components/logger/logger.h +11 -7
- esphome/components/logger/select/__init__.py +29 -0
- esphome/components/logger/select/logger_level_select.cpp +27 -0
- esphome/components/logger/select/logger_level_select.h +15 -0
- esphome/components/lvgl/__init__.py +96 -73
- esphome/components/lvgl/automation.py +39 -7
- esphome/components/lvgl/defines.py +8 -2
- esphome/components/lvgl/lvgl_esphome.cpp +8 -15
- esphome/components/lvgl/lvgl_esphome.h +20 -5
- esphome/components/lvgl/schemas.py +25 -14
- esphome/components/lvgl/trigger.py +27 -3
- esphome/components/lvgl/widgets/dropdown.py +1 -1
- esphome/components/lvgl/widgets/keyboard.py +8 -1
- esphome/components/lvgl/widgets/meter.py +2 -1
- esphome/components/lvgl/widgets/msgbox.py +1 -1
- esphome/components/lvgl/widgets/obj.py +1 -12
- esphome/components/lvgl/widgets/page.py +37 -2
- esphome/components/lvgl/widgets/tabview.py +1 -1
- esphome/components/max6956/max6956.h +2 -0
- esphome/components/mcp23016/mcp23016.h +2 -0
- esphome/components/mcp23xxx_base/mcp23xxx_base.h +2 -0
- esphome/components/mdns/__init__.py +1 -1
- esphome/components/media_player/__init__.py +37 -8
- esphome/components/media_player/automation.h +11 -2
- esphome/components/media_player/media_player.cpp +8 -0
- esphome/components/media_player/media_player.h +8 -4
- esphome/components/micronova/switch/micronova_switch.cpp +4 -2
- esphome/components/midea/ac_automations.h +3 -1
- esphome/components/midea/air_conditioner.cpp +7 -5
- esphome/components/midea/air_conditioner.h +1 -1
- esphome/components/midea/climate.py +4 -2
- esphome/components/midea/ir_transmitter.h +36 -5
- esphome/components/mixer/__init__.py +0 -0
- esphome/components/mixer/speaker/__init__.py +172 -0
- esphome/components/mixer/speaker/automation.h +19 -0
- esphome/components/mixer/speaker/mixer_speaker.cpp +624 -0
- esphome/components/mixer/speaker/mixer_speaker.h +207 -0
- esphome/components/mpr121/mpr121.h +2 -0
- esphome/components/mqtt/__init__.py +1 -1
- esphome/components/mqtt/mqtt_client.cpp +7 -1
- esphome/components/mqtt/mqtt_client.h +1 -1
- esphome/components/mqtt/mqtt_climate.cpp +2 -2
- esphome/components/network/ip_address.h +2 -0
- esphome/components/nextion/automation.h +17 -0
- esphome/components/nextion/display.py +42 -17
- esphome/components/nextion/nextion.cpp +4 -10
- esphome/components/nextion/nextion.h +89 -82
- esphome/components/nextion/nextion_commands.cpp +10 -10
- esphome/components/ntc/sensor.py +2 -4
- esphome/components/online_image/__init__.py +98 -46
- esphome/components/online_image/bmp_image.cpp +101 -0
- esphome/components/online_image/bmp_image.h +40 -0
- esphome/components/online_image/image_decoder.cpp +28 -2
- esphome/components/online_image/image_decoder.h +24 -15
- esphome/components/online_image/jpeg_image.cpp +90 -0
- esphome/components/online_image/jpeg_image.h +34 -0
- esphome/components/online_image/online_image.cpp +112 -53
- esphome/components/online_image/online_image.h +24 -7
- esphome/components/online_image/png_image.cpp +7 -3
- esphome/components/online_image/png_image.h +2 -1
- esphome/components/opentherm/__init__.py +73 -7
- esphome/components/opentherm/automation.h +25 -0
- esphome/components/opentherm/const.py +1 -0
- esphome/components/opentherm/generate.py +39 -6
- esphome/components/opentherm/hub.cpp +117 -79
- esphome/components/opentherm/hub.h +31 -15
- esphome/components/opentherm/opentherm.cpp +47 -23
- esphome/components/opentherm/opentherm.h +27 -6
- esphome/components/opentherm/opentherm_macros.h +11 -0
- esphome/components/opentherm/schema.py +78 -1
- esphome/components/opentherm/validate.py +7 -2
- esphome/components/pca6416a/pca6416a.h +2 -0
- esphome/components/pca9554/pca9554.h +2 -0
- esphome/components/pcf8574/pcf8574.h +2 -0
- esphome/components/preferences/__init__.py +2 -4
- esphome/components/preferences/syncer.h +10 -3
- esphome/components/prometheus/prometheus_handler.cpp +313 -0
- esphome/components/prometheus/prometheus_handler.h +48 -7
- esphome/components/psram/psram.cpp +8 -1
- esphome/components/pulse_counter/pulse_counter_sensor.cpp +14 -9
- esphome/components/pulse_counter/pulse_counter_sensor.h +4 -4
- esphome/components/pulse_meter/pulse_meter_sensor.cpp +2 -0
- esphome/components/qspi_dbi/__init__.py +3 -0
- esphome/components/qspi_dbi/display.py +74 -47
- esphome/components/qspi_dbi/models.py +245 -2
- esphome/components/qspi_dbi/qspi_dbi.cpp +9 -16
- esphome/components/qspi_dbi/qspi_dbi.h +2 -2
- esphome/components/remote_base/__init__.py +77 -25
- esphome/components/remote_base/remote_base.cpp +1 -1
- esphome/components/remote_base/remote_base.h +20 -2
- esphome/components/remote_base/toto_protocol.cpp +100 -0
- esphome/components/remote_base/toto_protocol.h +45 -0
- esphome/components/remote_receiver/__init__.py +55 -10
- esphome/components/remote_receiver/remote_receiver.h +36 -3
- esphome/components/remote_receiver/remote_receiver_esp32.cpp +145 -6
- esphome/components/remote_transmitter/__init__.py +62 -4
- esphome/components/remote_transmitter/remote_transmitter.h +21 -2
- esphome/components/remote_transmitter/remote_transmitter_esp32.cpp +140 -4
- esphome/components/remote_transmitter/remote_transmitter_esp8266.cpp +3 -3
- esphome/components/remote_transmitter/remote_transmitter_libretiny.cpp +3 -3
- esphome/components/resampler/__init__.py +0 -0
- esphome/components/resampler/speaker/__init__.py +103 -0
- esphome/components/resampler/speaker/resampler_speaker.cpp +318 -0
- esphome/components/resampler/speaker/resampler_speaker.h +107 -0
- esphome/components/resistance/resistance_sensor.h +2 -3
- esphome/components/resistance/sensor.py +2 -9
- esphome/components/rotary_encoder/rotary_encoder.cpp +8 -4
- esphome/components/rp2040/__init__.py +1 -0
- esphome/components/rp2040/gpio.h +1 -0
- esphome/components/rtl87xx/__init__.py +2 -0
- esphome/components/sdl/binary_sensor.py +270 -0
- esphome/components/sdl/sdl_esphome.cpp +16 -0
- esphome/components/sdl/sdl_esphome.h +9 -0
- esphome/components/seeed_mr60bha2/binary_sensor.py +25 -0
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.cpp +26 -2
- esphome/components/seeed_mr60bha2/seeed_mr60bha2.h +9 -20
- esphome/components/seeed_mr60bha2/sensor.py +9 -1
- esphome/components/sn74hc165/sn74hc165.h +3 -0
- esphome/components/sn74hc595/sn74hc595.h +3 -0
- esphome/components/speaker/__init__.py +5 -4
- esphome/components/speaker/media_player/__init__.py +458 -0
- esphome/components/speaker/media_player/audio_pipeline.cpp +568 -0
- esphome/components/speaker/media_player/audio_pipeline.h +159 -0
- esphome/components/speaker/media_player/automation.h +26 -0
- esphome/components/speaker/media_player/speaker_media_player.cpp +577 -0
- esphome/components/speaker/media_player/speaker_media_player.h +160 -0
- esphome/components/speaker/speaker.h +20 -0
- esphome/components/spi/__init__.py +1 -5
- esphome/components/spi/spi.cpp +7 -1
- esphome/components/spi/spi.h +21 -2
- esphome/components/spi_led_strip/light.py +3 -5
- esphome/components/spi_led_strip/spi_led_strip.cpp +67 -0
- esphome/components/spi_led_strip/spi_led_strip.h +8 -60
- esphome/components/sprinkler/sprinkler.cpp +3 -1
- esphome/components/sx1509/sx1509_gpio_pin.h +2 -0
- esphome/components/tca9555/tca9555.h +2 -0
- esphome/components/toshiba/toshiba.cpp +2 -1
- esphome/components/tuya/light/tuya_light.cpp +4 -2
- esphome/components/uart/uart_component_esp32_arduino.cpp +2 -2
- esphome/components/uart/uart_component_esp_idf.cpp +2 -2
- esphome/components/udp/__init__.py +8 -2
- esphome/components/udp/udp_component.cpp +25 -56
- esphome/components/udp/udp_component.h +3 -0
- esphome/components/uponor_smatrix/sensor/__init__.py +14 -4
- esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.cpp +5 -0
- esphome/components/uponor_smatrix/sensor/uponor_smatrix_sensor.h +1 -0
- esphome/components/uptime/text_sensor/__init__.py +19 -0
- esphome/components/uptime/text_sensor/uptime_text_sensor.cpp +63 -0
- esphome/components/uptime/text_sensor/uptime_text_sensor.h +25 -0
- esphome/components/voice_assistant/voice_assistant.cpp +24 -14
- esphome/components/voice_assistant/voice_assistant.h +8 -0
- esphome/components/waveshare_epaper/display.py +22 -1
- esphome/components/waveshare_epaper/waveshare_213v3.cpp +9 -3
- esphome/components/waveshare_epaper/waveshare_epaper.cpp +1155 -44
- esphome/components/waveshare_epaper/waveshare_epaper.h +208 -7
- esphome/components/web_server/web_server.cpp +28 -6
- esphome/components/weikai/weikai.h +2 -0
- esphome/components/wifi/__init__.py +6 -6
- esphome/components/wifi/wifi_component.cpp +1 -1
- esphome/components/wifi/wifi_component_esp32_arduino.cpp +30 -1
- esphome/components/wireguard/__init__.py +2 -2
- esphome/components/xl9535/xl9535.h +2 -0
- esphome/components/xxtea/__init__.py +3 -0
- esphome/components/xxtea/xxtea.cpp +46 -0
- esphome/components/xxtea/xxtea.h +26 -0
- esphome/components/yashima/yashima.cpp +2 -1
- esphome/config.py +9 -5
- esphome/config_validation.py +55 -17
- esphome/const.py +7 -10
- esphome/core/__init__.py +6 -13
- esphome/core/base_automation.h +1 -0
- esphome/core/config.py +57 -72
- esphome/core/defines.h +9 -1
- esphome/core/gpio.h +7 -0
- esphome/core/helpers.cpp +19 -15
- esphome/core/helpers.h +57 -8
- esphome/core/log.h +9 -7
- esphome/cpp_generator.py +2 -2
- esphome/espota2.py +3 -2
- esphome/loader.py +12 -4
- esphome/log.py +5 -7
- esphome/yaml_util.py +2 -2
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/METADATA +12 -7
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/RECORD +338 -289
- esphome/components/custom/binary_sensor/custom_binary_sensor.cpp +0 -16
- esphome/components/custom/binary_sensor/custom_binary_sensor.h +0 -26
- esphome/components/custom/climate/custom_climate.h +0 -22
- esphome/components/custom/cover/custom_cover.h +0 -21
- esphome/components/custom/light/custom_light_output.h +0 -24
- esphome/components/custom/output/custom_output.h +0 -37
- esphome/components/custom/sensor/custom_sensor.cpp +0 -16
- esphome/components/custom/sensor/custom_sensor.h +0 -24
- esphome/components/custom/switch/custom_switch.cpp +0 -16
- esphome/components/custom/switch/custom_switch.h +0 -24
- esphome/components/custom/text_sensor/custom_text_sensor.cpp +0 -16
- esphome/components/custom/text_sensor/custom_text_sensor.h +0 -26
- esphome/components/custom_component/custom_component.h +0 -28
- esphome/components/esp32_ble_server/ble_2901.cpp +0 -18
- esphome/components/esp32_ble_server/ble_2901.h +0 -19
- esphome/components/resistance_sampler/__init__.py +0 -6
- esphome/components/resistance_sampler/resistance_sampler.h +0 -10
- esphome/components/uptime/{sensor.py → sensor/__init__.py} +3 -3
- /esphome/components/uptime/{uptime_seconds_sensor.cpp → sensor/uptime_seconds_sensor.cpp} +0 -0
- /esphome/components/uptime/{uptime_seconds_sensor.h → sensor/uptime_seconds_sensor.h} +0 -0
- /esphome/components/uptime/{uptime_timestamp_sensor.cpp → sensor/uptime_timestamp_sensor.cpp} +0 -0
- /esphome/components/uptime/{uptime_timestamp_sensor.h → sensor/uptime_timestamp_sensor.h} +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/LICENSE +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/WHEEL +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/entry_points.txt +0 -0
- {esphome-2024.12.4.dist-info → esphome-2025.2.0b1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,160 @@
|
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#ifdef USE_ESP_IDF
|
4
|
+
|
5
|
+
#include "audio_pipeline.h"
|
6
|
+
|
7
|
+
#include "esphome/components/audio/audio.h"
|
8
|
+
|
9
|
+
#include "esphome/components/media_player/media_player.h"
|
10
|
+
#include "esphome/components/speaker/speaker.h"
|
11
|
+
|
12
|
+
#include "esphome/core/automation.h"
|
13
|
+
#include "esphome/core/component.h"
|
14
|
+
#include "esphome/core/preferences.h"
|
15
|
+
|
16
|
+
#include <deque>
|
17
|
+
#include <freertos/FreeRTOS.h>
|
18
|
+
#include <freertos/queue.h>
|
19
|
+
|
20
|
+
namespace esphome {
|
21
|
+
namespace speaker {
|
22
|
+
|
23
|
+
struct MediaCallCommand {
|
24
|
+
optional<media_player::MediaPlayerCommand> command;
|
25
|
+
optional<float> volume;
|
26
|
+
optional<bool> announce;
|
27
|
+
optional<bool> new_url;
|
28
|
+
optional<bool> new_file;
|
29
|
+
optional<bool> enqueue;
|
30
|
+
};
|
31
|
+
|
32
|
+
struct PlaylistItem {
|
33
|
+
optional<std::string> url;
|
34
|
+
optional<audio::AudioFile *> file;
|
35
|
+
};
|
36
|
+
|
37
|
+
struct VolumeRestoreState {
|
38
|
+
float volume;
|
39
|
+
bool is_muted;
|
40
|
+
};
|
41
|
+
|
42
|
+
class SpeakerMediaPlayer : public Component, public media_player::MediaPlayer {
|
43
|
+
public:
|
44
|
+
float get_setup_priority() const override { return esphome::setup_priority::PROCESSOR; }
|
45
|
+
void setup() override;
|
46
|
+
void loop() override;
|
47
|
+
|
48
|
+
// MediaPlayer implementations
|
49
|
+
media_player::MediaPlayerTraits get_traits() override;
|
50
|
+
bool is_muted() const override { return this->is_muted_; }
|
51
|
+
|
52
|
+
void set_buffer_size(size_t buffer_size) { this->buffer_size_ = buffer_size; }
|
53
|
+
void set_task_stack_in_psram(bool task_stack_in_psram) { this->task_stack_in_psram_ = task_stack_in_psram; }
|
54
|
+
|
55
|
+
// Percentage to increase or decrease the volume for volume up or volume down commands
|
56
|
+
void set_volume_increment(float volume_increment) { this->volume_increment_ = volume_increment; }
|
57
|
+
|
58
|
+
void set_volume_max(float volume_max) { this->volume_max_ = volume_max; }
|
59
|
+
void set_volume_min(float volume_min) { this->volume_min_ = volume_min; }
|
60
|
+
|
61
|
+
void set_announcement_speaker(Speaker *announcement_speaker) { this->announcement_speaker_ = announcement_speaker; }
|
62
|
+
void set_announcement_format(const media_player::MediaPlayerSupportedFormat &announcement_format) {
|
63
|
+
this->announcement_format_ = announcement_format;
|
64
|
+
}
|
65
|
+
void set_media_speaker(Speaker *media_speaker) { this->media_speaker_ = media_speaker; }
|
66
|
+
void set_media_format(const media_player::MediaPlayerSupportedFormat &media_format) {
|
67
|
+
this->media_format_ = media_format;
|
68
|
+
}
|
69
|
+
|
70
|
+
Trigger<> *get_mute_trigger() const { return this->mute_trigger_; }
|
71
|
+
Trigger<> *get_unmute_trigger() const { return this->unmute_trigger_; }
|
72
|
+
Trigger<float> *get_volume_trigger() const { return this->volume_trigger_; }
|
73
|
+
|
74
|
+
void play_file(audio::AudioFile *media_file, bool announcement, bool enqueue);
|
75
|
+
|
76
|
+
uint32_t get_playback_ms() const { return this->playback_ms_; }
|
77
|
+
uint32_t get_playback_us() const { return this->playback_us_; }
|
78
|
+
uint32_t get_decoded_playback_ms() const { return this->decoded_playback_ms_; }
|
79
|
+
|
80
|
+
void set_playlist_delay_ms(AudioPipelineType pipeline_type, uint32_t delay_ms);
|
81
|
+
|
82
|
+
protected:
|
83
|
+
// Receives commands from HA or from the voice assistant component
|
84
|
+
// Sends commands to the media_control_commanda_queue_
|
85
|
+
void control(const media_player::MediaPlayerCall &call) override;
|
86
|
+
|
87
|
+
/// @brief Updates this->volume and saves volume/mute state to flash for restortation if publish is true.
|
88
|
+
void set_volume_(float volume, bool publish = true);
|
89
|
+
|
90
|
+
/// @brief Sets the mute state. Restores previous volume if unmuting. Always saves volume/mute state to flash for
|
91
|
+
/// restoration.
|
92
|
+
/// @param mute_state If true, audio will be muted. If false, audio will be unmuted
|
93
|
+
void set_mute_state_(bool mute_state);
|
94
|
+
|
95
|
+
/// @brief Saves the current volume and mute state to the flash for restoration.
|
96
|
+
void save_volume_restore_state_();
|
97
|
+
|
98
|
+
/// Returns true if the media player has only the announcement pipeline defined, false if both the announcement and
|
99
|
+
/// media pipelines are defined.
|
100
|
+
inline bool single_pipeline_() { return (this->media_speaker_ == nullptr); }
|
101
|
+
|
102
|
+
// Processes commands from media_control_command_queue_.
|
103
|
+
void watch_media_commands_();
|
104
|
+
|
105
|
+
std::unique_ptr<AudioPipeline> announcement_pipeline_;
|
106
|
+
std::unique_ptr<AudioPipeline> media_pipeline_;
|
107
|
+
Speaker *media_speaker_{nullptr};
|
108
|
+
Speaker *announcement_speaker_{nullptr};
|
109
|
+
|
110
|
+
optional<media_player::MediaPlayerSupportedFormat> media_format_;
|
111
|
+
AudioPipelineState media_pipeline_state_{AudioPipelineState::STOPPED};
|
112
|
+
std::string media_url_{}; // only modified by control function
|
113
|
+
audio::AudioFile *media_file_{}; // only modified by play_file function
|
114
|
+
bool media_repeat_one_{false};
|
115
|
+
uint32_t media_playlist_delay_ms_{0};
|
116
|
+
|
117
|
+
optional<media_player::MediaPlayerSupportedFormat> announcement_format_;
|
118
|
+
AudioPipelineState announcement_pipeline_state_{AudioPipelineState::STOPPED};
|
119
|
+
std::string announcement_url_{}; // only modified by control function
|
120
|
+
audio::AudioFile *announcement_file_{}; // only modified by play_file function
|
121
|
+
bool announcement_repeat_one_{false};
|
122
|
+
uint32_t announcement_playlist_delay_ms_{0};
|
123
|
+
|
124
|
+
QueueHandle_t media_control_command_queue_;
|
125
|
+
|
126
|
+
std::deque<PlaylistItem> announcement_playlist_;
|
127
|
+
std::deque<PlaylistItem> media_playlist_;
|
128
|
+
|
129
|
+
size_t buffer_size_;
|
130
|
+
|
131
|
+
bool task_stack_in_psram_;
|
132
|
+
|
133
|
+
bool is_paused_{false};
|
134
|
+
bool is_muted_{false};
|
135
|
+
|
136
|
+
// The amount to change the volume on volume up/down commands
|
137
|
+
float volume_increment_;
|
138
|
+
|
139
|
+
float volume_max_;
|
140
|
+
float volume_min_;
|
141
|
+
|
142
|
+
// Used to save volume/mute state for restoration on reboot
|
143
|
+
ESPPreferenceObject pref_;
|
144
|
+
|
145
|
+
Trigger<> *mute_trigger_ = new Trigger<>();
|
146
|
+
Trigger<> *unmute_trigger_ = new Trigger<>();
|
147
|
+
Trigger<float> *volume_trigger_ = new Trigger<float>();
|
148
|
+
|
149
|
+
uint32_t decoded_playback_ms_{0};
|
150
|
+
uint32_t playback_us_{0};
|
151
|
+
uint32_t playback_ms_{0};
|
152
|
+
uint32_t remainder_us_{0};
|
153
|
+
uint32_t pending_ms_{0};
|
154
|
+
uint32_t last_audio_write_timestamp_{0};
|
155
|
+
};
|
156
|
+
|
157
|
+
} // namespace speaker
|
158
|
+
} // namespace esphome
|
159
|
+
|
160
|
+
#endif
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#endif
|
10
10
|
|
11
11
|
#include "esphome/core/defines.h"
|
12
|
+
#include "esphome/core/helpers.h"
|
12
13
|
|
13
14
|
#include "esphome/components/audio/audio.h"
|
14
15
|
#ifdef USE_AUDIO_DAC
|
@@ -56,6 +57,10 @@ class Speaker {
|
|
56
57
|
// When finish() is not implemented on the platform component it should just do a normal stop.
|
57
58
|
virtual void finish() { this->stop(); }
|
58
59
|
|
60
|
+
// Pauses processing incoming audio. Needs to be implemented specifically per speaker component
|
61
|
+
virtual void set_pause_state(bool pause_state) {}
|
62
|
+
virtual bool get_pause_state() const { return false; }
|
63
|
+
|
59
64
|
virtual bool has_buffered_data() const = 0;
|
60
65
|
|
61
66
|
bool is_running() const { return this->state_ == STATE_RUNNING; }
|
@@ -95,6 +100,19 @@ class Speaker {
|
|
95
100
|
this->audio_stream_info_ = audio_stream_info;
|
96
101
|
}
|
97
102
|
|
103
|
+
audio::AudioStreamInfo &get_audio_stream_info() { return this->audio_stream_info_; }
|
104
|
+
|
105
|
+
/// Callback function for sending the duration of the audio written to the speaker since the last callback.
|
106
|
+
/// Parameters:
|
107
|
+
/// - Duration in milliseconds. Never rounded and should always be less than or equal to the actual duration.
|
108
|
+
/// - Remainder duration in microseconds. Rounded duration after subtracting the previous parameter from the actual
|
109
|
+
/// duration.
|
110
|
+
/// - Duration of remaining, unwritten audio buffered in the speaker in milliseconds.
|
111
|
+
/// - System time in microseconds when the last write was completed.
|
112
|
+
void add_audio_output_callback(std::function<void(uint32_t, uint32_t, uint32_t, uint32_t)> &&callback) {
|
113
|
+
this->audio_output_callback_.add(std::move(callback));
|
114
|
+
}
|
115
|
+
|
98
116
|
protected:
|
99
117
|
State state_{STATE_STOPPED};
|
100
118
|
audio::AudioStreamInfo audio_stream_info_;
|
@@ -104,6 +122,8 @@ class Speaker {
|
|
104
122
|
#ifdef USE_AUDIO_DAC
|
105
123
|
audio_dac::AudioDac *audio_dac_{nullptr};
|
106
124
|
#endif
|
125
|
+
|
126
|
+
CallbackManager<void(uint32_t, uint32_t, uint32_t, uint32_t)> audio_output_callback_{};
|
107
127
|
};
|
108
128
|
|
109
129
|
} // namespace speaker
|
@@ -97,11 +97,7 @@ RP_SPI_PINSETS = [
|
|
97
97
|
|
98
98
|
|
99
99
|
def get_target_platform():
|
100
|
-
return
|
101
|
-
CORE.data[KEY_CORE][KEY_TARGET_PLATFORM]
|
102
|
-
if KEY_TARGET_PLATFORM in CORE.data[KEY_CORE]
|
103
|
-
else ""
|
104
|
-
)
|
100
|
+
return CORE.data[KEY_CORE][KEY_TARGET_PLATFORM]
|
105
101
|
|
106
102
|
|
107
103
|
def get_target_variant():
|
esphome/components/spi/spi.cpp
CHANGED
@@ -7,6 +7,10 @@ namespace spi {
|
|
7
7
|
|
8
8
|
const char *const TAG = "spi";
|
9
9
|
|
10
|
+
SPIDelegate *const SPIDelegate::NULL_DELEGATE = // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
11
|
+
new SPIDelegateDummy();
|
12
|
+
// https://bugs.llvm.org/show_bug.cgi?id=48040
|
13
|
+
|
10
14
|
bool SPIDelegate::is_ready() { return true; }
|
11
15
|
|
12
16
|
GPIOPin *const NullPin::NULL_PIN = new NullPin(); // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
@@ -75,6 +79,8 @@ void SPIComponent::dump_config() {
|
|
75
79
|
}
|
76
80
|
}
|
77
81
|
|
82
|
+
void SPIDelegateDummy::begin_transaction() { ESP_LOGE(TAG, "SPIDevice not initialised - did you call spi_setup()?"); }
|
83
|
+
|
78
84
|
uint8_t SPIDelegateBitBash::transfer(uint8_t data) { return this->transfer_(data, 8); }
|
79
85
|
|
80
86
|
void SPIDelegateBitBash::write(uint16_t data, size_t num_bits) { this->transfer_(data, num_bits); }
|
@@ -82,7 +88,7 @@ void SPIDelegateBitBash::write(uint16_t data, size_t num_bits) { this->transfer_
|
|
82
88
|
uint16_t SPIDelegateBitBash::transfer_(uint16_t data, size_t num_bits) {
|
83
89
|
// Clock starts out at idle level
|
84
90
|
this->clk_pin_->digital_write(clock_polarity_);
|
85
|
-
|
91
|
+
uint16_t out_data = 0;
|
86
92
|
|
87
93
|
for (uint8_t i = 0; i != num_bits; i++) {
|
88
94
|
uint8_t shift;
|
esphome/components/spi/spi.h
CHANGED
@@ -114,6 +114,8 @@ class NullPin : public GPIOPin {
|
|
114
114
|
|
115
115
|
void pin_mode(gpio::Flags flags) override {}
|
116
116
|
|
117
|
+
gpio::Flags get_flags() const override { return gpio::Flags::FLAG_NONE; }
|
118
|
+
|
117
119
|
bool digital_read() override { return false; }
|
118
120
|
|
119
121
|
void digital_write(bool value) override {}
|
@@ -163,6 +165,8 @@ class Utility {
|
|
163
165
|
}
|
164
166
|
};
|
165
167
|
|
168
|
+
class SPIDelegateDummy;
|
169
|
+
|
166
170
|
// represents a device attached to an SPI bus, with a defined clock rate, mode and bit order. On Arduino this is
|
167
171
|
// a thin wrapper over SPIClass.
|
168
172
|
class SPIDelegate {
|
@@ -248,6 +252,21 @@ class SPIDelegate {
|
|
248
252
|
uint32_t data_rate_{1000000};
|
249
253
|
SPIMode mode_{MODE0};
|
250
254
|
GPIOPin *cs_pin_{NullPin::NULL_PIN};
|
255
|
+
static SPIDelegate *const NULL_DELEGATE; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
256
|
+
};
|
257
|
+
|
258
|
+
/**
|
259
|
+
* A dummy SPIDelegate that complains if it's used.
|
260
|
+
*/
|
261
|
+
|
262
|
+
class SPIDelegateDummy : public SPIDelegate {
|
263
|
+
public:
|
264
|
+
SPIDelegateDummy() = default;
|
265
|
+
|
266
|
+
uint8_t transfer(uint8_t data) override { return 0; }
|
267
|
+
void end_transaction() override{};
|
268
|
+
|
269
|
+
void begin_transaction() override;
|
251
270
|
};
|
252
271
|
|
253
272
|
/**
|
@@ -365,7 +384,7 @@ class SPIClient {
|
|
365
384
|
|
366
385
|
virtual void spi_teardown() {
|
367
386
|
this->parent_->unregister_device(this);
|
368
|
-
this->delegate_ =
|
387
|
+
this->delegate_ = SPIDelegate::NULL_DELEGATE;
|
369
388
|
}
|
370
389
|
|
371
390
|
bool spi_is_ready() { return this->delegate_->is_ready(); }
|
@@ -376,7 +395,7 @@ class SPIClient {
|
|
376
395
|
uint32_t data_rate_{1000000};
|
377
396
|
SPIComponent *parent_{nullptr};
|
378
397
|
GPIOPin *cs_{nullptr};
|
379
|
-
SPIDelegate *delegate_{
|
398
|
+
SPIDelegate *delegate_{SPIDelegate::NULL_DELEGATE};
|
380
399
|
};
|
381
400
|
|
382
401
|
/**
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import esphome.codegen as cg
|
2
|
+
from esphome.components import light, spi
|
2
3
|
import esphome.config_validation as cv
|
3
|
-
from esphome.
|
4
|
-
from esphome.components import spi
|
5
|
-
from esphome.const import CONF_OUTPUT_ID, CONF_NUM_LEDS
|
4
|
+
from esphome.const import CONF_NUM_LEDS, CONF_OUTPUT_ID
|
6
5
|
|
7
6
|
spi_led_strip_ns = cg.esphome_ns.namespace("spi_led_strip")
|
8
7
|
SpiLedStrip = spi_led_strip_ns.class_(
|
@@ -18,8 +17,7 @@ CONFIG_SCHEMA = light.ADDRESSABLE_LIGHT_SCHEMA.extend(
|
|
18
17
|
|
19
18
|
|
20
19
|
async def to_code(config):
|
21
|
-
var = cg.new_Pvariable(config[CONF_OUTPUT_ID])
|
22
|
-
cg.add(var.set_num_leds(config[CONF_NUM_LEDS]))
|
20
|
+
var = cg.new_Pvariable(config[CONF_OUTPUT_ID], config[CONF_NUM_LEDS])
|
23
21
|
await light.register_light(var, config)
|
24
22
|
await spi.register_spi_device(var, config)
|
25
23
|
await cg.register_component(var, config)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#include "spi_led_strip.h"
|
2
|
+
|
3
|
+
namespace esphome {
|
4
|
+
namespace spi_led_strip {
|
5
|
+
|
6
|
+
SpiLedStrip::SpiLedStrip(uint16_t num_leds) {
|
7
|
+
this->num_leds_ = num_leds;
|
8
|
+
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
9
|
+
this->buffer_size_ = num_leds * 4 + 8;
|
10
|
+
this->buf_ = allocator.allocate(this->buffer_size_);
|
11
|
+
if (this->buf_ == nullptr) {
|
12
|
+
ESP_LOGE(TAG, "Failed to allocate buffer of size %u", this->buffer_size_);
|
13
|
+
return;
|
14
|
+
}
|
15
|
+
|
16
|
+
this->effect_data_ = allocator.allocate(num_leds);
|
17
|
+
if (this->effect_data_ == nullptr) {
|
18
|
+
ESP_LOGE(TAG, "Failed to allocate effect data of size %u", num_leds);
|
19
|
+
return;
|
20
|
+
}
|
21
|
+
memset(this->buf_, 0xFF, this->buffer_size_);
|
22
|
+
memset(this->buf_, 0, 4);
|
23
|
+
}
|
24
|
+
void SpiLedStrip::setup() {
|
25
|
+
if (this->effect_data_ == nullptr || this->buf_ == nullptr) {
|
26
|
+
this->mark_failed();
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
this->spi_setup();
|
30
|
+
}
|
31
|
+
light::LightTraits SpiLedStrip::get_traits() {
|
32
|
+
auto traits = light::LightTraits();
|
33
|
+
traits.set_supported_color_modes({light::ColorMode::RGB});
|
34
|
+
return traits;
|
35
|
+
}
|
36
|
+
void SpiLedStrip::dump_config() {
|
37
|
+
esph_log_config(TAG, "SPI LED Strip:");
|
38
|
+
esph_log_config(TAG, " LEDs: %d", this->num_leds_);
|
39
|
+
if (this->data_rate_ >= spi::DATA_RATE_1MHZ) {
|
40
|
+
esph_log_config(TAG, " Data rate: %uMHz", (unsigned) (this->data_rate_ / 1000000));
|
41
|
+
} else {
|
42
|
+
esph_log_config(TAG, " Data rate: %ukHz", (unsigned) (this->data_rate_ / 1000));
|
43
|
+
}
|
44
|
+
}
|
45
|
+
void SpiLedStrip::write_state(light::LightState *state) {
|
46
|
+
if (this->is_failed())
|
47
|
+
return;
|
48
|
+
if (ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE) {
|
49
|
+
char strbuf[49];
|
50
|
+
size_t len = std::min(this->buffer_size_, (size_t) (sizeof(strbuf) - 1) / 3);
|
51
|
+
memset(strbuf, 0, sizeof(strbuf));
|
52
|
+
for (size_t i = 0; i != len; i++) {
|
53
|
+
sprintf(strbuf + i * 3, "%02X ", this->buf_[i]);
|
54
|
+
}
|
55
|
+
esph_log_v(TAG, "write_state: buf = %s", strbuf);
|
56
|
+
}
|
57
|
+
this->enable();
|
58
|
+
this->write_array(this->buf_, this->buffer_size_);
|
59
|
+
this->disable();
|
60
|
+
}
|
61
|
+
light::ESPColorView SpiLedStrip::get_view_internal(int32_t index) const {
|
62
|
+
size_t pos = index * 4 + 5;
|
63
|
+
return {this->buf_ + pos + 2, this->buf_ + pos + 1, this->buf_ + pos + 0, nullptr,
|
64
|
+
this->effect_data_ + index, &this->correction_};
|
65
|
+
}
|
66
|
+
} // namespace spi_led_strip
|
67
|
+
} // namespace esphome
|
@@ -13,74 +13,22 @@ class SpiLedStrip : public light::AddressableLight,
|
|
13
13
|
public spi::SPIDevice<spi::BIT_ORDER_MSB_FIRST, spi::CLOCK_POLARITY_HIGH, spi::CLOCK_PHASE_TRAILING,
|
14
14
|
spi::DATA_RATE_1MHZ> {
|
15
15
|
public:
|
16
|
-
|
16
|
+
SpiLedStrip(uint16_t num_leds);
|
17
|
+
void setup() override;
|
18
|
+
float get_setup_priority() const override { return setup_priority::IO; }
|
17
19
|
|
18
20
|
int32_t size() const override { return this->num_leds_; }
|
19
21
|
|
20
|
-
light::LightTraits get_traits() override
|
21
|
-
auto traits = light::LightTraits();
|
22
|
-
traits.set_supported_color_modes({light::ColorMode::RGB});
|
23
|
-
return traits;
|
24
|
-
}
|
25
|
-
void set_num_leds(uint16_t num_leds) {
|
26
|
-
this->num_leds_ = num_leds;
|
27
|
-
ExternalRAMAllocator<uint8_t> allocator(ExternalRAMAllocator<uint8_t>::ALLOW_FAILURE);
|
28
|
-
this->buffer_size_ = num_leds * 4 + 8;
|
29
|
-
this->buf_ = allocator.allocate(this->buffer_size_);
|
30
|
-
if (this->buf_ == nullptr) {
|
31
|
-
esph_log_e(TAG, "Failed to allocate buffer of size %u", this->buffer_size_);
|
32
|
-
this->mark_failed();
|
33
|
-
return;
|
34
|
-
}
|
22
|
+
light::LightTraits get_traits() override;
|
35
23
|
|
36
|
-
|
37
|
-
if (this->effect_data_ == nullptr) {
|
38
|
-
esph_log_e(TAG, "Failed to allocate effect data of size %u", num_leds);
|
39
|
-
this->mark_failed();
|
40
|
-
return;
|
41
|
-
}
|
42
|
-
memset(this->buf_, 0xFF, this->buffer_size_);
|
43
|
-
memset(this->buf_, 0, 4);
|
44
|
-
}
|
24
|
+
void dump_config() override;
|
45
25
|
|
46
|
-
void
|
47
|
-
esph_log_config(TAG, "SPI LED Strip:");
|
48
|
-
esph_log_config(TAG, " LEDs: %d", this->num_leds_);
|
49
|
-
if (this->data_rate_ >= spi::DATA_RATE_1MHZ) {
|
50
|
-
esph_log_config(TAG, " Data rate: %uMHz", (unsigned) (this->data_rate_ / 1000000));
|
51
|
-
} else {
|
52
|
-
esph_log_config(TAG, " Data rate: %ukHz", (unsigned) (this->data_rate_ / 1000));
|
53
|
-
}
|
54
|
-
}
|
26
|
+
void write_state(light::LightState *state) override;
|
55
27
|
|
56
|
-
void
|
57
|
-
if (this->is_failed())
|
58
|
-
return;
|
59
|
-
if (ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_VERBOSE) {
|
60
|
-
char strbuf[49];
|
61
|
-
size_t len = std::min(this->buffer_size_, (size_t) (sizeof(strbuf) - 1) / 3);
|
62
|
-
memset(strbuf, 0, sizeof(strbuf));
|
63
|
-
for (size_t i = 0; i != len; i++) {
|
64
|
-
sprintf(strbuf + i * 3, "%02X ", this->buf_[i]);
|
65
|
-
}
|
66
|
-
esph_log_v(TAG, "write_state: buf = %s", strbuf);
|
67
|
-
}
|
68
|
-
this->enable();
|
69
|
-
this->write_array(this->buf_, this->buffer_size_);
|
70
|
-
this->disable();
|
71
|
-
}
|
72
|
-
|
73
|
-
void clear_effect_data() override {
|
74
|
-
for (int i = 0; i < this->size(); i++)
|
75
|
-
this->effect_data_[i] = 0;
|
76
|
-
}
|
28
|
+
void clear_effect_data() override { memset(this->effect_data_, 0, this->num_leds_ * sizeof(this->effect_data_[0])); }
|
77
29
|
|
78
30
|
protected:
|
79
|
-
light::ESPColorView get_view_internal(int32_t index) const override
|
80
|
-
size_t pos = index * 4 + 5;
|
81
|
-
return {this->buf_ + pos + 2, this->buf_ + pos + 1, this->buf_ + pos + 0, nullptr,
|
82
|
-
this->effect_data_ + index, &this->correction_};
|
83
|
-
}
|
31
|
+
light::ESPColorView get_view_internal(int32_t index) const override;
|
84
32
|
|
85
33
|
size_t buffer_size_{};
|
86
34
|
uint8_t *effect_data_{nullptr};
|
@@ -184,11 +184,13 @@ void SprinklerValveOperator::set_controller(Sprinkler *controller) {
|
|
184
184
|
|
185
185
|
void SprinklerValveOperator::set_valve(SprinklerValve *valve) {
|
186
186
|
if (valve != nullptr) {
|
187
|
+
if (this->state_ != IDLE) { // Only kill if not already idle
|
188
|
+
this->kill_(); // ensure everything is off before we let go!
|
189
|
+
}
|
187
190
|
this->state_ = IDLE; // reset state
|
188
191
|
this->run_duration_ = 0; // reset to ensure the valve isn't started without updating it
|
189
192
|
this->start_millis_ = 0; // reset because (new) valve has not been started yet
|
190
193
|
this->stop_millis_ = 0; // reset because (new) valve has not been started yet
|
191
|
-
this->kill_(); // ensure everything is off before we let go!
|
192
194
|
this->valve_ = valve; // finally, set the pointer to the new valve
|
193
195
|
}
|
194
196
|
}
|
@@ -20,6 +20,8 @@ class SX1509GPIOPin : public GPIOPin {
|
|
20
20
|
void set_inverted(bool inverted) { this->inverted_ = inverted; }
|
21
21
|
void set_flags(gpio::Flags flags) { this->flags_ = flags; }
|
22
22
|
|
23
|
+
gpio::Flags get_flags() const override { return this->flags_; }
|
24
|
+
|
23
25
|
protected:
|
24
26
|
SX1509Component *parent_;
|
25
27
|
uint8_t pin_;
|
@@ -54,6 +54,8 @@ class TCA9555GPIOPin : public GPIOPin, public Parented<TCA9555Component> {
|
|
54
54
|
void set_inverted(bool inverted) { this->inverted_ = inverted; }
|
55
55
|
void set_flags(gpio::Flags flags) { this->flags_ = flags; }
|
56
56
|
|
57
|
+
gpio::Flags get_flags() const override { return this->flags_; }
|
58
|
+
|
57
59
|
protected:
|
58
60
|
uint8_t pin_;
|
59
61
|
bool inverted_;
|
@@ -106,8 +106,9 @@ void ToshibaClimate::setup() {
|
|
106
106
|
this->publish_state();
|
107
107
|
});
|
108
108
|
this->current_temperature = this->sensor_->state;
|
109
|
-
} else
|
109
|
+
} else {
|
110
110
|
this->current_temperature = NAN;
|
111
|
+
}
|
111
112
|
// restore set points
|
112
113
|
auto restore = this->restore_state_();
|
113
114
|
if (restore.has_value()) {
|
@@ -120,8 +120,9 @@ light::LightTraits TuyaLight::get_traits() {
|
|
120
120
|
traits.set_supported_color_modes(
|
121
121
|
{light::ColorMode::RGB_COLOR_TEMPERATURE, light::ColorMode::COLOR_TEMPERATURE});
|
122
122
|
}
|
123
|
-
} else
|
123
|
+
} else {
|
124
124
|
traits.set_supported_color_modes({light::ColorMode::COLOR_TEMPERATURE});
|
125
|
+
}
|
125
126
|
traits.set_min_mireds(this->cold_white_temperature_);
|
126
127
|
traits.set_max_mireds(this->warm_white_temperature_);
|
127
128
|
} else if (this->color_id_.has_value()) {
|
@@ -131,8 +132,9 @@ light::LightTraits TuyaLight::get_traits() {
|
|
131
132
|
} else {
|
132
133
|
traits.set_supported_color_modes({light::ColorMode::RGB_WHITE});
|
133
134
|
}
|
134
|
-
} else
|
135
|
+
} else {
|
135
136
|
traits.set_supported_color_modes({light::ColorMode::RGB});
|
137
|
+
}
|
136
138
|
} else if (this->dimmer_id_.has_value()) {
|
137
139
|
traits.set_supported_color_modes({light::ColorMode::BRIGHTNESS});
|
138
140
|
} else {
|
@@ -1,9 +1,9 @@
|
|
1
1
|
#ifdef USE_ESP32_FRAMEWORK_ARDUINO
|
2
|
+
#include "uart_component_esp32_arduino.h"
|
2
3
|
#include "esphome/core/application.h"
|
3
4
|
#include "esphome/core/defines.h"
|
4
5
|
#include "esphome/core/helpers.h"
|
5
6
|
#include "esphome/core/log.h"
|
6
|
-
#include "uart_component_esp32_arduino.h"
|
7
7
|
|
8
8
|
#ifdef USE_LOGGER
|
9
9
|
#include "esphome/components/logger/logger.h"
|
@@ -118,7 +118,7 @@ void ESP32ArduinoUARTComponent::setup() {
|
|
118
118
|
}
|
119
119
|
#endif // USE_LOGGER
|
120
120
|
|
121
|
-
if (next_uart_num >=
|
121
|
+
if (next_uart_num >= SOC_UART_NUM) {
|
122
122
|
ESP_LOGW(TAG, "Maximum number of UART components created already.");
|
123
123
|
this->mark_failed();
|
124
124
|
return;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
#ifdef USE_ESP_IDF
|
2
2
|
|
3
3
|
#include "uart_component_esp_idf.h"
|
4
|
+
#include <cinttypes>
|
4
5
|
#include "esphome/core/application.h"
|
5
6
|
#include "esphome/core/defines.h"
|
6
7
|
#include "esphome/core/helpers.h"
|
7
8
|
#include "esphome/core/log.h"
|
8
|
-
#include <cinttypes>
|
9
9
|
|
10
10
|
#ifdef USE_LOGGER
|
11
11
|
#include "esphome/components/logger/logger.h"
|
@@ -84,7 +84,7 @@ void IDFUARTComponent::setup() {
|
|
84
84
|
}
|
85
85
|
#endif // USE_LOGGER
|
86
86
|
|
87
|
-
if (next_uart_num >=
|
87
|
+
if (next_uart_num >= SOC_UART_NUM) {
|
88
88
|
ESP_LOGW(TAG, "Maximum number of UART components created already.");
|
89
89
|
this->mark_failed();
|
90
90
|
return;
|
@@ -18,7 +18,7 @@ from esphome.cpp_generator import MockObjClass
|
|
18
18
|
|
19
19
|
CODEOWNERS = ["@clydebarrow"]
|
20
20
|
DEPENDENCIES = ["network"]
|
21
|
-
AUTO_LOAD = ["socket"]
|
21
|
+
AUTO_LOAD = ["socket", "xxtea"]
|
22
22
|
MULTI_CONF = True
|
23
23
|
|
24
24
|
udp_ns = cg.esphome_ns.namespace("udp")
|
@@ -27,6 +27,7 @@ UDPComponent = udp_ns.class_("UDPComponent", cg.PollingComponent)
|
|
27
27
|
CONF_BROADCAST = "broadcast"
|
28
28
|
CONF_BROADCAST_ID = "broadcast_id"
|
29
29
|
CONF_ADDRESSES = "addresses"
|
30
|
+
CONF_LISTEN_ADDRESS = "listen_address"
|
30
31
|
CONF_PROVIDER = "provider"
|
31
32
|
CONF_PROVIDERS = "providers"
|
32
33
|
CONF_REMOTE_ID = "remote_id"
|
@@ -84,8 +85,11 @@ CONFIG_SCHEMA = cv.All(
|
|
84
85
|
{
|
85
86
|
cv.GenerateID(): cv.declare_id(UDPComponent),
|
86
87
|
cv.Optional(CONF_PORT, default=18511): cv.port,
|
88
|
+
cv.Optional(
|
89
|
+
CONF_LISTEN_ADDRESS, default="255.255.255.255"
|
90
|
+
): cv.ipv4address_multi_broadcast,
|
87
91
|
cv.Optional(CONF_ADDRESSES, default=["255.255.255.255"]): cv.ensure_list(
|
88
|
-
cv.
|
92
|
+
cv.ipv4address,
|
89
93
|
),
|
90
94
|
cv.Optional(CONF_ROLLING_CODE_ENABLE, default=False): cv.boolean,
|
91
95
|
cv.Optional(CONF_PING_PONG_ENABLE, default=False): cv.boolean,
|
@@ -154,5 +158,7 @@ async def to_code(config):
|
|
154
158
|
for provider in config.get(CONF_PROVIDERS, ()):
|
155
159
|
name = provider[CONF_NAME]
|
156
160
|
cg.add(var.add_provider(name))
|
161
|
+
if (listen_address := str(config[CONF_LISTEN_ADDRESS])) != "255.255.255.255":
|
162
|
+
cg.add(var.set_listen_address(listen_address))
|
157
163
|
if encryption := provider.get(CONF_ENCRYPTION):
|
158
164
|
cg.add(var.set_provider_encryption(name, hash_encryption_key(encryption)))
|