@@ -129,7 +129,6 @@ select:
|
|||||||
disabled_by_default: false
|
disabled_by_default: false
|
||||||
icon: mdi:dip-switch
|
icon: mdi:dip-switch
|
||||||
|
|
||||||
|
|
||||||
sensor:
|
sensor:
|
||||||
- id: sun_elevation
|
- id: sun_elevation
|
||||||
name: Sun Elevation
|
name: Sun Elevation
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ script:
|
|||||||
const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ?
|
const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ?
|
||||||
(sl_tx_model_gang->active_index().value() + 1) : 0;
|
(sl_tx_model_gang->active_index().value() + 1) : 0;
|
||||||
if (num_gangs < 1 || num_gangs > 4) {
|
if (num_gangs < 1 || num_gangs > 4) {
|
||||||
ESP_LOGE("hw_buttons", "Invalid number of gangs: %" PRIu8, num_gangs);
|
ESP_LOGE("core_hw_buttons", "Invalid number of gangs: %" PRIu8, num_gangs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bs_button_1->publish_state(false);
|
bs_button_1->publish_state(false);
|
||||||
|
|||||||
@@ -761,7 +761,7 @@ script:
|
|||||||
const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ?
|
const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ?
|
||||||
(sl_tx_model_gang->active_index().value() + 1) : 0;
|
(sl_tx_model_gang->active_index().value() + 1) : 0;
|
||||||
if (num_gangs < 1 || num_gangs > 4) {
|
if (num_gangs < 1 || num_gangs > 4) {
|
||||||
ESP_LOGE("hw_leds", "Invalid number of gangs: %" PRIu8, num_gangs);
|
ESP_LOGE("core_hw_leds", "Invalid number of gangs: %" PRIu8, num_gangs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
light_28->set_internal(!is_model_us);
|
light_28->set_internal(!is_model_us);
|
||||||
|
|||||||
@@ -60,6 +60,12 @@ binary_sensor:
|
|||||||
!bs_swipe_right->state)
|
!bs_swipe_right->state)
|
||||||
sw_relay_4->toggle();
|
sw_relay_4->toggle();
|
||||||
|
|
||||||
|
globals:
|
||||||
|
- id: boot_initialization_relays
|
||||||
|
type: bool
|
||||||
|
restore_value: false
|
||||||
|
initial_value: 'false'
|
||||||
|
|
||||||
output:
|
output:
|
||||||
- id: output_relay_1
|
- id: output_relay_1
|
||||||
platform: gpio
|
platform: gpio
|
||||||
@@ -95,7 +101,7 @@ script:
|
|||||||
const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ?
|
const uint8_t num_gangs = (sl_tx_model_gang->active_index().has_value()) ?
|
||||||
(sl_tx_model_gang->active_index().value() + 1) : 0;
|
(sl_tx_model_gang->active_index().value() + 1) : 0;
|
||||||
if (num_gangs < 1 || num_gangs > 4) {
|
if (num_gangs < 1 || num_gangs > 4) {
|
||||||
ESP_LOGE("hw_relays", "Invalid number of gangs: %" PRIu8, num_gangs);
|
ESP_LOGE("core_hw_relays", "Invalid number of gangs: %" PRIu8, num_gangs);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sl_relay_1_mode->set_internal(num_gangs < 1);
|
sl_relay_1_mode->set_internal(num_gangs < 1);
|
||||||
@@ -130,13 +136,22 @@ script:
|
|||||||
light_output_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 1);
|
light_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);
|
sw_relay_4->set_internal(num_gangs < 4 or relay_mode_index.value() != 0);
|
||||||
}
|
}
|
||||||
|
id(boot_initialization_relays) = true;
|
||||||
|
|
||||||
- id: show_relay_status
|
- id: show_relay_status
|
||||||
mode: restart
|
mode: restart
|
||||||
then:
|
then:
|
||||||
|
- script.wait: boot_initialize_relays
|
||||||
|
- wait_until:
|
||||||
|
condition:
|
||||||
|
- lambda: return sl_tx_model_format->active_index().has_value();
|
||||||
|
- lambda: return id(boot_initialization_relays);
|
||||||
- lambda: |-
|
- lambda: |-
|
||||||
auto model_format = sl_tx_model_format->active_index();
|
auto model_format = sl_tx_model_format->active_index();
|
||||||
if (!model_format.has_value()) return; // Early return if no model format
|
if (!model_format.has_value()) {
|
||||||
|
ESP_LOGE("core_hw_relays", "Model (Format) not defined");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<esphome::select::Select*> relay_modes;
|
std::vector<esphome::select::Select*> relay_modes;
|
||||||
const bool is_eu_model = model_format.value() == 0;
|
const bool is_eu_model = model_format.value() == 0;
|
||||||
@@ -153,8 +168,16 @@ script:
|
|||||||
// Get switch states
|
// Get switch states
|
||||||
const std::vector<switch_::Switch*> switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4};
|
const std::vector<switch_::Switch*> switches = {sw_relay_1, sw_relay_2, sw_relay_3, sw_relay_4};
|
||||||
|
|
||||||
|
// Check if light vectors are initialized
|
||||||
|
if (id(gb_lights_1).empty() || id(gb_lights_2).empty()) {
|
||||||
|
ESP_LOGE("core_hw_relays", "Light vector not initialized");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Update lights based on relay states
|
// Update lights based on relay states
|
||||||
for (size_t i = 0; i < relay_modes.size(); ++i) {
|
for (size_t i = 0; i < relay_modes.size() && i < id(gb_lights_1).size(); ++i) {
|
||||||
|
if (!relay_modes[i] || !switches[i]) continue;
|
||||||
|
|
||||||
auto light_index = relay_modes[i]->active_index();
|
auto light_index = relay_modes[i]->active_index();
|
||||||
if (!light_index.has_value()) continue;
|
if (!light_index.has_value()) continue;
|
||||||
|
|
||||||
@@ -162,7 +185,7 @@ script:
|
|||||||
const bool switch_state = switches[i]->state;
|
const bool switch_state = switches[i]->state;
|
||||||
|
|
||||||
// Update first light group (bottom/left)
|
// Update first light group (bottom/left)
|
||||||
if (light_idx == 1 || light_idx == 3) {
|
if ((light_idx == 1 || light_idx == 3) && i < id(gb_lights_1).size() && id(gb_lights_1)[i]) {
|
||||||
if (switch_state)
|
if (switch_state)
|
||||||
id(gb_lights_1)[i]->turn_on();
|
id(gb_lights_1)[i]->turn_on();
|
||||||
else
|
else
|
||||||
@@ -170,7 +193,7 @@ script:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update second light group (top/right)
|
// Update second light group (top/right)
|
||||||
if (light_idx == 2 || light_idx == 3) {
|
if ((light_idx == 2 || light_idx == 3) && i < id(gb_lights_2).size() && id(gb_lights_2)[i]) {
|
||||||
if (switch_state)
|
if (switch_state)
|
||||||
id(gb_lights_2)[i]->turn_on();
|
id(gb_lights_2)[i]->turn_on();
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -58,7 +58,11 @@ binary_sensor:
|
|||||||
- lambda: send_event_to_ha->execute("swipe", "down");
|
- lambda: send_event_to_ha->execute("swipe", "down");
|
||||||
|
|
||||||
external_components:
|
external_components:
|
||||||
- source: github://edwardtfn/TX-Ultimate-Easy@main
|
- source:
|
||||||
|
type: git
|
||||||
|
url: https://github.com/edwardtfn/TX-Ultimate-Easy
|
||||||
|
ref: ${version}
|
||||||
|
refresh: 1h
|
||||||
components:
|
components:
|
||||||
- tx_ultimate_easy
|
- tx_ultimate_easy
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user