Split files even more

This commit is contained in:
Edward Firmo
2024-12-25 23:01:33 +01:00
parent 4378952d97
commit 81c6620fbf
12 changed files with 348 additions and 94 deletions

View File

@@ -11,103 +11,22 @@
##### - For normal system use, modifications to this file are NOT required. #####
####################################################################################################
---
substitutions:
# RTTTL format: name:d=duration,o=octave,b=tempo:notes
# d=32 (32nd note), o=5 (octave 5), b=100 (tempo 100)
tone_volume_change: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b" # Use "none" to disable sound
api:
actions:
- action: rtttl_play
variables:
# The RTTTL string for the melody to be played.
# It should follow the RTTTL format, including the melody's name,
# default settings, and a sequence of notes.
tone: string
then:
- lambda: |-
rtttl_speaker->stop();
if (rtttl_speaker_gain->state > 0) {
ESP_LOGI("api", "Play tone: '%s'", tone.c_str());
rtttl_speaker->play(tone.c_str());
}
bluetooth_proxy:
esp32:
framework:
type: esp-idf
sdkconfig_options:
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST: "y"
CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY: "y"
CONFIG_ESP32_REV_MIN_3: "y"
CONFIG_MBEDTLS_DYNAMIC_BUFFER: "y"
CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT: "y"
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA: "y"
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC: "y"
CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY: "y"
CONFIG_SPIRAM_RODATA: "y"
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP: "y"
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_ADDON_BLE_PROXY
light:
- id: !extend light_full
platform: esp32_rmt_led_strip
rgb_order: GRB
rmt_channel: 1
chipset: ws2812
type: !remove
variant: !remove
max_refresh_rate: 33ms
use_psram: true
media_player: !remove
number:
- id: rtttl_speaker_gain
name: Sound - Volume
platform: template
max_value: 100
min_value: 0
step: 1
initial_value: 100
unit_of_measurement: "%"
internal: false
disabled_by_default: true
entity_category: config
device_class: sound_pressure
restore_value: true
optimistic: true
set_action:
then:
- lambda: |-
rtttl_speaker->set_gain((100-(x/10.0f))/100.0f);
std::string tone_volume_change = "${tone_volume_change}";
// Play sound if tone_volume_change is not "none"
if (x > 0 and !tone_volume_change.empty() and tone_volume_change != "none")
rtttl_speaker->play(tone_volume_change);
rtttl_speaker->dump_config();
rtttl:
- id: rtttl_speaker
speaker: mp_speaker
script:
- id: !extend dump_config
then:
- lambda: |-
ESP_LOGCONFIG("addon_ble_proxy", "Add-on BLE Proxy installed");
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
speaker:
- id: mp_speaker
platform: i2s_audio
dac_type: external
i2s_dout_pin: GPIO15
i2s_audio_id: if_i2s_audio
i2s_comm_fmt: stand_msb
channel: mono
// Identify itself
ESP_LOGCONFIG("addon_ble_proxy", "Add-on BLE Proxy installed");
...

View File

@@ -0,0 +1,51 @@
####################################################################################################
##### TX Ultimate Easy for ESPHome #####
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
####################################################################################################
##### Purpose: ESPHome - Add-on - Media player #####
####################################################################################################
##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo #####
####################################################################################################
##### NOTE: #####
##### - Make changes ONLY if absolutely necessary and you have the required knowledge. #####
##### - For normal system use, modifications to this file are NOT required. #####
####################################################################################################
---
packages:
core_hw_audio: !include TX-Ultimate-Easy-ESPHome_core_hw_audio.yaml
esp32:
framework:
type: arduino
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_ADDON_MEDIA_PLAYER
media_player:
- id: mp_media_player
name: Media Player
internal: false
platform: i2s_audio
i2s_dout_pin: GPIO15
i2s_audio_id: if_i2s_audio
i2s_comm_fmt: msb # Experimental - It was 'lsb' until v2024.12.12
dac_type: external
mode: mono
script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
#if !defined(TX_ULTIMATE_EASY_CORE_HW_AUDIO)
#error "The package TX-Ultimate-Easy-ESPHome_core_hw_audio.yaml is required."
#endif
// Identify itself
ESP_LOGCONFIG("addon_media_player", "Add-on Media Player installed");
...

View File

@@ -0,0 +1,176 @@
####################################################################################################
##### TX Ultimate Easy for ESPHome #####
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
####################################################################################################
##### Purpose: ESPHome - Add-on - Speaker #####
####################################################################################################
##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo #####
####################################################################################################
##### NOTE: #####
##### - Make changes ONLY if absolutely necessary and you have the required knowledge. #####
##### - For normal system use, modifications to this file are NOT required. #####
####################################################################################################
---
substitutions:
# RTTTL format: name:d=duration,o=octave,b=tempo:notes
# d=32 (32nd note), o=5 (octave 5), b=100 (tempo 100)
tone_volume_change: "scale_up:d=32,o=5,b=100:c,c#,d#,e,f#,g#,a#,b" # Use "none" to disable sound
click_sound: |-
[
0x01,0x02,0x04,0x06,0x07,0x08,0x08,0x06,0x01,0xFA,0xF4,0xEF,0xEE,0xF1,0xF7,0xFF,0x07,0x0E,
0x11,0x11,0x10,0x0C,0x06,0xFF,0xF8,0xF1,0xEC,0xEA,0xEC,0xF2,0xF9,0xFF,0x05,0x0A,0x10,0x14,
0x17,0x17,0x14,0x0B,0xFD,0xED,0xE0,0xD9,0xDB,0xE6,0xF7,0x0A,0x19,0x20,0x1E,0x14,0x05,0xF4,
0xE5,0xDF,0xE4,0xF4,0x0C,0x24,0x36,0x3D,0x35,0x20,0xFF,0xDD,0xC0,0xAE,0xA9,0xB0,0xC4,0xE0,
0x03,0x26,0x48,0x62,0x70,0x6D,0x59,0x35,0x08,0xD8,0xAC,0x8D,0x80,0x85,0x9C,0xC1,0xF0,0x21,
0x4E,0x6F,0x7F,0x7A,0x63,0x3D,0x0F,0xE0,0xB7,0x9B,0x90,0x96,0xAC,0xCE,0xF6,0x1D,0x3C,0x50,
0x55,0x4D,0x3A,0x20,0x04,0xEC,0xD8,0xCC,0xC9,0xCD,0xD8,0xE8,0xF9,0x0A,0x17,0x1F,0x20,0x1C,
0x12,0x07,0xFC,0xF2,0xEC,0xEB,0xED,0xF3,0xFA,0x02,0x0A,0x10,0x12,0x12,0x0E,0x07,0xFE,0xF5,
0xED,0xEA,0xEB,0xEF,0xF7,0x00,0x0A,0x10,0x13,0x12,0x0F,0x09,0x02,0xFB,0xF5,0xF3,0xF2,0xF3,
0xF6,0xFB,0xFF,0x03,0x05,0x07,0x08,0x07,0x05,0x03,0x01,0xFF,0xFE,0xFC,0xFB,0xFB,0xFC,0xFC,
0xFD,0xFE,0xFF,0x00,0x01,0x02,0x02,0x01
]
packages:
core_hw_audio: !include TX-Ultimate-Easy-ESPHome_core_hw_audio.yaml
api:
actions:
- action: rtttl_play
variables:
# The RTTTL string for the melody to be played.
# It should follow the RTTTL format, including the melody's name,
# default settings, and a sequence of notes.
tone: string
then:
- lambda: |-
rtttl_speaker->stop();
if (rtttl_speaker_gain->state > 0) {
ESP_LOGI("api", "Play tone: '%s'", tone.c_str());
rtttl_speaker->play(tone.c_str());
}
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_ADDON_SPEAKER
number:
- id: rtttl_speaker_gain
name: Sound - Volume
platform: template
max_value: 100
min_value: 0
step: 1
initial_value: 100
unit_of_measurement: "%"
internal: false
disabled_by_default: true
entity_category: config
device_class: sound_pressure
restore_value: true
optimistic: true
set_action:
then:
- lambda: |-
rtttl_speaker->set_gain((100-(x/10.0f))/100.0f);
std::string tone_volume_change = "${tone_volume_change}";
// Play sound if tone_volume_change is not "none"
if (x > 0 and !tone_volume_change.empty() and tone_volume_change != "none")
rtttl_speaker->play(tone_volume_change);
rtttl_speaker->dump_config();
rtttl:
- id: rtttl_speaker
speaker: speaker_embedded
script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
#if !defined(TX_ULTIMATE_EASY_CORE_HW_AUDIO)
#error "The package TX-Ultimate-Easy-ESPHome_core_hw_audio.yaml is required."
#endif
// Identify itself
ESP_LOGCONFIG("addon_speaker", "Add-on Speaker installed");
- id: speaker_play_click
then:
- if:
condition:
not:
- speaker.is_playing: speaker_embedded
then:
- speaker.play:
id: speaker_embedded
data: !lambda return std::vector<uint8_t>(${click_sound});
- wait_until:
condition:
not:
- speaker.is_playing: speaker_embedded
- speaker.stop: speaker_embedded
- id: !extend touch_on_multi_touch_release
then:
- script.execute: touch_on_multi_touch_release_speaker
- id: touch_on_multi_touch_release_speaker
mode: restart
then:
- lambda: |-
if (sl_touch_speaker_feedback->state != "Disabled")
vibrate->execute();
- id: !extend touch_on_press
then:
- script.execute: touch_on_press_speaker
- id: touch_on_press_speaker
mode: restart
then:
- lambda: |-
if (sl_touch_speaker_feedback->state == "On press" or sl_touch_speaker_feedback->state == "Always")
vibrate->execute();
- id: !extend touch_on_release
then:
- script.execute: touch_on_release_speaker
- id: touch_on_release_speaker
mode: restart
then:
- lambda: |-
if (sl_touch_speaker_feedback->state == "On release" or sl_touch_speaker_feedback->state == "Always")
vibrate->execute();
select:
- id: sl_touch_speaker_feedback
name: Touch - Speaker feedback
platform: template
options:
- "Disabled"
- "On press"
- "On release"
- "Always"
initial_option: "Disabled"
optimistic: true
restore_value: true
internal: false
entity_category: config
disabled_by_default: false
icon: mdi:vibrate
speaker:
- id: speaker_embedded
platform: i2s_audio
dac_type: external
i2s_dout_pin: GPIO15
i2s_audio_id: if_i2s_audio
i2s_comm_fmt: stand_msb
channel: mono
...

View File

@@ -31,7 +31,6 @@ packages:
# yamllint disable rule:colons
core_hw_buttons: !include TX-Ultimate-Easy-ESPHome_core_hw_buttons.yaml
core_hw_leds: !include TX-Ultimate-Easy-ESPHome_core_hw_leds.yaml
core_hw_media_player: !include TX-Ultimate-Easy-ESPHome_core_hw_media_player.yaml
core_hw_relays: !include TX-Ultimate-Easy-ESPHome_core_hw_relays.yaml
core_hw_touch: !include TX-Ultimate-Easy-ESPHome_core_hw_touch.yaml
core_hw_vibration: !include TX-Ultimate-Easy-ESPHome_core_hw_vibration.yaml
@@ -71,8 +70,22 @@ captive_portal:
id: ap_captive_portal
esp32:
board: esp32dev
board: esp32dev # adafruit_feather_esp32_v2 # esp32dev
flash_size: 8MB
framework:
type: esp-idf
#sdkconfig_options:
#CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST: "y"
#CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY: "y"
#CONFIG_ESP32_REV_MIN_3: "y"
#CONFIG_ESPTOOLPY_FLASHSIZE_8MB: "y"
#CONFIG_MBEDTLS_DYNAMIC_BUFFER: "y"
#CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT: "y"
#CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA: "y"
#CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC: "y"
#CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY: "y"
#CONFIG_SPIRAM_RODATA: "y"
#CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP: "y"
esphome:
name: ${name}

View File

@@ -0,0 +1,32 @@
####################################################################################################
##### TX Ultimate Easy for ESPHome #####
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
####################################################################################################
##### Purpose: ESPHome - Core - I2S Audio #####
####################################################################################################
##### Author: edwardtfn - https://github.com/edwardtfn - https://buymeacoffee.com/edwardfirmo #####
####################################################################################################
##### NOTE: #####
##### - Make changes ONLY if absolutely necessary and you have the required knowledge. #####
##### - For normal system use, modifications to this file are NOT required. #####
####################################################################################################
---
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_CORE_HW_AUDIO
i2s_audio:
id: if_i2s_audio
i2s_bclk_pin: GPIO2
i2s_lrclk_pin: GPIO4
script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
...

View File

@@ -57,6 +57,11 @@ binary_sensor:
internal: false
<<: *binary_sensor_button_base
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_CORE_HW_BUTTONS
globals:
- id: button_press_button
type: uint8_t
@@ -203,6 +208,12 @@ script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
// Button's actions
ESP_LOGCONFIG("core_hw_buttons", "Button%s action%s:",
id(gang_count_plural_suffix).c_str(),
id(gang_count_plural_suffix).c_str());

View File

@@ -29,6 +29,11 @@ substitutions:
LIGHT_SIDES_RESTORE_MODE: RESTORE_DEFAULT_OFF
LIGHT_INDIVIDUAL_RESTORE_MODE: RESTORE_DEFAULT_OFF
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_CORE_HW_LEDS
globals:
- id: gb_lights_1
type: std::vector<light::LightState*>
@@ -42,13 +47,15 @@ light:
- id: light_full
name: Light - All
internal: true
platform: neopixelbus
type: GRB
variant: WS2811
# method: esp32_rmt
platform: esp32_rmt_led_strip
rgb_order: GRB
rmt_channel: 1
chipset: ws2812
num_leds: 32
pin: GPIO13
restore_mode: ${LIGHT_FULL_RESTORE_MODE}
max_refresh_rate: 33ms
use_psram: true
# Those lights are available based on the model selections
- &light_partition_with_effects
@@ -489,6 +496,11 @@ script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
// Relay's LEDs modes
ESP_LOGCONFIG("core_hw_leds", "Relay%s LEDs mode%s:",
id(gang_count_plural_suffix).c_str(),

View File

@@ -19,6 +19,10 @@ substitutions:
RELAY_RESTORE_MODE: RESTORE_DEFAULT_OFF
LIGHT_RELAYS_RESTORE_MODE: RESTORE_DEFAULT_OFF
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_CORE_HW_RELAYS
globals:
- id: boot_initialization_relays
@@ -637,6 +641,12 @@ script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
// Relay's modes
ESP_LOGCONFIG("core_hw_relays", "Relay%s mode%s:",
id(gang_count_plural_suffix).c_str(),
id(gang_count_plural_suffix).c_str());
@@ -655,6 +665,8 @@ script:
ESP_LOGCONFIG("core_hw_relays", " Relay 4: %s", sl_relay_4_mode->has_state()
? sl_relay_4_mode->state.c_str()
: "Unknown");
// Relay's states
ESP_LOGCONFIG("core_hw_relays", "Relay%s state%s:",
id(gang_count_plural_suffix).c_str(),
id(gang_count_plural_suffix).c_str());
@@ -667,11 +679,15 @@ script:
ESP_LOGCONFIG("core_hw_relays", " Relay 4: %s", sw_relay_4->state ? "ON" : "OFF");
ESP_LOGCONFIG("core_hw_relays", "Expose Relay's LEDs to Home Assistant: %s",
YESNO(sw_expose_relays_leds_to_ha->state));
// Boot initialization statuses
ESP_LOGCONFIG("core_hw_relays", "Boot initialization flags:");
ESP_LOGCONFIG("core_hw_relays", " Overall: %s", YESNO(id(boot_initialization_relays)));
ESP_LOGCONFIG("core_hw_relays", " Light modes: %s", YESNO(id(boot_initialization_relays_light_modes)));
ESP_LOGCONFIG("core_hw_relays", " Relay modes: %s", YESNO(id(boot_initialization_relays_relay_modes)));
ESP_LOGCONFIG("core_hw_relays", " Status LEDs: %s", YESNO(id(boot_initialization_relays_relay_leds)));
// Substitutions
ESP_LOGCONFIG("core_hw_relays", "Restore modes:");
ESP_LOGCONFIG("core_hw_relays", " Relays: ${RELAY_RESTORE_MODE}");
ESP_LOGCONFIG("core_hw_relays", " Status LEDs: ${LIGHT_RELAYS_RESTORE_MODE}");

View File

@@ -198,6 +198,11 @@ binary_sensor:
id: bs_swipe_down
state: OFF # yamllint disable-line rule:truthy
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_CORE_HW_TOUCH
external_components:
- source:
type: git
@@ -286,6 +291,12 @@ script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
// Touch panel's state
if (sw_touch_panel_power->state)
ESP_LOGCONFIG("core_hw_touch", "Touch panel - Power: On");
else

View File

@@ -32,6 +32,11 @@ button:
then:
- script.execute: vibrate
esphome:
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_CORE_HW_VIBRATION
number:
- id: nr_vibrating_duration
name: Vibrate duration
@@ -56,6 +61,11 @@ script:
- id: !extend dump_config
then:
- lambda: |-
// Check for requirements
#if !defined(TX_ULTIMATE_EASY_CORE)
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
#endif
// Configuration
ESP_LOGCONFIG("core_hw_vibration", "Touch - Vibration feedback: %s",
sl_touch_vibration_feedback->state.c_str());

View File

@@ -156,6 +156,7 @@ This project builds upon the work of several amazing projects and contributors:
- [SmartHome yourself - SONOFF TX Ultimate for ESPHome](https://github.com/SmartHome-yourself/sonoff-tx-ultimate-for-esphome)
- [Un loco y su tecnología - Sonoff TX Ultimate with ESPHome](https://www.youtube.com/watch?v=58v8oqSQgXQ)
- @PxPert - [Sonoff TX Ultimate and Voice Assistant](https://community.home-assistant.io/t/sonoff-tx-ultimate-and-voice-assistant/682214?u=edwardtfn)
Special thanks to all contributors and community members who help make this project better.

View File

@@ -20,5 +20,7 @@ packages:
refresh: 5min
files:
- ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml
# - ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml # Adds experimental BLE proxy support (limited)
# - ESPHome/TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml # Adds BLE proxy support
# - ESPHome/TX-Ultimate-Easy-ESPHome_addon_media_player.yaml # Adds experimental Media Player (limited)
# - ESPHome/TX-Ultimate-Easy-ESPHome_addon_speaker.yaml # Adds basic audio speaker support
...