diff --git a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml index 71defc6..8ac41eb 100644 --- a/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml +++ b/ESPHome/TX-Ultimate-Easy-ESPHome_core.yaml @@ -32,6 +32,7 @@ binary_sensor: - id: bs_button_1 name: Button 1 + icon: mdi:gesture-tap-box internal: false platform: template on_press: @@ -40,6 +41,7 @@ binary_sensor: - id: bs_button_2 name: Button 2 + icon: mdi:gesture-tap-box internal: true platform: template on_press: @@ -48,6 +50,7 @@ binary_sensor: - id: bs_button_3 name: Button 3 + icon: mdi:gesture-tap-box internal: true platform: template on_press: @@ -56,6 +59,7 @@ binary_sensor: - id: bs_button_4 name: Button 4 + icon: mdi:gesture-tap-box internal: true platform: template on_press: @@ -64,12 +68,26 @@ binary_sensor: - id: bs_swipe_left name: Swipe left - internal: false + icon: mdi:gesture-swipe-left + internal: true platform: template - id: bs_swipe_right name: Swipe right - internal: false + icon: mdi:gesture-swipe-right + internal: true + platform: template + + - id: bs_swipe_up + name: Swipe up + icon: mdi:gesture-swipe-up + internal: true + platform: template + + - id: bs_swipe_down + name: Swipe down + icon: mdi:gesture-swipe-down + internal: true platform: template # bluetooth_proxy: @@ -91,6 +109,8 @@ button: captive_portal: +debug: + esp32: board: esp32dev framework: @@ -115,15 +135,60 @@ esphome: build_flags: - -DCONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=true # - -DCONFIG_BT_BLE_DYNAMIC_ENV_MEMORY=true - - -DCONFIG_ESP32_REV_MIN_3=true - - -DCONFIG_MBEDTLS_DYNAMIC_BUFFER=true - - -DCONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT=true - - -DCONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=true - - -DCONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=true - - -DCONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY=true - - -DCONFIG_SPIRAM_RODATA=true - - -DCONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=true - on_boot: + - -DCONFIG_ESP32_REV_MIN_3 + - -DCONFIG_MBEDTLS_DYNAMIC_BUFFER + - -DCONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT + - -DCONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA + - -DCONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC + - -DCONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY + - -DCONFIG_SPIRAM_RODATA + - -DCONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP + - -DCONFIG_SPIRAM_USE + # - -DCONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL + - -DCONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY + - -DCONFIG_SPIRAM_ALLOW_NOINIT_SEG_EXTERNAL_MEMORY + - -DCONFIG_SPIRAM_CACHE_LIBCHAR_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBENV_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBFILE_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBIO_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBJMP_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBMATH_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBMEM_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBMISC_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBNUMPARSER_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBRAND_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBSTR_IN_IRAM + - -DCONFIG_SPIRAM_CACHE_LIBTIME_IN_IRAM + + on_boot: + - priority: 701 + then: + - wait_until: + condition: + - lambda: return sl_tx_model_format->active_index().has_value(); + - lambda: |- + auto index = sl_tx_model_format->active_index(); + if (index.has_value()) { + uint8_t idx = index.value(); + bs_swipe_down->set_internal(idx == 0); + bs_swipe_left->set_internal(idx == 1); + bs_swipe_right->set_internal(idx == 1); + bs_swipe_up->set_internal(idx == 0); + light_28->set_internal(idx == 0); + light_29->set_internal(idx == 0); + light_30->set_internal(idx == 0); + light_31->set_internal(idx == 0); + light_eu_bottom->set_internal(idx == 1); + light_eu_left->set_internal(idx == 1); + light_eu_right->set_internal(idx == 1); + light_eu_top->set_internal(idx == 1); + light_us_bottom->set_internal(idx == 0); + light_us_left->set_internal(idx == 0); + light_us_right->set_internal(idx == 0); + light_us_top->set_internal(idx == 0); + sl_relay_light_mode_eu->set_internal(idx == 1); + sl_relay_light_mode_us->set_internal(idx == 0); + } - priority: 700 then: - wait_until: @@ -148,6 +213,56 @@ esphome: bs_swipe_left->publish_state(false); bs_swipe_right->publish_state(false); } + - priority: 699 + 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: |- + auto model_format = sl_tx_model_format->active_index(); + auto model_gang = sl_tx_model_gang->active_index(); + if (model_format.has_value() and model_gang.has_value()) { + bool us_model = (model_gang.value() == 1); + switch (model_gang.value() + 1) { + 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: |- @@ -162,6 +277,14 @@ external_components: components: - tx_ultimate_easy +globals: + - id: gb_lights_1 + type: std::vector + restore_value: false + - id: gb_lights_2 + type: std::vector + restore_value: false + i2s_audio: id: if_i2s_audio i2s_bclk_pin: GPIO2 @@ -170,6 +293,7 @@ i2s_audio: light: - id: light_full name: Light - All + internal: true platform: neopixelbus type: GRB variant: WS2811 @@ -177,8 +301,66 @@ light: # rgb_order: GRB # rmt_channel: 0 # chipset: ws2812 - num_leds: 28 + num_leds: 32 pin: GPIO13 + + - id: light_eu + name: Light + internal: true + platform: partition + segments: + - id: light_full + from: 0 + to: 28 + effects: + - 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 + segments: + - id: light_full + from: 0 + to: 31 effects: - addressable_rainbow: - addressable_rainbow: @@ -221,8 +403,9 @@ light: intensity: 5% - random: - - id: light_bottom + - id: light_eu_bottom name: Light - Bottom + internal: true disabled_by_default: true platform: partition segments: @@ -271,8 +454,9 @@ light: update_interval: 16ms intensity: 5% - random: - - id: light_left + - id: light_eu_left name: Light - Left + internal: true disabled_by_default: true platform: partition segments: @@ -321,8 +505,9 @@ light: update_interval: 16ms intensity: 5% - random: - - id: light_right + - id: light_eu_right name: Light - Right + internal: true disabled_by_default: true platform: partition segments: @@ -375,8 +560,9 @@ light: update_interval: 16ms intensity: 5% - random: - - id: light_top + - id: light_eu_top name: Light - Top + internal: true disabled_by_default: true platform: partition segments: @@ -425,6 +611,214 @@ light: update_interval: 16ms intensity: 5% - random: + - id: light_us_bottom + name: Light - Bottom + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 10 + to: 15 + reversed: true + effects: + - 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_left + name: Light - Left + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 15 + to: 24 + reversed: true + effects: + - 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_right + name: Light - Right + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 31 + to: 31 + reversed: false + - id: light_full + from: 0 + to: 8 + reversed: false + effects: + - 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_top + name: Light - Top + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 25 + to: 30 + reversed: false + effects: + - 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_00 name: Light - LED 00 @@ -650,8 +1044,44 @@ light: - id: light_full from: 27 to: 27 + - id: light_28 + name: Light - LED 28 + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 28 + to: 28 + - id: light_29 + name: Light - LED 29 + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 29 + to: 29 + - id: light_30 + name: Light - LED 30 + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 30 + to: 30 + - id: light_31 + name: Light - LED 31 + internal: true + disabled_by_default: true + platform: partition + segments: + - id: light_full + from: 31 + to: 31 - - id: light_rl_1_1_bottom + - id: light_eu_rl_1_1_bottom name: Light - Relay 1 of 1 (bottom) internal: true platform: partition @@ -659,7 +1089,7 @@ light: - id: light_full from: 9 to: 9 - - id: light_rl_1_1_top + - id: light_eu_rl_1_1_top name: Light - Relay 1 of 1 (top) internal: true platform: partition @@ -667,7 +1097,7 @@ light: - id: light_full from: 23 to: 23 - - id: light_rl_1_2_bottom + - id: light_eu_rl_1_2_bottom name: Light - Relay 1 of 2 (bottom) internal: true platform: partition @@ -675,7 +1105,7 @@ light: - id: light_full from: 11 to: 11 - - id: light_rl_1_2_top + - id: light_eu_rl_1_2_top name: Light - Relay 1 of 2 (top) internal: true platform: partition @@ -683,7 +1113,7 @@ light: - id: light_full from: 21 to: 21 - - id: light_rl_2_2_bottom + - id: light_eu_rl_2_2_bottom name: Light - Relay 2 of 2 (bottom) internal: true platform: partition @@ -691,7 +1121,7 @@ light: - id: light_full from: 7 to: 7 - - id: light_rl_2_2_top + - id: light_eu_rl_2_2_top name: Light - Relay 2 of 2 (top) internal: true platform: partition @@ -699,7 +1129,7 @@ light: - id: light_full from: 25 to: 25 - - id: light_rl_1_3_bottom + - id: light_eu_rl_1_3_bottom name: Light - Relay 1 of 3 (bottom) internal: true platform: partition @@ -707,7 +1137,7 @@ light: - id: light_full from: 11 to: 11 - - id: light_rl_1_3_top + - id: light_eu_rl_1_3_top name: Light - Relay 1 of 3 (top) internal: true platform: partition @@ -715,7 +1145,7 @@ light: - id: light_full from: 21 to: 21 - - id: light_rl_2_3_bottom + - id: light_eu_rl_2_3_bottom name: Light - Relay 2 of 3 (bottom) internal: true platform: partition @@ -723,7 +1153,7 @@ light: - id: light_full from: 9 to: 9 - - id: light_rl_2_3_top + - id: light_eu_rl_2_3_top name: Light - Relay 2 of 3 (top) internal: true platform: partition @@ -731,7 +1161,7 @@ light: - id: light_full from: 23 to: 23 - - id: light_rl_3_3_bottom + - id: light_eu_rl_3_3_bottom name: Light - Relay 3 of 3 (bottom) internal: true platform: partition @@ -739,7 +1169,7 @@ light: - id: light_full from: 7 to: 7 - - id: light_rl_3_3_top + - id: light_eu_rl_3_3_top name: Light - Relay 3 of 3 (top) internal: true platform: partition @@ -747,7 +1177,7 @@ light: - id: light_full from: 25 to: 25 - - id: light_rl_1_4_bottom + - id: light_eu_rl_1_4_bottom name: Light - Relay 1 of 4 (bottom) internal: true platform: partition @@ -755,7 +1185,7 @@ light: - id: light_full from: 12 to: 12 - - id: light_rl_1_4_top + - id: light_eu_rl_1_4_top name: Light - Relay 1 of 4 (top) internal: true platform: partition @@ -763,7 +1193,7 @@ light: - id: light_full from: 20 to: 20 - - id: light_rl_2_4_bottom + - id: light_eu_rl_2_4_bottom name: Light - Relay 2 of 4 (bottom) internal: true platform: partition @@ -771,7 +1201,7 @@ light: - id: light_full from: 10 to: 10 - - id: light_rl_2_4_top + - id: light_eu_rl_2_4_top name: Light - Relay 2 of 4 (top) internal: true platform: partition @@ -779,7 +1209,7 @@ light: - id: light_full from: 22 to: 22 - - id: light_rl_3_4_bottom + - id: light_eu_rl_3_4_bottom name: Light - Relay 3 of 4 (bottom) internal: true platform: partition @@ -787,7 +1217,7 @@ light: - id: light_full from: 8 to: 8 - - id: light_rl_3_4_top + - id: light_eu_rl_3_4_top name: Light - Relay 3 of 4 (top) internal: true platform: partition @@ -795,7 +1225,7 @@ light: - id: light_full from: 24 to: 24 - - id: light_rl_4_4_bottom + - id: light_eu_rl_4_4_bottom name: Light - Relay 4 of 4 (bottom) internal: true platform: partition @@ -803,7 +1233,7 @@ light: - id: light_full from: 6 to: 6 - - id: light_rl_4_4_top + - id: light_eu_rl_4_4_top name: Light - Relay 4 of 4 (top) internal: true platform: partition @@ -811,6 +1241,172 @@ light: - 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + 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 + segments: + - id: light_full + from: 7 + to: 7 # - id: light_status # name: Light - Status @@ -845,6 +1441,7 @@ number: unit_of_measurement: ms # mode: box internal: false + entity_category: config platform: template min_value: 1 max_value: 500 @@ -862,139 +1459,28 @@ script: mode: restart then: - lambda: |- - auto model_index = sl_tx_model_gang->active_index(); - auto light_index = sl_relay_light_mode->active_index(); - if (model_index.has_value() and light_index.has_value() and light_index.value() > 0) { - uint8_t model_idx = model_index.value() + 1; - switch (model_idx) { - case 1: // 1 Gang - if (light_index == 1 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_1_bottom->turn_on().perform(); - else - light_rl_1_1_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_1_top->turn_on().perform(); - else - light_rl_1_1_top->turn_off().perform(); - } - break; - case 2: // 2 Gang - if (light_index == 1 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_2_bottom->turn_on().perform(); - else - light_rl_1_2_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_2_top->turn_on().perform(); - else - light_rl_1_2_top->turn_off().perform(); - } - if (light_index == 1 or light_index == 3) { - if (sw_relay_2->state) - light_rl_2_2_bottom->turn_on().perform(); - else - light_rl_2_2_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_2->state) - light_rl_2_2_top->turn_on().perform(); - else - light_rl_2_2_top->turn_off().perform(); - } - break; - case 3: // 3 Gang - if (light_index == 1 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_3_bottom->turn_on().perform(); - else - light_rl_1_3_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_3_top->turn_on().perform(); - else - light_rl_1_3_top->turn_off().perform(); - } - if (light_index == 1 or light_index == 3) { - if (sw_relay_2->state) - light_rl_2_3_bottom->turn_on().perform(); - else - light_rl_2_3_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_2->state) - light_rl_2_3_top->turn_on().perform(); - else - light_rl_2_3_top->turn_off().perform(); - } - if (light_index == 1 or light_index == 3) { - if (sw_relay_3->state) - light_rl_3_3_bottom->turn_on().perform(); - else - light_rl_3_3_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_3->state) - light_rl_3_3_top->turn_on().perform(); - else - light_rl_3_3_top->turn_off().perform(); - } - break; - case 4: // 4 Gang - if (light_index == 1 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_4_bottom->turn_on().perform(); - else - light_rl_1_4_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_1->state) - light_rl_1_4_top->turn_on().perform(); - else - light_rl_1_4_top->turn_off().perform(); - } - if (light_index == 1 or light_index == 3) { - if (sw_relay_2->state) - light_rl_2_4_bottom->turn_on().perform(); - else - light_rl_2_4_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_2->state) - light_rl_2_4_top->turn_on().perform(); - else - light_rl_2_4_top->turn_off().perform(); - } - if (light_index == 1 or light_index == 3) { - if (sw_relay_3->state) - light_rl_3_4_bottom->turn_on().perform(); - else - light_rl_3_4_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_3->state) - light_rl_3_4_top->turn_on().perform(); - else - light_rl_3_4_top->turn_off().perform(); - } - if (light_index == 1 or light_index == 3) { - if (sw_relay_4->state) - light_rl_4_4_bottom->turn_on().perform(); - else - light_rl_4_4_bottom->turn_off().perform(); - } - if (light_index == 2 or light_index == 3) { - if (sw_relay_4->state) - light_rl_4_4_top->turn_on().perform(); - else - light_rl_4_4_top->turn_off().perform(); - } - break; + 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 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(); + } } } @@ -1006,7 +1492,7 @@ script: - switch.turn_off: sw_vibration_motor select: - - id: sl_relay_light_mode + - id: sl_relay_light_mode_eu name: Relay light mode platform: template options: @@ -1017,7 +1503,23 @@ select: initial_option: "Bottom" optimistic: true restore_value: true - internal: false + internal: true + entity_category: config + disabled_by_default: false + icon: mdi:dots-square + + - 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 @@ -1038,8 +1540,22 @@ select: 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 + name: Model (Gang) platform: template options: - "1 Gang" @@ -1055,6 +1571,16 @@ select: icon: mdi:dip-switch sensor: + - platform: debug + free: + name: "Heap Free" + block: + name: "Heap Max Block" + loop_time: + name: "Loop Time" + psram: + name: "Free PSRAM" + - id: sun_elevation name: Sun Elevation platform: sun @@ -1083,8 +1609,8 @@ sun: longitude: ${longitude} switch: - - id: sw_speaker_aplifier - name: Speaker - Aplifier + - id: sw_speaker_amplifier + name: Speaker - Amplifier platform: gpio pin: number: GPIO26 @@ -1092,6 +1618,7 @@ switch: allow_other_uses: true restore_mode: RESTORE_DEFAULT_ON internal: true + entity_category: config - id: sw_relay_1 name: Relay 1 @@ -1099,6 +1626,12 @@ switch: pin: GPIO18 restore_mode: RESTORE_DEFAULT_OFF internal: false + 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 @@ -1106,6 +1639,12 @@ switch: pin: GPIO17 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 @@ -1113,6 +1652,12 @@ switch: pin: GPIO27 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 @@ -1120,6 +1665,12 @@ switch: pin: GPIO23 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 @@ -1129,6 +1680,7 @@ switch: inverted: true restore_mode: ALWAYS_ON internal: false + entity_category: config - id: sw_vibration_motor name: Vibration motor