CodeRabbitAI suggestions
This commit is contained in:
@@ -121,6 +121,32 @@ binary_sensor:
|
||||
event: long_click
|
||||
|
||||
script:
|
||||
- id: !extend boot_initialize
|
||||
then:
|
||||
- script.execute: boot_initialize_buttons
|
||||
|
||||
- id: boot_initialize_buttons
|
||||
mode: restart
|
||||
then:
|
||||
- wait_until:
|
||||
condition:
|
||||
- lambda: return sl_tx_model_gang->active_index().has_value();
|
||||
- lambda: |-
|
||||
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);
|
||||
|
||||
- id: button_action
|
||||
mode: parallel
|
||||
parameters:
|
||||
@@ -133,34 +159,15 @@ script:
|
||||
- id: buttons_release
|
||||
mode: restart
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: bs_button_1
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_button_1
|
||||
state: OFF # yamllint disable-line rule:truthy
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: bs_button_2
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_button_2
|
||||
state: OFF # yamllint disable-line rule:truthy
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: bs_button_3
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_button_3
|
||||
state: OFF # yamllint disable-line rule:truthy
|
||||
- if:
|
||||
condition:
|
||||
binary_sensor.is_on: bs_button_4
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_button_4
|
||||
state: OFF # yamllint disable-line rule:truthy
|
||||
- lambda: |-
|
||||
std::vector<binary_sensor::BinarySensor*> buttons = {
|
||||
bs_button_1, bs_button_2, bs_button_3, bs_button_4
|
||||
};
|
||||
for (auto* button : buttons) {
|
||||
if (button->state) {
|
||||
button->publish_state(false);
|
||||
}
|
||||
}
|
||||
|
||||
- id: !extend touch_on_multi_touch_release
|
||||
then:
|
||||
|
||||
Reference in New Issue
Block a user