Hi,
I have 2 switches that are tied to 2 device trackers and when the switch is turned on or off then he must do a MQTT publish.
When the switches aren’t tied to the device trackers and I switch the manualy everytings work.
When the switches are tied to the device trackers then the MQTT publish isn’t triggerd.
Below you can find my code
switch:
- platform: template
switches:
lucie_switch:
friendly_name: "Lucie thuis"
value_template: "{{ is_state('device_tracker.gsm_lucie', 'home') }}"
turn_on:
service: mqtt.publish
data:
topic: domoticz/ha
payload: >-
{"command":"switchlight",
"idx": 387,
"switchcmd": "On"
}
turn_off:
service: mqtt.publish
data:
topic: domoticz/ha
payload: >-
{"command": "switchlight",
"idx": 387,
"switchcmd": "Off"
}
- platform: template
switches:
koen_switch:
friendly_name: "Koen thuis"
value_template: "{{ is_state('device_tracker.gsm_koen', 'home') }}"
turn_on:
service: mqtt.publish
data:
topic: domoticz/ha
payload: >-
{"command": "switchlight",
"idx": 382,
"switchcmd": "On"
}
turn_off:
service: mqtt.publish
data:
topic: domoticz/ha
payload: >-
{"command": "switchlight",
"idx": 382,
"switchcmd": "Off"
}