Fallback even when button is assigned to another entity

Solves https://github.com/Blackymas/NSPanel_HA_Blueprint/issues/1013#issuecomment-1720107844
This commit is contained in:
Edward Firmo
2023-09-15 21:17:23 +02:00
parent 59b5687420
commit d4f9926079
3 changed files with 61 additions and 3 deletions

View File

@@ -416,9 +416,11 @@ api:
relay1_local_control: bool
relay1_icon: string
relay1_icon_color: int
relay1_fallback: bool
relay2_local_control: bool
relay2_icon: string
relay2_icon_color: int
relay2_fallback: bool
date_color: int
time_format: string
time_color: int
@@ -434,9 +436,11 @@ api:
ESP_LOGV("service.global_settings", "relay1_local_control: %i", (relay1_local_control) ? 1 : 0);
ESP_LOGV("service.global_settings", "relay1_icon: %s", relay1_icon.c_str());
ESP_LOGV("service.global_settings", "relay1_icon_color: %i", relay1_icon_color);
ESP_LOGD("service.global_settings", "relay1_fallback: %i", (relay1_fallback) ? 1 : 0);
ESP_LOGV("service.global_settings", "relay2_local_control: %i", (relay2_local_control) ? 1 : 0);
ESP_LOGV("service.global_settings", "relay2_icon: %s", relay2_icon.c_str());
ESP_LOGV("service.global_settings", "relay2_icon_color: %i", relay2_icon_color);
ESP_LOGD("service.global_settings", "relay2_fallback: %i", (relay2_fallback) ? 1 : 0);
ESP_LOGV("service.global_settings", "date_color: %i", date_color);
ESP_LOGV("service.global_settings", "time_format: %s", time_format.c_str());
ESP_LOGV("service.global_settings", "time_color: %i", time_color);
@@ -456,6 +460,8 @@ api:
id(home_relay2_icon) = relay2_icon.c_str();
id(home_relay1_icon_color) = relay1_icon_color;
id(home_relay2_icon_color) = relay2_icon_color;
id(relay_1_fallback) = relay1_fallback;
id(relay_2_fallback) = relay2_fallback;
// Localization
id(mui_time_format) = time_format;
@@ -854,6 +860,16 @@ api:
##### START - GLOBALS CONFIGURATION #####
globals:
###### Relay fallback even when buttons have other entities? ######
- id: relay_1_fallback
type: bool
restore_value: true
initial_value: 'false'
- id: relay_2_fallback
type: bool
restore_value: true
initial_value: 'false'
##### Display mode (1 = EU, 2 = US, 3 = US Landscape)
- id: display_mode
type: int
@@ -988,7 +1004,15 @@ binary_sensor:
- logger.log: "Left button - Short click"
- if:
condition:
- switch.is_on: relay1_local
or:
- switch.is_on: relay1_local
- and:
- lambda: !lambda return id(relay_1_fallback);
- or:
- not:
- api.connected:
- not:
- wifi.connected:
then:
- switch.toggle: relay_1
- script.execute: refresh_relays
@@ -1019,7 +1043,15 @@ binary_sensor:
- logger.log: "Right button - Short click"
- if:
condition:
- switch.is_on: relay2_local
or:
- switch.is_on: relay2_local
- and:
- lambda: !lambda return id(relay_2_fallback);
- or:
- not:
- api.connected:
- not:
- wifi.connected:
then:
- switch.toggle: relay_2
- script.execute: refresh_relays