I saw an earlier post in the configuration section regarding this topic: Random timer.
But thought to re-request this idea here.
It would be nice to have access to a random time generator for use with a burglar deterrent light system.
i.e. have hass be able to switch the lights off at a random time time between 22:30 and 00:00 on nights when no one is at home.
write a small py which writes a random time to a file.
in automation call the py every night, lets say at 21:00
the you can make a sensor to connect to the file and write an automation that fires at the set time.
that way you can randomize the times from any automation you like.
Thanks!, I am currently doing it using a python file, but as I find it such a useful feature, I thought it be worth requesting it as part of the main platform.
Apologies for necroposting but over 4 years later is this integrated somewhere yet? Tasmota has a really nice timer system that allows adding a random offset of +/- up to 15 minutes. This is such a basic feature that most fancier standalone lamp timers have offered for decades. I feel like I must be overlooking something obvious. Iām currently using the local timers in Tasmota for a lot of my timed lights for this reason, but I would love to be able to do everything in one place. It would be fantastic if a random offset could just be tacked onto any time value. I want to avoid the āHome Aloneā scenario where the burglars have figured out that everyone is away and the lights are on timers because they all turn on at precisely predictable times.
@Teagan42, can you please write a few more words about your work around? I have not used templates before and therefore I am not clear what to do with the code you wrote. thanks in advance
If you can give us a sample of where you would like to use it and a use case, we can show you how to use templates in such a case.
e.g. do you want to have a light come on āsomewhereā between 20:00 and 21:00 and have it go off again 30 to 60 minutes later ?
Post what you have so far ā¦
Edit: Oh ! and youāll have to say which file normally stores your automations (probably automations.yaml)
You may or may not (probably not) be able to edit this automation from the GUI after it is made (I dunno, I donāt use the GUI editors)
@Mutt thatās really kind of you.
You guessed right; Iād like the light to turn on between 7:30 and 8:00 and turn off between 23:30 and 00:10.
My automations are stored in automations.yaml.
Thanks
So write an automation that triggers the ālightā at 07:30 then we have the āentitiesā to work with (entity_id's).
Note: To Paraphrase what you asked for (itās the same* but makes the automation simpler) : -
Light on between 07:30 and 08:00 (so in the morning ???) and switches off again between 15:30 - 16:10 later (i.e. after it switched on. * - This is ānot quiteā the same, the randomness is constrained by the boundaries of the limits but (say) if the light switched on at 07:30 it would have to switch off at or before 16:10 later and the same for 08:00
This allows you to keep it all in one simple automation rather than having to make an automation to switch it on, and another to switch it off.
Regardless, weāll write it and you can adapt it as you need to.
Edit: You donāt need to tag me if you are repling to my post rather than the thread
to be more specific, this automation is for roller blinds (i said light just to keep it simple , I didnāt think it matters).
If I understood you correctly, it makes sense that the randomness is within a boundary of a time window. The task at hand has two time windows, one in the morning, and the other at night. I did not expect to trigger both from within a single automation.
Okay,
If you canāt work the code out from the above example then you are likely to have difficulties in implementation.
The reasons we ask for a basic automation are : -
To get the entities
To check your spacing (yaml is sensitive)
To give you a fighting chance of getting an automation that works (or if it doesnāt has a limited area where it could be wrong)
Then with it working you can tweak it / break it - but recover and try again
Without this we get people who think they can re-interpret it on the fly and do it using the gui
I figured out the code and I totally understand it (p.s. the filter rand should be spelled random).
I am not sure about a couple of things:
where and in what way is this code integrated in the automation yaml?
is the automation yaml processed on a regular basis? Otherwise, how will the random code change the trigger time from one instance to the next? donāt be shy to elaborate on this
Use the GUI Editor to create an automation that raises the ācoverā at 09:00 (or whatever time you wish), save and then CUT & PASTE that automation here.