So let me start by saying I’m not a prgrammer. I can noodle thru the basics and that’s about it.
I use input_booleans as “locks” in HA to limit actions. I would like to be able to set a Date/Timer input to do some additional items with but as much as I google, experiment and poke around I can’t find out how.
What I would like to do is:
Set a random time within 30 to 45 min of a certain time. (ie. at 8:30 set a time between 9:00 and 9:15) Which I can do with the random node.
Take that time and place it into my input_datetime entity.
Use a function node where you convert your start datetime value to microseconds with Date.parse(msg.payload), which will give you a value in microseconds since new year 1970.
To this you can add and subtract microseconds, so adding 60x60x1000 will increase the value one hour.
Use Math.floor(Math.random()*max) to get a random number between 0 and max.
Add the numbers up and return the message.
The new time node in the home assistant nodes is made for this scenario. Create an input time helper, use that entity in the node. Set it to state and check the randomize box.
Just use a call service node. You can use load example data to see the json formatting for the data entry. Btw load example is not working on quite a few nodes so load example won’t always work.
What would I put in the Data field to pass the time onto the input boolean? I’ve tried $now() but It places the UTC time and not my local. I’ve confirmed that my HA time is correct for my timezone.
What I’m thinking is having something like time > time formatter (to add time) > call service (input time into boolean).
1st let me say the help as been WONDERFUL but it’s the last piece that has me stumped.
I’ve done the load example data and the flow works great. But the part that I can’t grasp is how to replace the “2019-04-20 05:04:20” sample data with what’s being sent in from my “time” node.