Reorg boot sequence
This commit is contained in:
@@ -187,135 +187,117 @@ esphome:
|
||||
build_flags:
|
||||
- -D TX_ULTIMATE_EASY_CORE
|
||||
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->set_internal(idx == 1);
|
||||
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->set_internal(idx == 0);
|
||||
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:
|
||||
condition:
|
||||
- lambda: return sl_tx_model_gang->active_index().has_value();
|
||||
- lambda: |-
|
||||
auto index = sl_tx_model_gang->active_index();
|
||||
if (index.has_value()) {
|
||||
uint8_t idx = index.value();
|
||||
bs_button_1->set_internal(false);
|
||||
bs_button_2->set_internal(idx < 1);
|
||||
bs_button_3->set_internal(idx < 2);
|
||||
bs_button_4->set_internal(idx < 3);
|
||||
bs_button_1->publish_state(false);
|
||||
bs_button_2->publish_state(false);
|
||||
bs_button_3->publish_state(false);
|
||||
bs_button_4->publish_state(false);
|
||||
bs_multi_touch->publish_state(false);
|
||||
bs_swipe_left->publish_state(false);
|
||||
bs_swipe_right->publish_state(false);
|
||||
sl_button_1_action->set_internal(false);
|
||||
sl_button_2_action->set_internal(idx < 1);
|
||||
sl_button_3_action->set_internal(idx < 2);
|
||||
sl_button_4_action->set_internal(idx < 3);
|
||||
sl_relay_1_mode->set_internal(false);
|
||||
sl_relay_2_mode->set_internal(idx < 1);
|
||||
sl_relay_3_mode->set_internal(idx < 2);
|
||||
sl_relay_4_mode->set_internal(idx < 3);
|
||||
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(idx < 1 or relay_mode_index.value() != 1);
|
||||
sw_relay_2->set_internal(idx < 1 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(idx < 2 or relay_mode_index.value() != 1);
|
||||
sw_relay_3->set_internal(idx < 2 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(idx < 3 or relay_mode_index.value() != 1);
|
||||
sw_relay_4->set_internal(idx < 3 or relay_mode_index.value() != 0);
|
||||
}
|
||||
}
|
||||
- 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;
|
||||
}
|
||||
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()) ? 0 :
|
||||
(sl_tx_model_format->active_index().value() + 1);
|
||||
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: |-
|
||||
@@ -389,7 +371,7 @@ light:
|
||||
- id: light_full
|
||||
from: 0
|
||||
to: 28
|
||||
effects:
|
||||
effects: &effects_standard
|
||||
- addressable_rainbow:
|
||||
- addressable_rainbow:
|
||||
name: "Rainbow - Fast"
|
||||
|
||||
Reference in New Issue
Block a user