Clean up general entities & fallback

Store inputs into variables only when needed.
Removed fallback mode - Replaced by ESPHome local control when the relay is assigned to the button in the blueprint.
This commit is contained in:
Edward Firmo
2023-08-27 10:50:38 +02:00
parent 46a4b6929e
commit 0f49eb2f8c
2 changed files with 67 additions and 123 deletions

View File

@@ -727,12 +727,7 @@ binary_sensor:
then:
- if:
condition:
or:
- switch.is_on: relay1_local
- and:
- switch.is_on: relay1_fallback
- not:
api.connected:
- switch.is_on: relay1_local
then:
- switch.toggle: relay_1
- script.execute:
@@ -749,12 +744,7 @@ binary_sensor:
then:
- if:
condition:
or:
- switch.is_on: relay2_local
- and:
- switch.is_on: relay2_fallback
- not:
api.connected:
- switch.is_on: relay2_local
then:
- switch.toggle: relay_2
- script.execute:
@@ -1193,20 +1183,6 @@ switch:
on_turn_off:
- logger.log: "Relay 2 Local turned Off!"
##### Relay Local control Fallback #####
- name: ${device_name} Relay 1 Local Fallback
platform: template
id: relay1_fallback
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
- name: ${device_name} Relay 2 Local Fallback
platform: template
id: relay2_fallback
entity_category: config
optimistic: true
restore_mode: RESTORE_DEFAULT_OFF
##### START - NUMBER CONFIGURATION #####
number:
@@ -1462,8 +1438,8 @@ script:
if (id(relay_2).state) id(disp1).set_component_text_printf("home.icon_top_02", "%s", id(home_relay2_icon).c_str());
else id(disp1).set_component_text_printf("home.icon_top_02", "\uFFFF");
// Hardware buttons - Fallback mode
if (id(relay_1).state and (id(relay1_local).state or (id(relay1_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.left_bt_pic.pic=%i", (id(relay_1).state) ? 78 : 77);
if (id(relay_2).state and (id(relay2_local).state or (id(relay2_fallback).state and not id(api_status).state))) id(disp1).send_command_printf("home.right_bt_pic.pic=%i", (id(relay_2).state) ? 78 : 77);
if (id(relay_1).state and id(relay1_local).state) id(disp1).send_command_printf("home.left_bt_pic.pic=%i", (id(relay_1).state) ? 78 : 77);
if (id(relay_2).state and id(relay2_local).state) id(disp1).send_command_printf("home.right_bt_pic.pic=%i", (id(relay_2).state) ? 78 : 77);
ESP_LOGV("script.refresh_relays", "Finished");
- id: refresh_wifi_icon