I made an automation that changes the input_text based on the status of a gate. If the gate is opened then the input_text is set to “open”, after some seconds the input_text changes to “close” if there is no signal from the gate.
This works but it is inefficent. I would like to be able to use a variable instead of writing and reading values from input_text.
But what’s the point of this input_text in relation to the automation?
Why don’t you just trigger on the state of the gate directly? If it’s a binary sensor, there is no need for any variable, the state is always “on” or “off”.
I have an esp32 plugged to the gate motor, when the gate is opened the esp is active and sending periodic mqtt messages to my home assistant server. When the device is powered off it means the gate must be closed or it is closing.
All of this because I want to remotely know my gate status and I can also trigger automations based on that.
When the gate is closed the esp doesn’t send an “off” signal because it is not powered. That’s why input_text comes in. After some seconds if there is no “on” mqtt signal it means the esp is off and then the gate is closed.