I have two contact sensors, one detecting when a door has been opened, and another when a handle has been raised.
When the handle is raised, and the door is closed, it engages the doors deadlocks.
I’d like a binary sensor to show whether or not the deadlocks are engaged.
The logic I need is as follows:-
If the door is opened at any time, deadlocks are false (disengaged)
If the handle is raised whilst the door is closed, then the deadlocks are engaged.
The state of the handle should be ignored whilst the door is open.
I can do this with an automation and an input boolean helper, but wondered whether or not this is doable with a template sensor ?
The handle is only raised momentarily to engage the deadlock, so to get the deadlock into a ‘true’ state, the above works fine, but once deadlocks are true, the handle could be lowered. Only the door opening can change the deadlock state to false.
My pseudo code:-
if deadlocks are false and handle is raised and door is shut then deadlocks are true.
if door is opened then deadlocks are false.
I’ve always stayed way from trigger based templates, preferring automations, because they basically look very similar, but I thought I would use this as an exercise to learn a bit more about them.
Yeah, they are similar. Before they existed, you’d be using an automation to manipulate an input_boolean to do this job, but they make it much cleaner.