I am new to ESP home before used Tasmota but since it not support local automatization i need to switch to ESPhome.
I am trying to achieve the following in this section:
IF “GA_Kazan_Relay_4” is ON “GA_Kazan_Relay_1” should not turn ON
“GA_Kazan_Relay_1” only can turned ON if at least “GA_Kazan_Relay_2” or “GA_Kazan_Relay_3” is ON
switch:
# GAS furnes
- platform: gpio
pin: GPIO2
inverted: true
name: "GA_Kazan_Relay_1"
id: "GA_Kazan_Relay_1"
on_turn_on:
- if: #R1: if [4] is ON [1] must be OFF
condition:
switch.is_on: GA_Kazan_Relay_4
then:
switch.turn_off: GA_Kazan_Relay_1
- if: #R3: [1] is only can turned ON if at least [2] or [3] is ON
condition:
switch.is_of: GA_Kazan_Relay_2
switch.is_of: GA_Kazan_Relay_3
then:
switch.turn_off: GA_Kazan_Relay_1
If i only has one if statement there is no error:
switch:
# GAS furnes
- platform: gpio
pin: GPIO2
inverted: true
name: "GA_Kazan_Relay_1"
id: "GA_Kazan_Relay_1"
on_turn_on:
if: #R1: if [4] is ON [1] must be OFF
condition:
switch.is_on: GA_Kazan_Relay_4
then:
switch.turn_off: GA_Kazan_Relay_1
Seems that indenting is wrong for the ‘then’ parts.
Also the second ‘if’ depends on 2 conditions, use an ‘or’ and check for ‘is_off’ instead of ‘is_of’.
Try this:
switch:
# GAS furnes
- platform: gpio
pin: GPIO2
inverted: true
name: "GA_Kazan_Relay_1"
id: "GA_Kazan_Relay_1"
on_turn_on:
- if: #R1: if [4] is ON [1] must be OFF
condition:
switch.is_on: GA_Kazan_Relay_4
then:
switch.turn_off: GA_Kazan_Relay_1
- if: #R3: [1] is only can turned ON if at least [2] or [3] is ON
condition:
or:
- switch.is_off: GA_Kazan_Relay_2
- switch.is_off: GA_Kazan_Relay_3
then:
switch.turn_off: GA_Kazan_Relay_1
I only needed to change the or to and statement. It is doing what i want to do so that is god. To only problem is the status is not updated in homeasistant correctly .
In during turn_on i switching off the switch but in the GUI it show as turned on.
I am trying to update manually the status with: - lambda: "id(GA_Kazan_Relay_1).publish_state(false);"
but that just make thing worse leading to crash ESPHOME.
# GAS furnes
- platform: gpio
pin: GPIO2
inverted: true
name: "GA_Kazan_Relay_1"
id: "GA_Kazan_Relay_1"
on_turn_on:
- if: #R1: if [4] is ON [1] must be OFF
condition:
switch.is_on: GA_Kazan_Relay_4
then:
- switch.turn_off: GA_Kazan_Relay_1
- lambda: "id(GA_Kazan_Relay_1).publish_state(false);"
- if: #R3: [1] is only can turned ON if at least [2] or [3] is ON
condition:
and:
- switch.is_off: GA_Kazan_Relay_2
- switch.is_off: GA_Kazan_Relay_3
then:
- switch.turn_off: GA_Kazan_Relay_1
- lambda: "id(GA_Kazan_Relay_1).publish_state(false);"