Hello, I just got some door contat sensors working with tuya and configured them with tuya local. They works perfectly fine except when they go in deep sleep.
The sensor after sending the status (on/off) goes in deep sleep and becomes unavailable but I need to remember the last state they sent. Since I’m new with home assistant I found template sensors. And got a functional code where it returns the status of the sensor but the issue is the same, when the door sensor goes in deep sleep also the template sensor return the “off” state even if the door sensor went in deep sleep while it was on the “on” state.
The code below is what I used in the dev tools to check if it works.
{%set temp%}
{%endset%}
{%if (states('binary_sensor.finestracamera') == 'on' or states('binary_sensor.finestracamera') == 'off') and states('binary_sensor.finestracamera') != 'unavailable' %}
{%set temp = states('binary_sensor.finestracamera')%}
{%endif%}
stato effettivo: {{states('binary_sensor.finestracamera')}}
Stato: {{temp}}
At this point I can assume that the temp variable get reset every time the status changes, included when it goes unavailable so I need to save the status somewhere it doesn’t get reset everytime. I read something about helpers but if I could avoid to create an helper for every variable it would be nice (since i have 10 door sensors which every one as both contact and battery level sensors)
Basically the triggers will define when the conditions will be checked. If nothing is triggered, the conditions (if any) won’t be checked.
When a condition is checked (after a trigger), then it will run the actions.
The tricky part about using the trigger variable as you have tried initially is the fact that it will be different based on how your automation was triggered and won’t exists if you run the automation manually in the UI. But it is a power tool that I use a lot on many of my automations.