I can sort of see that the following is a bad idea, but I can’t see why it doesn’t work. Each element works on its own, but the two combined do not.
I have two door sensors on my garage door. One for when it’s open(ed) and the other for when it’s closed. By having two (the closed one has a replaced relay from NC to NO). I can ensure that it’s closed and not that it’s simply “not open” (IYSWIM). So, I created a pair of trigger template sensors each pointing at the same binary sensor. Each works fine in isolation, but as soon as there are two present, the sensor won’t change.
# Trigger Binary Sensors for Garage Door status
# First is trigger for closed
- trigger:
- platform: state
entity_id: binary_sensor.10006f1d21_1
from: "off"
to: "on"
binary_sensor:
- name: "Garage Door Status"
unique_id: garage_door_status
device_class: garage_door
state: "off"
# Next is trigger for open
- trigger:
- platform: state
entity_id: binary_sensor.10006f1d21_4
from: "off"
to: "on"
binary_sensor:
- name: "Garage Door Status"
unique_id: garage_door_status
device_class: garage_door
state: "on"
I could just change this to an automation, I suppose, but I understood that using trigger templates were preferred these days?
May I ask why my version didn’t work? I fully understand that it’s much more long-winded, but that doesn’t explain why it simply didn’t work. Both elements were correct, as far as I could test, but they simply didn’t work in concert.
Is a trigger really needed? If you create a simpler template sensor it will always (and only) be calculated when one of the sensors changes it states, no?
I’m editing directly here at the forum and couldn’t test this, but I’m pretty sure it will give the results you want (if I didn’t mixed the sensor states).
I have hit a snag in that when the sensors trigger, they stay in the “on” state for quite some time. Thus, it’s possible to open the door and then close it again and the “open” sensor still shows as “on”. This compromises the recording of closure (and presumably vice versa)
Is the duration of the trigger configurable in any way? I assume it’s a HA setting rather than the source (Sonoff) device.