I am using a sonoff SV as I only require 12v to be switched. I have set it up so it has 2 switches. A main switch to turn on the christmas audio and a secondary which I am using as an automation timer.
I am trying to run an automation so when I push the secondary switch the audio for my Christmas lights turns on for a set period of time. but if i hit the normal switch it stays on consistently.
I am trying to remove any bugs at the moment as I have the timer working. I am most likely going to get multiple button pushes from the people coming to see the lights which is where I am having the issue.
the bug I am trying to sort is if the secondary button is pushed the audio turns on for a given period but if the secondary button is pushed within the given period of time the timer has no effect and the audio stays turned on.
How do I make the timer persistent so that even if the secondary switch is toggled to off the main switch still turns off after the given period of time but if the secondary switch is toggled back to on the timer starts again?
I don’t want to set a timer on the main switch as i want to be able to turn the audio on constantly if required.
Main switch - audio turns on and off with the state of this switch. Audio output is wired to this switch.
Second switch - audio should come on for 15 minutes when this switch is on. Switching off does nothing. The timer should not reset to start counting 15 minutes again if the switch is pushed more than once.
You are correct with the main switch and I am happy with that functionality.
the second switch
Current:
turns the main switch on and if no other state changes it turns off after 15 minutes
turns the main switch on but if the state changes to off it disables the timer, if switched back on the timer starts again for the 15 minutes
What I want:
once state changed to on run a timer for 15 minutes.
if the state changes to off within that 15 minutes continue with the original 15 minutes
if the state changes to on reset timer to an additional 15 minutes
What I can live with (if easier):
if it makes it easier I am happy to make it so every time the second switch is pushed it resets the timer for 15 minutes.
I hope this clears up any confusion with what I need.
- id: christmas_light_audio_timer
alias: 'Christmas Light Audio Timer'
trigger:
entity_id: switch.christmas_audio_timed
platform: state
to: 'on'
condition: ## omitting this condition will allow the timer to reset each time the second switch turns on ##
condition: state
entity_id: timer.xmas_audio_timer
state: 'idle'
action:
- service: switch.turn_on ## if it's already on this wont matter
entity_id: switch.christmas_audio
- service: timer.start ## if it's already on this will reset the timer
entity_id: timer.xmas_audio_timer
Leave out the condition if you want the timer to reset every time the second switch is turned on.
This is untested and I’ve probably made some mistakes. Let me know how it goes.
I omitted the condition in the last automation for now, but if kids push the button constantly I may add it back in when it all goes live.
This is required as last year was my first year doing a Christmas display and the music on constantly till late starts to do your head in after a few days. Now it will be on constantly through the FM transmitter and only loud when the button is pressed and the fm receiver to the amp is turned on.
Thank you so much for your help. I have learned a lot. I had no idea about timers as a component.
The issue is knowing how to implement them properly.
I’m stuck on the google maps device tracking at the moment.
Owntracks just does not update from my wife’s phone and i have set the setting the same for both phones and as they are both android it makes sense just to use the google maps option (if I can get it to work).
I am still learning and there is a lot to learn and it is constantly growing and changing.
I was so excited when i got google home integration working and then the update broke it and I had to work out how to fix it as when I followed the instructions it didn’t work. But after an hour or 2 of yelling at the computer it worked.
HA is a rapidly evolving system of systems. Sometimes manufacturer’s change things, sometimes the original way things were done in HA doesn’t work out in the long run and breaking changes are needed. Always read the breaking changes for every new HA release.
I cant help with Google maps unfortunately. I don’t use it.
I’m happy for the evolution of the system. But I still get frustrated by the changes when they break things. Don’t get me wrong. I appreciate what the dev’s do and it is amazing to have such an awesome system running on a cheap raspberry pi.
There have been a few breaks that I have had to figure out, and it forces you to learn (and re learn what has vanished from memory).
I need to start reading the breaking changes before doing updates. But usually i just smash the update button without even thinking.
I’ll figure out the google maps in time. Just a lot of the info on the forum with the fixes goes straight over my head.