Files
TX-Ultimate-Easy/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml
Edward Firmo 55ede52dd2 Update TX-Ultimate-Easy-ESPHome_core.yaml
Solves #20

I will use this picture as a reference:

![LED numbers from Tasmota](https://templates.blakadder.com/assets/device_images/sonoff_tx_ultimate_T5-86MAIN-V1-0-7-20221108.webp)

Currently, when using a 3-gang device, the following LEDs are currently in use:

| Button/Relay | LED<br>Bottom | LED<br>Top |
| :--: | :--: | :--: |
| 1 | 12 | 22 |
| 2 | 10 | 24 |
| 3 | 8 | 26 |

I will change to the following:
| Button/Relay | LED<br>Bottom | LED<br>Top |
| :--: | :--: | :--: |
| 1 | 13 | 21 |
| 2 | 10 | 24 |
| 3 | 7 | 27 |
2024-06-12 18:13:38 +02:00

1750 lines
47 KiB
YAML

substitutions:
name: tx-ultimate-easy
friendly_name: TX Ultimate Easy
latitude: '0'
longitude: '0'
zone_home: 'zone.home'
default_transition_length: 500ms
invalid_cooldown: 100ms
version: '0.0.1'
api:
id: api_server
services:
- service: set_float
variables:
component: string
val: float
then:
- lambda: |-
if (!isnan(val)) {
if (component == "latitude") sun_entity->set_latitude(val);
else if (component == "longitude") sun_entity->set_longitude(val);
}
binary_sensor:
- id: bs_vibrating
name: Vibrating
icon: mdi:vibrate
internal: false
platform: template
lambda: return sw_vibration_motor->state;
- id: bs_button_1
name: Button 1
icon: mdi:gesture-tap-box
internal: false
platform: template
on_click:
then:
- lambda: |-
if (sl_button_1_action->active_index().has_value() and sl_button_1_action->active_index().value() == 1)
sw_relay_1->toggle();
send_event_to_ha->execute("bs_button_1", "click");
on_double_click:
then:
- lambda: send_event_to_ha->execute("bs_button_1", "double_click");
on_multi_click:
- timing: &long_click-timing
- ON for at least 0.8s
invalid_cooldown: ${invalid_cooldown}
then:
- lambda: send_event_to_ha->execute("bs_button_1", "long_click");
- id: bs_button_2
name: Button 2
icon: mdi:gesture-tap-box
internal: true
platform: template
on_click:
then:
- lambda: |-
if (sl_button_2_action->active_index().has_value() and sl_button_2_action->active_index().value() == 1)
sw_relay_2->toggle();
send_event_to_ha->execute("bs_button_2", "click");
on_double_click:
then:
- lambda: send_event_to_ha->execute("bs_button_2", "double_click");
on_multi_click:
- timing: *long_click-timing
invalid_cooldown: ${invalid_cooldown}
then:
- lambda: send_event_to_ha->execute("bs_button_2", "long_click");
- id: bs_button_3
name: Button 3
icon: mdi:gesture-tap-box
internal: true
platform: template
on_click:
then:
- lambda: |-
if (sl_button_3_action->active_index().has_value() and sl_button_3_action->active_index().value() == 1)
sw_relay_3->toggle();
send_event_to_ha->execute("bs_button_3", "click");
on_double_click:
then:
- lambda: send_event_to_ha->execute("bs_button_3", "double_click");
on_multi_click:
- timing: *long_click-timing
invalid_cooldown: ${invalid_cooldown}
then:
- lambda: send_event_to_ha->execute("bs_button_3", "long_click");
- id: bs_button_4
name: Button 4
icon: mdi:gesture-tap-box
internal: true
platform: template
on_click:
then:
- lambda: |-
if (sl_button_4_action->active_index().has_value() and sl_button_4_action->active_index().value() == 1)
sw_relay_4->toggle();
send_event_to_ha->execute("bs_button_4", "click");
on_double_click:
then:
- lambda: send_event_to_ha->execute("bs_button_4", "double_click");
on_multi_click:
- timing: *long_click-timing
invalid_cooldown: ${invalid_cooldown}
then:
- lambda: send_event_to_ha->execute("bs_button_4", "long_click");
- id: bs_multi_touch
name: Multi-touch
icon: mdi:gesture-two-tap
internal: false
platform: template
on_click:
then:
- lambda: send_event_to_ha->execute("multi_touch", "multi_touch");
- id: bs_swipe_left
name: Swipe left
icon: mdi:gesture-swipe-left
internal: true
platform: template
on_click:
then:
- lambda: send_event_to_ha->execute("swipe", "left");
- id: bs_swipe_right
name: Swipe right
icon: mdi:gesture-swipe-right
internal: true
platform: template
on_click:
then:
- lambda: send_event_to_ha->execute("swipe", "right");
- id: bs_swipe_up
name: Swipe up
icon: mdi:gesture-swipe-up
internal: true
platform: template
on_click:
then:
- lambda: send_event_to_ha->execute("swipe", "up");
- id: bs_swipe_down
name: Swipe down
icon: mdi:gesture-swipe-down
internal: true
platform: template
on_click:
then:
- lambda: send_event_to_ha->execute("swipe", "down");
button:
- id: bt_restart
name: Restart
internal: false
platform: restart
- id: bt_vibrate
name: Vibrate
icon: mdi:vibrate
internal: false
platform: template
on_press:
then:
- script.execute: vibrate
captive_portal:
id: ap_captive_portal
esp32:
board: esp32dev
flash_size: 8MB
esphome:
name: ${name}
friendly_name: ${friendly_name}
platformio_options:
build_flags:
- -D TX_ULTIMATE_EASY_CORE
on_boot:
- priority: 700
then:
- wait_until:
condition:
- lambda: return sl_tx_model_format->active_index().has_value();
- lambda: return sl_tx_model_gang->active_index().has_value();
- lambda: |-
const bool us_model = sl_tx_model_format->active_index().has_value() and
sl_tx_model_format->active_index().value() == 1;
const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ?
(sl_tx_model_gang->active_index().value() + 1) : 0;
bs_button_1->publish_state(false);
bs_button_1->set_internal(num_gangs < 1);
sl_button_1_action->set_internal(num_gangs < 1);
bs_button_2->publish_state(false);
bs_button_2->set_internal(num_gangs < 2);
sl_button_2_action->set_internal(num_gangs < 2);
bs_button_3->publish_state(false);
bs_button_3->set_internal(num_gangs < 3);
sl_button_3_action->set_internal(num_gangs < 3);
bs_button_4->publish_state(false);
bs_button_4->set_internal(num_gangs < 4);
sl_button_4_action->set_internal(num_gangs < 4);
bs_multi_touch->publish_state(false);
bs_swipe_down->publish_state(false);
bs_swipe_down->set_internal(!us_model);
bs_swipe_left->publish_state(false);
bs_swipe_left->set_internal(us_model);
bs_swipe_right->publish_state(false);
bs_swipe_right->set_internal(us_model);
bs_swipe_up->publish_state(false);
bs_swipe_up->set_internal(!us_model);
light_28->set_internal(!us_model);
light_29->set_internal(!us_model);
light_30->set_internal(!us_model);
light_31->set_internal(!us_model);
light_eu->set_internal(us_model);
light_eu_bottom->set_internal(us_model);
light_eu_left->set_internal(us_model);
light_eu_right->set_internal(us_model);
light_eu_top->set_internal(us_model);
light_us->set_internal(!us_model);
light_us_bottom->set_internal(!us_model);
light_us_left->set_internal(!us_model);
light_us_right->set_internal(!us_model);
light_us_top->set_internal(!us_model);
sl_relay_1_mode->set_internal(num_gangs < 1);
sl_relay_2_mode->set_internal(num_gangs < 2);
sl_relay_3_mode->set_internal(num_gangs < 3);
sl_relay_4_mode->set_internal(num_gangs < 4);
sl_relay_light_mode_eu->set_internal(us_model);
sl_relay_light_mode_us->set_internal(!us_model);
auto relay_mode_index = sl_relay_1_mode->active_index();
if (relay_mode_index.has_value()) {
ligth_output_1->set_internal(false or relay_mode_index.value() != 1);
sw_relay_1->set_internal(false or relay_mode_index.value() != 0);
}
relay_mode_index = sl_relay_2_mode->active_index();
if (relay_mode_index.has_value()) {
ligth_output_2->set_internal(num_gangs < 2 or relay_mode_index.value() != 1);
sw_relay_2->set_internal(num_gangs < 2 or relay_mode_index.value() != 0);
}
relay_mode_index = sl_relay_3_mode->active_index();
if (relay_mode_index.has_value()) {
ligth_output_3->set_internal(num_gangs < 3 or relay_mode_index.value() != 1);
sw_relay_3->set_internal(num_gangs < 3 or relay_mode_index.value() != 0);
}
relay_mode_index = sl_relay_4_mode->active_index();
if (relay_mode_index.has_value()) {
ligth_output_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 1);
sw_relay_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 0);
}
switch (num_gangs) {
case 1: // 1 Gang
if (us_model) {
id(gb_lights_1) = { light_us_rl_1_1_left };
id(gb_lights_2) = { light_us_rl_1_1_right };
} else {
id(gb_lights_1) = { light_eu_rl_1_1_bottom };
id(gb_lights_2) = { light_eu_rl_1_1_top };
}
break;
case 2: // 2 Gang
if (us_model) {
id(gb_lights_1) = { light_us_rl_1_2_left, light_us_rl_2_2_left };
id(gb_lights_2) = { light_us_rl_1_2_right, light_us_rl_2_2_right };
} else {
id(gb_lights_1) = { light_eu_rl_1_2_bottom, light_eu_rl_2_2_bottom };
id(gb_lights_2) = { light_eu_rl_1_2_top, light_eu_rl_2_2_top };
}
break;
case 3: // 3 Gang
if (us_model) {
id(gb_lights_1) = { light_us_rl_1_3_left, light_us_rl_2_3_left, light_us_rl_3_3_left };
id(gb_lights_2) = { light_us_rl_1_3_right, light_us_rl_2_3_right, light_us_rl_3_3_right };
} else {
id(gb_lights_1) = { light_eu_rl_1_3_bottom, light_eu_rl_2_3_bottom, light_eu_rl_3_3_bottom };
id(gb_lights_2) = { light_eu_rl_1_3_top, light_eu_rl_2_3_top, light_eu_rl_3_3_top };
}
break;
case 4: // 3 Gang
if (us_model) {
id(gb_lights_1) = { light_us_rl_1_4_left, light_us_rl_2_4_left, light_us_rl_3_4_left, light_us_rl_4_4_left };
id(gb_lights_2) = { light_us_rl_1_4_right, light_us_rl_2_4_right, light_us_rl_3_4_right, light_us_rl_4_4_right };
} else {
id(gb_lights_1) = { light_eu_rl_1_4_bottom, light_eu_rl_2_4_bottom, light_eu_rl_3_4_bottom, light_eu_rl_4_4_bottom };
id(gb_lights_2) = { light_eu_rl_1_4_top, light_eu_rl_2_4_top, light_eu_rl_3_4_top, light_eu_rl_4_4_top };
}
break;
}
- priority: 600 # This is where most sensors are set up.
then:
- lambda: |-
tx_fw_version->publish_state("${version}");
tx_device_name->publish_state("${name}");
- priority: -100 # At this priority, pretty much everything should already be initialized.
then:
- lambda: send_event_to_ha->execute("boot", "done");
external_components:
- source: github://edwardtfn/TX-Ultimate-Easy@dev # Change this before releasing
components:
- tx_ultimate_easy
globals:
- id: gb_lights_1
type: std::vector<light::LightState*>
restore_value: false
- id: gb_lights_2
type: std::vector<light::LightState*>
restore_value: false
i2s_audio:
id: if_i2s_audio
i2s_bclk_pin: GPIO2
i2s_lrclk_pin: GPIO4
improv_serial:
id: serial_improv
light:
- id: ligth_output_1
name: Light output 1
internal: true
platform: binary
output: output_relay_1
- id: ligth_output_2
name: Light output 2
internal: true
platform: binary
output: output_relay_2
- id: ligth_output_3
name: Light output 3
internal: true
platform: binary
output: output_relay_3
- id: ligth_output_4
name: Light output 4
internal: true
platform: binary
output: output_relay_4
- id: light_full
name: Light - All
internal: true
platform: neopixelbus
type: GRB
variant: WS2811
num_leds: 32
pin: GPIO13
- id: light_eu
name: Light
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 0
to: 28
effects: &light_effects_full
- addressable_rainbow:
- addressable_rainbow:
name: "Rainbow - Fast"
speed: 50
- pulse:
- pulse:
name: "Pulse - Fast"
transition_length: 0.5s
update_interval: 0.5s
- pulse:
name: "Pulse - Slow"
update_interval: 2s
- addressable_scan:
- addressable_scan:
name: Scan Effect With Custom Values
move_interval: 100ms
scan_width: 3
- addressable_twinkle:
- addressable_twinkle:
name: Twinkle Effect With Custom Values
twinkle_probability: 5%
progress_interval: 4ms
- addressable_random_twinkle:
- addressable_random_twinkle:
name: Random Twinkle Effect With Custom Values
twinkle_probability: 20%
progress_interval: 32ms
- addressable_fireworks:
- addressable_fireworks:
name: Fireworks Effect With Custom Values
update_interval: 32ms
spark_probability: 10%
use_random_color: false
fade_out_rate: 120
- addressable_flicker:
- addressable_flicker:
name: Flicker Effect With Custom Values
update_interval: 16ms
intensity: 5%
- random:
- id: light_us
name: Light
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 0
to: 31
effects: *light_effects_full
- id: light_eu_bottom
name: Light - Bottom
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 6
to: 12
reversed: true
effects: *light_effects_full
- id: light_eu_left
name: Light - Left
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 13
to: 19
reversed: true
effects: *light_effects_full
- id: light_eu_right
name: Light - Right
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 27
to: 27
reversed: false
- id: light_full
from: 0
to: 5
reversed: false
effects: *light_effects_full
- id: light_eu_top
name: Light - Top
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 20
to: 26
reversed: false
effects: *light_effects_full
- id: light_us_bottom
name: Light - Bottom
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 10
to: 15
reversed: true
effects: *light_effects_full
- id: light_us_left
name: Light - Left
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 15
to: 24
reversed: true
effects: *light_effects_full
- id: light_us_right
name: Light - Right
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 31
to: 31
reversed: false
- id: light_full
from: 0
to: 8
reversed: false
effects: *light_effects_full
- id: light_us_top
name: Light - Top
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 25
to: 30
reversed: false
effects: *light_effects_full
- id: light_00
name: Light - LED 00
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 0
to: 0
- id: light_01
name: Light - LED 01
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 1
to: 1
- id: light_02
name: Light - LED 02
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 2
to: 2
- id: light_03
name: Light - LED 03
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 3
to: 3
- id: light_04
name: Light - LED 04
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 4
to: 4
- id: light_05
name: Light - LED 05
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 5
to: 5
- id: light_06
name: Light - LED 06
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 6
to: 6
- id: light_07
name: Light - LED 07
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 7
to: 7
- id: light_08
name: Light - LED 08
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 8
to: 8
- id: light_09
name: Light - LED 09
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 9
to: 9
- id: light_10
name: Light - LED 10
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 10
to: 10
- id: light_11
name: Light - LED 11
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 11
to: 11
- id: light_12
name: Light - LED 12
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 12
to: 12
- id: light_13
name: Light - LED 13
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 13
to: 13
- id: light_14
name: Light - LED 14
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 14
to: 14
- id: light_15
name: Light - LED 15
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 15
to: 15
- id: light_16
name: Light - LED 16
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 16
to: 16
- id: light_17
name: Light - LED 17
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 17
to: 17
- id: light_18
name: Light - LED 18
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 18
to: 18
- id: light_19
name: Light - LED 19
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 19
to: 19
- id: light_20
name: Light - LED 20
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 20
to: 20
- id: light_21
name: Light - LED 21
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 21
to: 21
- id: light_22
name: Light - LED 22
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 22
to: 22
- id: light_23
name: Light - LED 23
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 23
to: 23
- id: light_24
name: Light - LED 24
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 24
to: 24
- id: light_25
name: Light - LED 25
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 25
to: 25
- id: light_26
name: Light - LED 26
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 26
to: 26
- id: light_27
name: Light - LED 27
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 27
to: 27
- id: light_28
name: Light - LED 28
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 28
to: 28
- id: light_29
name: Light - LED 29
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 29
to: 29
- id: light_30
name: Light - LED 30
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 30
to: 30
- id: light_31
name: Light - LED 31
internal: true
disabled_by_default: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 31
to: 31
- id: light_eu_rl_1_1_bottom
name: Light - Relay 1 of 1 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 9
to: 9
- id: light_eu_rl_1_1_top
name: Light - Relay 1 of 1 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 23
to: 23
- id: light_eu_rl_1_2_bottom
name: Light - Relay 1 of 2 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 11
to: 11
- id: light_eu_rl_1_2_top
name: Light - Relay 1 of 2 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 21
to: 21
- id: light_eu_rl_2_2_bottom
name: Light - Relay 2 of 2 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 7
to: 7
- id: light_eu_rl_2_2_top
name: Light - Relay 2 of 2 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 25
to: 25
- id: light_eu_rl_1_3_bottom
name: Light - Relay 1 of 3 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 12
to: 12
- id: light_eu_rl_1_3_top
name: Light - Relay 1 of 3 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 20
to: 20
- id: light_eu_rl_2_3_bottom
name: Light - Relay 2 of 3 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 9
to: 9
- id: light_eu_rl_2_3_top
name: Light - Relay 2 of 3 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 23
to: 23
- id: light_eu_rl_3_3_bottom
name: Light - Relay 3 of 3 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 6
to: 6
- id: light_eu_rl_3_3_top
name: Light - Relay 3 of 3 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 26
to: 26
- id: light_eu_rl_1_4_bottom
name: Light - Relay 1 of 4 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 12
to: 12
- id: light_eu_rl_1_4_top
name: Light - Relay 1 of 4 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 20
to: 20
- id: light_eu_rl_2_4_bottom
name: Light - Relay 2 of 4 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 10
to: 10
- id: light_eu_rl_2_4_top
name: Light - Relay 2 of 4 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 22
to: 22
- id: light_eu_rl_3_4_bottom
name: Light - Relay 3 of 4 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 8
to: 8
- id: light_eu_rl_3_4_top
name: Light - Relay 3 of 4 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 24
to: 24
- id: light_eu_rl_4_4_bottom
name: Light - Relay 4 of 4 (bottom)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 6
to: 6
- id: light_eu_rl_4_4_top
name: Light - Relay 4 of 4 (top)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 26
to: 26
- id: light_us_rl_1_1_left
name: Light - Relay 1 of 1 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 15
to: 24
- id: light_us_rl_1_1_right
name: Light - Relay 1 of 1 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 31
to: 31
- id: light_full
from: 0
to: 8
- id: light_us_rl_1_2_left
name: Light - Relay 1 of 2 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 20
to: 24
- id: light_us_rl_1_2_right
name: Light - Relay 1 of 2 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 31
to: 31
- id: light_full
from: 0
to: 3
- id: light_us_rl_2_2_left
name: Light - Relay 2 of 2 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 15
to: 19
- id: light_us_rl_2_2_right
name: Light - Relay 2 of 2 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 4
to: 8
- id: light_us_rl_1_3_left
name: Light - Relay 1 of 3 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 22
to: 23
- id: light_us_rl_1_3_right
name: Light - Relay 1 of 3 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 0
to: 1
- id: light_us_rl_2_3_left
name: Light - Relay 2 of 3 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 19
to: 20
- id: light_us_rl_2_3_right
name: Light - Relay 2 of 3 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 3
to: 4
- id: light_us_rl_3_3_left
name: Light - Relay 3 of 3 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 17
to: 18
- id: light_us_rl_3_3_right
name: Light - Relay 3 of 3 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 6
to: 7
- id: light_us_rl_1_4_left
name: Light - Relay 1 of 4 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 12
to: 12
- id: light_us_rl_1_4_right
name: Light - Relay 1 of 4 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 31
to: 31
- id: light_us_rl_2_4_left
name: Light - Relay 2 of 4 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 24
to: 24
- id: light_us_rl_2_4_right
name: Light - Relay 2 of 4 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 2
to: 2
- id: light_us_rl_3_4_left
name: Light - Relay 3 of 4 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 21
to: 21
- id: light_us_rl_3_4_right
name: Light - Relay 3 of 4 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 4
to: 4
- id: light_us_rl_4_4_left
name: Light - Relay 4 of 4 (left)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 19
to: 19
- id: light_us_rl_4_4_right
name: Light - Relay 4 of 4 (right)
internal: true
platform: partition
default_transition_length: ${default_transition_length}
segments:
- id: light_full
from: 7
to: 7
# - id: light_status
# name: Light - Status
# platform: esp32_rmt_led_strip
# rgb_order: GRB
# pin: GPIO13
# num_leds: 1
# rmt_channel: 0
# chipset: ws2812
logger:
media_player:
- id: mp_speaker
name: Speaker
platform: i2s_audio
i2s_dout_pin: GPIO15
i2s_audio_id: if_i2s_audio
i2s_comm_fmt: lsb
dac_type: external
mode: mono
mute_pin:
number: GPIO26
inverted: true
allow_other_uses: true
internal: false
number:
- id: nr_vibrating_duration
name: Vibrate duration
icon: mdi:vibrate
unit_of_measurement: ms
# mode: box
internal: false
entity_category: config
platform: template
min_value: 1
max_value: 500
step: 1
initial_value: 15
optimistic: true
restore_value: true
- id: nr_touch_duration
name: Touch duration
icon: mdi:timer-cog-outline
unit_of_measurement: ms
# mode: box
internal: false
entity_category: config
platform: template
min_value: 10
max_value: 1500
step: 1
initial_value: 250
optimistic: true
restore_value: true
ota:
output:
- id: output_relay_1
platform: gpio
pin: GPIO18
- id: output_relay_2
platform: gpio
pin: GPIO17
- id: output_relay_3
platform: gpio
pin: GPIO27
- id: output_relay_4
platform: gpio
pin: GPIO23
psram:
script:
- id: release_buttons
mode: restart
then:
- lambda: |-
if (bs_button_1->state) bs_button_1->publish_state(false);
if (bs_button_2->state) bs_button_2->publish_state(false);
if (bs_button_3->state) bs_button_3->publish_state(false);
if (bs_button_4->state) bs_button_4->publish_state(false);
- id: send_event_to_ha
mode: queued
parameters:
component: string
event: string
then:
- lambda: |-
esphome::api::CustomAPIDevice ha_event;
ha_event.fire_homeassistant_event("esphome.tx_ultimate_easy",
{
{"device_name", tx_device_name->state.c_str()},
{"firmware", "${version}"},
{"component", component},
{"event", event},
});
- id: show_relay_status
mode: restart
then:
- lambda: |-
auto model_format = sl_tx_model_format->active_index();
auto light_index = ((model_format.has_value() and model_format.value() == 0)
? sl_relay_light_mode_eu->active_index()
: sl_relay_light_mode_us->active_index());
if (model_format.has_value() and light_index.has_value() and light_index.value() > 0) {
std::vector<switch_::Switch*> switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4};
uint8_t light_idx = light_index.value();
if (light_idx == 1 or light_idx == 3) {
for (int i = 0; i < id(gb_lights_1).size(); ++i) {
if (switches[i]->state)
id(gb_lights_1)[i]->turn_on().perform();
else
id(gb_lights_1)[i]->turn_off().perform();
}
}
if (light_idx == 2 or light_idx == 3) {
for (int i = 0; i < id(gb_lights_2).size(); ++i) {
if (switches[i]->state)
id(gb_lights_2)[i]->turn_on().perform();
else
id(gb_lights_2)[i]->turn_off().perform();
}
}
}
- id: vibrate
mode: restart
then:
- switch.turn_on: sw_vibration_motor
- delay: !lambda return nr_vibrating_duration->state;
- switch.turn_off: sw_vibration_motor
select:
- id: sl_button_1_action
name: Button 1 action
platform: template
options:
- "None"
- "Relay 1 (toggle)"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_button_2_action
name: Button 2 action
platform: template
options:
- "None"
- "Relay 2 (toggle)"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_button_3_action
name: Button 3 action
platform: template
options:
- "None"
- "Relay 3 (toggle)"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_button_4_action
name: Button 4 action
platform: template
options:
- "None"
- "Relay 4 (toggle)"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_relay_light_mode_eu
name: Relay light mode
platform: template
options:
- "Disabled"
- "Bottom"
- "Top"
- "Both"
initial_option: "Bottom"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dots-square
- id: sl_relay_1_mode
name: Relay 1 mode
platform: template
options:
- "Relay"
- "Light"
- "Not in use"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_relay_2_mode
name: Relay 2 mode
platform: template
options:
- "Relay"
- "Light"
- "Not in use"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_relay_3_mode
name: Relay 3 mode
platform: template
options:
- "Relay"
- "Light"
- "Not in use"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_relay_4_mode
name: Relay 4 mode
platform: template
options:
- "Relay"
- "Light"
- "Not in use"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
- id: sl_relay_light_mode_us
name: Relay light mode
platform: template
options:
- "Disabled"
- "Left"
- "Right"
- "Both"
initial_option: "Right"
optimistic: true
restore_value: true
internal: true
entity_category: config
disabled_by_default: false
icon: mdi:dots-square
- id: sl_touch_vibration_feedback
name: Touch - Vibration 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
- id: sl_tx_model_format
name: Model (Format)
platform: template
options:
- "EU (Square, T5-xC-86)"
- "US (Rectangle, T5-xC-120)"
initial_option: "EU (Square, T5-xC-86)"
optimistic: true
restore_value: true
internal: false
entity_category: config
disabled_by_default: false
icon: mdi:tablet-cellphone
- id: sl_tx_model_gang
name: Model (Gang)
platform: template
options:
- "1 Gang"
- "2 Gang"
- "3 Gang"
- "4 Gang"
initial_option: "1 Gang"
optimistic: true
restore_value: true
internal: false
entity_category: config
disabled_by_default: false
icon: mdi:dip-switch
sensor:
- id: sun_elevation
name: Sun Elevation
platform: sun
type: elevation
internal: true
- id: zone_home_latitude
platform: homeassistant
entity_id: ${zone_home}
attribute: latitude
internal: false
on_value:
- lambda: if (!isnan(x)) sun_entity->set_latitude(x);
- id: zone_home_longitude
platform: homeassistant
entity_id: ${zone_home}
attribute: longitude
internal: false
on_value:
- lambda: if (!isnan(x)) sun_entity->set_longitude(x);
sun:
id: sun_entity
latitude: ${latitude}
longitude: ${longitude}
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: sw_relay_1
name: Relay 1
platform: output
output: output_relay_1
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
then:
- script.execute: show_relay_status
on_turn_off:
then:
- script.execute: show_relay_status
- id: sw_relay_2
name: Relay 2
platform: output
output: output_relay_2
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
then:
- script.execute: show_relay_status
on_turn_off:
then:
- script.execute: show_relay_status
- id: sw_relay_3
name: Relay 3
platform: output
output: output_relay_3
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
then:
- script.execute: show_relay_status
on_turn_off:
then:
- script.execute: show_relay_status
- id: sw_relay_4
name: Relay 4
platform: output
output: output_relay_4
restore_mode: RESTORE_DEFAULT_OFF
internal: true
on_turn_on:
then:
- script.execute: show_relay_status
on_turn_off:
then:
- script.execute: show_relay_status
- id: sw_touch_panel_power
name: Touch panel - Power
platform: gpio
pin:
number: GPIO5
inverted: true
restore_mode: ALWAYS_ON
internal: false
entity_category: config
- id: sw_vibration_motor
name: Vibration motor
platform: gpio
pin: GPIO21
restore_mode: ALWAYS_OFF
internal: true
on_turn_on:
then:
- lambda: bs_vibrating->publish_state(true);
on_turn_off:
then:
- lambda: bs_vibrating->publish_state(false);
text_sensor:
- id: tx_fw_version
name: Firmware version
platform: template
entity_category: diagnostic
icon: mdi:tag-text-outline
internal: false
update_interval: never
lambda: |-
return {"${version}"};
- id: tx_device_name
name: Device Name
platform: template
icon: mdi:identifier
entity_category: diagnostic
internal: false
disabled_by_default: false
lambda: |-
return {"${name}"};
filters:
- lambda: |-
const std::string raw_name = x;
std::string result;
bool last_was_underscore = false;
for (const char& c : raw_name) {
if (isalnum(c)) {
result += tolower(c); // Add alphanumeric characters as lowercase
last_was_underscore = false;
} else if (!last_was_underscore) { // Replace non-alphanumeric with '_' but avoid consecutive '_'
result += '_';
last_was_underscore = true;
}
}
return result;
time:
- id: time_source
platform: homeassistant
tx_ultimate_easy:
id: tx_ultimate
uart: uart_touch
on_multi_touch_release:
- lambda: |-
if (sl_touch_vibration_feedback->state == "On press" or sl_touch_vibration_feedback->state == "Always")
vibrate->execute();
bs_multi_touch->publish_state(true);
release_buttons->execute();
- delay: !lambda return nr_touch_duration->state;
- lambda: bs_multi_touch->publish_state(false);
on_press:
- lambda: |-
if (sl_touch_vibration_feedback->state == "On press" or sl_touch_vibration_feedback->state == "Always")
vibrate->execute();
auto model_index = sl_tx_model_gang->active_index();
if (model_index.has_value()) {
uint8_t model_idx = model_index.value() + 1;
switch (model_idx) {
case 1: // 1 Gang
bs_button_1->publish_state(true);
break;
case 2: // 2 Gang
if (touch.x <= 5) bs_button_1->publish_state(true);
else bs_button_2->publish_state(true);
break;
case 3: // 3 Gang
if (touch.x <= 3) bs_button_1->publish_state(true);
else if (touch.x <= 7) bs_button_2->publish_state(true);
else bs_button_3->publish_state(true);
break;
case 4: // 4 Gang
if (touch.x <= 2) bs_button_1->publish_state(true);
else if (touch.x <= 5) bs_button_2->publish_state(true);
else if (touch.x <= 8) bs_button_3->publish_state(true);
else bs_button_4->publish_state(true);
break;
}
}
on_release:
- lambda: |-
if (sl_touch_vibration_feedback->state == "On release" or sl_touch_vibration_feedback->state == "Always")
vibrate->execute();
release_buttons->execute();
if (bs_swipe_left->state) bs_swipe_left->publish_state(false);
if (bs_swipe_right->state) bs_swipe_right->publish_state(false);
on_swipe_left:
- lambda: |-
bs_swipe_left->publish_state(true);
release_buttons->execute();
- delay: !lambda return nr_touch_duration->state;
- lambda: bs_swipe_left->publish_state(false);
on_swipe_right:
- lambda: |-
bs_swipe_right->publish_state(true);
release_buttons->execute();
- delay: !lambda return nr_touch_duration->state;
- lambda: bs_swipe_right->publish_state(false);
on_touch_event:
- lambda: |-
ESP_LOGD("tx_ultimate_easy.on_touch_event", "Touch event:");
ESP_LOGD("tx_ultimate_easy.on_touch_event", " State: %i (%s)", touch.state, touch.state_str.c_str());
ESP_LOGD("tx_ultimate_easy.on_touch_event", " Position: %i", touch.x);
uart:
id: uart_touch
tx_pin: GPIO19
rx_pin: GPIO22
baud_rate: 115200
web_server:
wifi:
ap: