Hi all,
I’m working on a sprinkler project controlled by HA.
The ESP Device Listens to the topic
home/Sprinkler/Valve/set
and publishes the status to
home/Sprinkler/Valve
So I have four switches to call the valves. Putting a number from 1 to 4 to the set-topic the appropiate valve is opened. The ESP sets all the other valves to close. This is because there’s only waterpressure for one valve at a time.
By sending an 0 all valves are closed.
So getting the status of 3 all the switches for 1, 2 and 4 should go to “Off”, but they are only “Off”, when getting the “0”.
Can anybody help me with this, so that the switches get the OFF-state, when receiving another value than their own On-value?
Here’s the configuration of the switches:
switch:
- platform: mqtt
name: “Valve1”
state_topic: “home/Sprinkler/Valve”
command_topic: “home/Sprinkler/Valve/set”
payload_on: ‘1’
payload_off: ‘0’
state_template: >-
{% if value != “1” %}
“0”
{% else %}
“1”
{% endif %}
optimistic: false
qos: 0
retain: true - platform: mqtt
name: “Valve2”
state_topic: “home/Sprinkler/Valve”
command_topic: “home/Sprinkler/Valve/set”
payload_on: ‘2’
payload_off: ‘0’
state_template: >-
{% if value != “2” %}
“0”
{% else %}
“2”
{% endif %}
optimistic: false
qos: 0
retain: true - platform: mqtt
name: “Valve3”
state_topic: “home/Sprinkler/Valve”
command_topic: “home/Sprinkler/Valve/set”
payload_on: ‘3’
payload_off: ‘0’
state_template: >-
{% if value != “3” %}
“0”
{% else %}
“3”
{% endif %}
optimistic: false
qos: 0
retain: true - platform: mqtt
name: “Valve4”
state_topic: “home/Sprinkler/Valve”
command_topic: “home/Sprinkler/Valve/set”
payload_on: ‘4’
payload_off: ‘0’
state_template: >-
{% if value != “4” %}
“0”
{% else %}
“4”
{% endif %}
optimistic: false
qos: 0
retain: true
Thanks in advance!
Mario