Merge pull request #112 from edwardtfn/idf-as-default
Set ESP-IDF as default framework
This commit is contained in:
@@ -2,57 +2,22 @@
|
||||
##### TX Ultimate Easy for ESPHome #####
|
||||
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
|
||||
####################################################################################################
|
||||
##### Purpose: ESPHome Core - Add-on - BLE Proxy #####
|
||||
##### Purpose: ESPHome Core - Add-on - BLE Proxy (REMOVED) #####
|
||||
####################################################################################################
|
||||
##### 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. #####
|
||||
##### REMOVAL NOTICE: #####
|
||||
##### This package has been removed. Please update your configuration. #####
|
||||
##### Add BLE proxy functionality directly in your YAML configuration instead: #####
|
||||
##### bluetooth_proxy: #####
|
||||
####################################################################################################
|
||||
---
|
||||
packages:
|
||||
standard_hw_speaker: !include TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml
|
||||
|
||||
bluetooth_proxy:
|
||||
|
||||
esp32:
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
esphome:
|
||||
platformio_options:
|
||||
build_flags:
|
||||
- -D TX_ULTIMATE_EASY_ADDON_BLE_PROXY
|
||||
|
||||
i2s_audio: !remove
|
||||
|
||||
light:
|
||||
- id: !extend light_full
|
||||
platform: esp32_rmt_led_strip
|
||||
rgb_order: GRB
|
||||
# rmt_channel: 1 # Not supported with IDF 5
|
||||
chipset: ws2812
|
||||
max_refresh_rate: 33ms
|
||||
use_psram: false
|
||||
type: !remove
|
||||
variant: !remove
|
||||
|
||||
media_player: !remove
|
||||
|
||||
# Trigger the error at compile time
|
||||
script:
|
||||
- id: !extend dump_config_list_packages
|
||||
- id: force_compilation_error
|
||||
then:
|
||||
- script.wait: dump_config
|
||||
- lambda: |-
|
||||
// Check for requirements
|
||||
#if !defined(TX_ULTIMATE_EASY_CORE)
|
||||
#error "The package TX-Ultimate-Easy-ESPHome_core.yaml is required."
|
||||
#endif
|
||||
|
||||
// Identify itself
|
||||
ESP_LOGCONFIG(ESPHOME_PROJECT_NAME, " - Add-on - BLE Proxy");
|
||||
|
||||
switch:
|
||||
- id: !remove sw_speaker_amplifier
|
||||
#error "The package TX-Ultimate-Easy-ESPHome_addon_ble_proxy.yaml has been removed." \
|
||||
"Please remove this package from your configuration and add" \
|
||||
"'bluetooth_proxy:' directly to your YAML instead."
|
||||
...
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
####################################################################################################
|
||||
##### 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:
|
||||
standard_hw_audio: !include TX-Ultimate-Easy-ESPHome_standard_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
|
||||
dac_type: external
|
||||
mode: mono
|
||||
mute_pin:
|
||||
number: GPIO26
|
||||
inverted: true
|
||||
allow_other_uses: true
|
||||
|
||||
script:
|
||||
- id: !extend dump_config_list_packages
|
||||
then:
|
||||
- script.wait: dump_config
|
||||
- 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_STANDARD_HW_AUDIO)
|
||||
#error "The package TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml is required."
|
||||
#endif
|
||||
|
||||
// Identify itself
|
||||
ESP_LOGCONFIG(ESPHOME_PROJECT_NAME, " - Add-on - Media Player");
|
||||
|
||||
switch:
|
||||
- id: sw_speaker_amplifier
|
||||
name: Speaker - Amplifier
|
||||
platform: gpio
|
||||
pin:
|
||||
number: GPIO26
|
||||
inverted: true
|
||||
allow_other_uses: true
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
internal: true
|
||||
entity_category: config
|
||||
...
|
||||
@@ -29,7 +29,6 @@ substitutions:
|
||||
|
||||
DUMP_CONFIG_CALLER_DELAY: 10s # Delay to dump config after requested
|
||||
|
||||
|
||||
api:
|
||||
id: api_server
|
||||
on_client_connected:
|
||||
@@ -63,6 +62,8 @@ button:
|
||||
esp32:
|
||||
board: esp32dev
|
||||
flash_size: 8MB
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
esphome:
|
||||
name: ${name}
|
||||
@@ -99,11 +100,6 @@ globals:
|
||||
restore_value: true
|
||||
initial_value: '0'
|
||||
|
||||
- id: gang_count_plural_suffix
|
||||
type: std::string
|
||||
restore_value: true
|
||||
max_restore_data_length: 3
|
||||
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
@@ -155,7 +151,6 @@ script:
|
||||
if (id(gang_count) < 1 || id(gang_count) > 4) {
|
||||
ESP_LOGE("core_hw_leds", "Invalid number of gangs: %" PRIu8, id(gang_count));
|
||||
}
|
||||
id(gang_count_plural_suffix) = id(gang_count) > 1 ? "s" : "";
|
||||
|
||||
- id: boot_sequence
|
||||
mode: restart
|
||||
@@ -191,7 +186,7 @@ script:
|
||||
ESP_LOGCONFIG("core", "Model format (selected): %s", sl_tx_model_format->state.c_str());
|
||||
ESP_LOGCONFIG("core", "Model format (detected): %s", id(is_us_model) ? "US" : "EU");
|
||||
ESP_LOGCONFIG("core", "Gangs (selected): %s", sl_tx_model_gang->state.c_str());
|
||||
ESP_LOGCONFIG("core", "Gangs (detected): %" PRIu8 "-Gang%s", id(gang_count), id(gang_count_plural_suffix).c_str());
|
||||
ESP_LOGCONFIG("core", "Gangs (detected): %" PRIu8 "-Gang%s", id(gang_count), id(gang_count) > 1 ? "s" : "");
|
||||
|
||||
// System state
|
||||
if (bs_pending_restart->state)
|
||||
|
||||
@@ -209,10 +209,11 @@ script:
|
||||
- id: !extend dump_config
|
||||
then:
|
||||
- lambda: |-
|
||||
std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : "";
|
||||
// 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());
|
||||
gang_count_plural_suffix.c_str(),
|
||||
gang_count_plural_suffix.c_str());
|
||||
ESP_LOGCONFIG("core_hw_buttons", " Relay 1: %s", sl_button_1_action->has_state()
|
||||
? sl_button_1_action->state.c_str()
|
||||
: "Unknown");
|
||||
|
||||
@@ -50,9 +50,14 @@ light:
|
||||
num_leds: 32
|
||||
pin: GPIO13
|
||||
restore_mode: ${LIGHT_FULL_RESTORE_MODE}
|
||||
platform: neopixelbus
|
||||
type: GRB
|
||||
variant: WS2811
|
||||
platform: esp32_rmt_led_strip
|
||||
rgb_order: GRB
|
||||
chipset: ws2812
|
||||
max_refresh_rate: 33ms
|
||||
use_psram: false
|
||||
# platform: neopixelbus
|
||||
# type: GRB
|
||||
# variant: WS2811
|
||||
|
||||
# Those lights are available based on the model selections
|
||||
- &light_partition_with_effects_eu
|
||||
@@ -492,10 +497,11 @@ script:
|
||||
- id: !extend dump_config
|
||||
then:
|
||||
- lambda: |-
|
||||
std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : "";
|
||||
// Relay's LEDs modes
|
||||
ESP_LOGCONFIG("core_hw_leds", "Relay%s LEDs mode%s:",
|
||||
id(gang_count_plural_suffix).c_str(),
|
||||
id(gang_count_plural_suffix).c_str());
|
||||
gang_count_plural_suffix.c_str(),
|
||||
gang_count_plural_suffix.c_str());
|
||||
ESP_LOGCONFIG("core_hw_leds", " Relay 1: %s", id(is_us_model)
|
||||
? sl_relay_1_light_mode_us->state.c_str()
|
||||
: sl_relay_1_light_mode_eu->state.c_str());
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
####################################################################################################
|
||||
##### TX Ultimate Easy for ESPHome #####
|
||||
##### Repository: https://github.com/edwardtfn/TX-Ultimate-Easy #####
|
||||
####################################################################################################
|
||||
##### Purpose: ESPHome Core - Hardware - 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. #####
|
||||
####################################################################################################
|
||||
---
|
||||
i2s_audio:
|
||||
id: if_i2s_audio
|
||||
i2s_bclk_pin: GPIO2
|
||||
i2s_lrclk_pin: GPIO4
|
||||
|
||||
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
|
||||
...
|
||||
@@ -387,17 +387,16 @@ tx_ultimate_easy:
|
||||
|
||||
on_multi_touch_release:
|
||||
then:
|
||||
- homeassistant.event:
|
||||
event: ${EVENT_NAME}
|
||||
data:
|
||||
device_name: !lambda return id(tx_device_name).state.c_str();
|
||||
firmware: ${version}
|
||||
domain: touch
|
||||
type: multi_touch
|
||||
action: release
|
||||
position: !lambda return std::to_string(touch.x);
|
||||
- lambda: |-
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "touch"},
|
||||
{"type", "multi_touch"},
|
||||
{"action", "release"},
|
||||
{"position", std::to_string(touch.x)}
|
||||
});
|
||||
ESP_LOGI("core_hw_touch", "Multi-touch released");
|
||||
touch_on_multi_touch_release->execute();
|
||||
|
||||
@@ -419,38 +418,52 @@ tx_ultimate_easy:
|
||||
|
||||
on_swipe_left:
|
||||
then:
|
||||
- homeassistant.event:
|
||||
event: ${EVENT_NAME}
|
||||
data:
|
||||
device_name: !lambda return id(tx_device_name).state.c_str();
|
||||
firmware: ${version}
|
||||
domain: touch
|
||||
type: swipe
|
||||
action: !lambda |-
|
||||
if (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}")
|
||||
return "left";
|
||||
else
|
||||
return "down";
|
||||
swipe-direction: !lambda |-
|
||||
if (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}")
|
||||
return "left";
|
||||
else
|
||||
return "down";
|
||||
position: !lambda return std::to_string(touch.x);
|
||||
- lambda: |-
|
||||
std::string swipe_direction = (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down";
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "touch"},
|
||||
{"type", "swipe"},
|
||||
{"action", swipe_direction.c_str()},
|
||||
{"swipe-direction", swipe_direction.c_str()},
|
||||
{"position", std::to_string(touch.x)}
|
||||
});
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s", swipe_direction.c_str());
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s",
|
||||
(sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "left" : "down");
|
||||
touch_swipe_left->execute();
|
||||
|
||||
on_swipe_right:
|
||||
then:
|
||||
- homeassistant.event:
|
||||
event: ${EVENT_NAME}
|
||||
data:
|
||||
device_name: !lambda return id(tx_device_name).state.c_str();
|
||||
firmware: ${version}
|
||||
domain: touch
|
||||
type: swipe
|
||||
action: !lambda |-
|
||||
if (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}")
|
||||
return "right";
|
||||
else
|
||||
return "up";
|
||||
swipe-direction: !lambda |-
|
||||
if (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}")
|
||||
return "right";
|
||||
else
|
||||
return "up";
|
||||
position: !lambda return std::to_string(touch.x);
|
||||
- lambda: |-
|
||||
std::string swipe_direction = (sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up";
|
||||
// Send event to Home Assistant
|
||||
esphome::api::CustomAPIDevice ha_event;
|
||||
ha_event.fire_homeassistant_event("${EVENT_NAME}", {
|
||||
{"device_name", id(tx_device_name).state.c_str()},
|
||||
{"firmware", "${version}"},
|
||||
{"domain", "touch"},
|
||||
{"type", "swipe"},
|
||||
{"action", swipe_direction.c_str()},
|
||||
{"swipe-direction", swipe_direction.c_str()},
|
||||
{"position", std::to_string(touch.x)}
|
||||
});
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s", swipe_direction.c_str());
|
||||
ESP_LOGI("core_hw_touch", "Swipe %s",
|
||||
(sl_tx_model_format->state == "${TX_MODEL_FORMAT_EU_TEXT}") ? "right" : "up");
|
||||
touch_swipe_right->execute();
|
||||
|
||||
on_touch_event:
|
||||
|
||||
@@ -11,15 +11,18 @@
|
||||
##### - For normal system use, modifications to this file are NOT required. #####
|
||||
####################################################################################################
|
||||
---
|
||||
substitutions:
|
||||
SWITCH_AUDIO_AMPLIFIER_RESTORE_MODE: RESTORE_DEFAULT_ON
|
||||
|
||||
esphome:
|
||||
platformio_options:
|
||||
build_flags:
|
||||
- -D TX_ULTIMATE_EASY_STANDARD_HW_AUDIO
|
||||
|
||||
i2s_audio:
|
||||
id: if_i2s_audio
|
||||
i2s_bclk_pin: GPIO2
|
||||
i2s_lrclk_pin: GPIO4
|
||||
- id: if_i2s_audio
|
||||
i2s_bclk_pin: GPIO2
|
||||
i2s_lrclk_pin: GPIO4
|
||||
|
||||
script:
|
||||
- id: !extend dump_config_list_packages
|
||||
@@ -33,4 +36,15 @@ script:
|
||||
|
||||
// Identify itself
|
||||
ESP_LOGCONFIG(ESPHOME_PROJECT_NAME, " - Standard - Hardware - Audio");
|
||||
|
||||
switch:
|
||||
- id: sw_audio_amplifier
|
||||
name: Audio Amplifier
|
||||
platform: gpio
|
||||
pin:
|
||||
number: GPIO26
|
||||
inverted: false
|
||||
restore_mode: ${SWITCH_AUDIO_AMPLIFIER_RESTORE_MODE}
|
||||
internal: true
|
||||
entity_category: config
|
||||
...
|
||||
|
||||
@@ -703,10 +703,11 @@ script:
|
||||
- id: !extend dump_config
|
||||
then:
|
||||
- lambda: |-
|
||||
std::string gang_count_plural_suffix = id(gang_count) > 1 ? "s" : "";
|
||||
// Relay's modes
|
||||
ESP_LOGCONFIG("standard_hw_relays", "Relay%s mode%s:",
|
||||
id(gang_count_plural_suffix).c_str(),
|
||||
id(gang_count_plural_suffix).c_str());
|
||||
gang_count_plural_suffix.c_str(),
|
||||
gang_count_plural_suffix.c_str());
|
||||
ESP_LOGCONFIG("standard_hw_relays", " Relay 1: %s", sl_relay_1_mode->has_state()
|
||||
? sl_relay_1_mode->state.c_str()
|
||||
: "Unknown");
|
||||
@@ -725,8 +726,8 @@ script:
|
||||
|
||||
// Relay's states
|
||||
ESP_LOGCONFIG("standard_hw_relays", "Relay%s state%s:",
|
||||
id(gang_count_plural_suffix).c_str(),
|
||||
id(gang_count_plural_suffix).c_str());
|
||||
gang_count_plural_suffix.c_str(),
|
||||
gang_count_plural_suffix.c_str());
|
||||
ESP_LOGCONFIG("standard_hw_relays", " Relay 1: %s", sw_relay_1->state ? "ON" : "OFF");
|
||||
if (id(gang_count) >= 2)
|
||||
ESP_LOGCONFIG("standard_hw_relays", " Relay 2: %s", sw_relay_2->state ? "ON" : "OFF");
|
||||
|
||||
@@ -38,11 +38,11 @@ api:
|
||||
esphome:
|
||||
platformio_options:
|
||||
build_flags:
|
||||
- -D TX_ULTIMATE_EASY_STANDARD_SPEAKER
|
||||
- -D TX_ULTIMATE_EASY_STANDARD_HW_SPEAKER
|
||||
|
||||
number:
|
||||
- id: speaker_volume
|
||||
name: Sound - Volume
|
||||
name: Speaker Volume
|
||||
platform: template
|
||||
max_value: 100
|
||||
min_value: 0
|
||||
@@ -179,4 +179,8 @@ speaker:
|
||||
i2s_audio_id: if_i2s_audio
|
||||
i2s_comm_fmt: stand_msb
|
||||
channel: mono
|
||||
timeout: never
|
||||
bits_per_sample: 16bit
|
||||
sample_rate: 48000
|
||||
buffer_duration: 500ms
|
||||
...
|
||||
|
||||
@@ -12,29 +12,64 @@
|
||||
####################################################################################################
|
||||
---
|
||||
packages:
|
||||
standard_hw_audio: !include TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml
|
||||
standard_hw_speaker: !include TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml
|
||||
|
||||
esphome:
|
||||
platformio_options:
|
||||
build_flags:
|
||||
- -D TX_ULTIMATE_EASY_ADDON_MEDIA_PLAYER
|
||||
- -D TX_ULTIMATE_EASY_STANDARD_MEDIA_PLAYER
|
||||
|
||||
globals:
|
||||
- id: last_media_player_volume
|
||||
type: uint8_t
|
||||
restore_value: false
|
||||
initial_value: '100'
|
||||
- id: persistent_media_player_volume
|
||||
type: uint8_t
|
||||
restore_value: true
|
||||
initial_value: '100'
|
||||
|
||||
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
|
||||
dac_type: external
|
||||
mode: mono
|
||||
mute_pin:
|
||||
number: GPIO26
|
||||
inverted: true
|
||||
allow_other_uses: true
|
||||
platform: speaker
|
||||
codec_support_enabled: true
|
||||
buffer_size: 250000
|
||||
task_stack_in_psram: false
|
||||
announcement_pipeline:
|
||||
speaker: announcement_spk_resampling_input
|
||||
format: WAV
|
||||
num_channels: 1
|
||||
sample_rate: 48000
|
||||
media_pipeline:
|
||||
speaker: media_spk_resampling_input
|
||||
format: FLAC
|
||||
num_channels: 1
|
||||
sample_rate: 48000
|
||||
on_state:
|
||||
then:
|
||||
- lambda: |-
|
||||
// Check if volume has changed and update number entity
|
||||
id(persistent_media_player_volume) = static_cast<uint8_t>(mp_media_player->volume * 100.0f);
|
||||
if (id(persistent_media_player_volume) != id(last_media_player_volume)) {
|
||||
id(last_media_player_volume) = id(persistent_media_player_volume);
|
||||
ESP_LOGD("media_player_volume", "Media player volume changed to %" PRIu8 "%%, updating number entity", id(persistent_media_player_volume));
|
||||
}
|
||||
|
||||
script:
|
||||
- id: !extend boot_sequence
|
||||
then:
|
||||
- script.execute: sync_initial_volume
|
||||
|
||||
- id: !extend dump_config
|
||||
then:
|
||||
- lambda: |-
|
||||
// Volume sync configuration
|
||||
ESP_LOGCONFIG("standard_media_player", "Media Player Volume Sync:");
|
||||
ESP_LOGCONFIG("standard_media_player", " Persistent volume: %" PRIu8 "%", id(persistent_media_player_volume));
|
||||
ESP_LOGCONFIG("standard_media_player", " Current volume: %.1f%%", mp_media_player->volume * 100.0f);
|
||||
|
||||
- id: !extend dump_config_list_packages
|
||||
then:
|
||||
- script.wait: dump_config
|
||||
@@ -42,23 +77,36 @@ script:
|
||||
// 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_STANDARD_HW_AUDIO)
|
||||
#error "The package TX-Ultimate-Easy-ESPHome_standard_hw_audio.yaml is required."
|
||||
#endif
|
||||
#endif // TX_ULTIMATE_EASY_CORE
|
||||
#if !defined(TX_ULTIMATE_EASY_STANDARD_HW_SPEAKER)
|
||||
#error "The package TX-Ultimate-Easy-ESPHome_standard_hw_speaker.yaml is required."
|
||||
#endif // TX_ULTIMATE_EASY_STANDARD_HW_SPEAKER
|
||||
|
||||
// Identify itself
|
||||
ESP_LOGCONFIG(ESPHOME_PROJECT_NAME, " - Add-on - Media Player");
|
||||
ESP_LOGCONFIG(ESPHOME_PROJECT_NAME, " - Standard - Media Player");
|
||||
|
||||
switch:
|
||||
- id: sw_speaker_amplifier
|
||||
name: Speaker - Amplifier
|
||||
platform: gpio
|
||||
pin:
|
||||
number: GPIO26
|
||||
inverted: true
|
||||
allow_other_uses: true
|
||||
restore_mode: RESTORE_DEFAULT_ON
|
||||
internal: true
|
||||
entity_category: config
|
||||
- id: sync_initial_volume
|
||||
mode: restart
|
||||
then:
|
||||
- delay: 2s # Wait for media player to initialize
|
||||
- media_player.volume_set: # Sync initial volume from persisted number entity to media player
|
||||
id: mp_media_player
|
||||
volume: !lambda return id(persistent_media_player_volume) / 100.0f;
|
||||
- lambda: |-
|
||||
id(last_media_player_volume) = id(persistent_media_player_volume);
|
||||
ESP_LOGI("media_player_volume", "Initial volume sync: %.1f%% (restored from persistence)", id(persistent_media_player_volume));
|
||||
|
||||
speaker:
|
||||
- platform: mixer
|
||||
id: mixer_speaker_embedded
|
||||
output_speaker: speaker_embedded
|
||||
source_speakers:
|
||||
- id: announcement_speaker_embedded
|
||||
- id: media_speaker_embedded
|
||||
- platform: resampler
|
||||
id: announcement_spk_resampling_input
|
||||
output_speaker: announcement_speaker_embedded
|
||||
- platform: resampler
|
||||
id: media_spk_resampling_input
|
||||
output_speaker: media_speaker_embedded
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user