Still quite new to HA (core install 2022.12.3) I want to create a retriggerable timer that switches on a light. After the timer timeouts, the lamp is turned off. When the timer receives a trigger during countdown, the initial timer value should be restored.
trigger switches on light and a timer (e.g. 180s)
the running timer receives a trigger, reset to 180s
If your automation starts a timer whenever the PCF8574 input that goes from 1 to 0, it will do that each time this state-change occurs. In other words, if the timer is active and then the state-change occurs, the automation restarts the timer. The automation should specify the duration value when starting the timer.
Ok, but these sorts of automations, can it be done by the GUI or is “vi” the appropiate tool? I read somewhere I should turn the light on and start a timer. When the timer times out, the light is switched off. Then, if a trigger occurs before timeout, it should re-initiate the timer. But I cannot find a method to achieve this using the GUI…
I assume by “GUI” you mean the Automation Editor in visual mode. Yes, you can create what you want using the Automation Editor. However, posting a series of screenshots, showing each step of the process of creating an automation in visual mode, is not the usual way community members share their automations. Reference: FAQ guideline 16
Every automation you create with the Automation Editor in visual mode is ultimately stored as YAML. You can switch the Automation Editor from visual to YAML mode at any time to see the automation in YAML form (click the ‘three-dots’ icon in the upper right-hand corner of the Automation Editor and select ‘Edit in YAML’). It also makes it very easy to share an automation because you can simple copy-paste the example I posted directly into an new, empty automation in the Automation Editor, while it is in YAML mode, then switch it to visual mode.
I didn’t declare a timer at all. Now I added a helper, but according to the trace the timer is never fired. I’ll throw everything away and I will try to build a new one. Just before deleting, here is the code:
Yep, that did it. It works like a charm. I begin to understand a bit how things work…
What happens now is that the light receives a command light.turn_on each time the trigger occurs. This light.turn_on is an X10 signal that is sent to the X10-switch. I would like to prevent the light.turn_on from being sent to the X10-switch when the light is already ON. If I add a condition, the timer would not receive a re-init. IOW: I need to add a condition into the if-then structure. Is that possible?
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic is resolved. This helps other users find answers to similar questions.
For more information about the Solution tag, refer to guideline 21 in the FAQ.
Please consider marking my post above with the Solution tag (the one containing the example you ultimately used). You marked your own post as the Solution but it simply contains a copy of what I had proposed. That’s not how the Solution tag was meant to be used (refer to guideline 21 in the FAQ).