I am running an automation with to shut down the kids PC at a given time on school days.
It uses the RPC-addon and is working fine.
Since discovering node red i have passed all, or almost all automations to node red.
This one wold be easy with an inject node, BUT i was trying to use an HA input bolean and a input time to set the on/off switch and set the hour at will.
Is there a way to use the info in the input time, the time that is set there and use it as the “at a specific time” time value?
Hi, surprisingly implementing such a basic automation like this turned out to be way too harder then I expected but I am using schedex for this. Have a look https://www.npmjs.com/package/node-red-contrib-schedex
Big timer is also another alternative but I found it too complicated.
There is an input time in ha and everytime it is updated, send the message to schedex to update the schedule time. In my case, morning alarm. I am on mobile but will try to post the flow tomorrow if you need…
there are 2 current state nodes, checking if the alarm clock is “on” and if it’s a workday. maybe you can also change the workday sensor in HA and use it as a condition if “tomorrow” is a school day (come on give them some slack )
Now I don’t remember why did I put a switch node between alarm set and workday, you might get away without it if you clean the flow little bit.
I am getting a “TypeError: Cannot read property ‘attributes’ of undefined” on the debug node.
You have on the node code homeAssistant, i tried with A and a, same error.
The input_datetime is correct, any tought on why the error on the debug?
EDIT:
Weirdly enought repasted the datetime_input name and started to work!
I will go with Kermit solution, is a smaller solution
BUT thank you too, serkank, for the help also.
Sorry to revive an old topic, but in looking for a solution to a problem I saw this post and it was exactly what I wanted to do. I however spent a bit of time trying to use this, but all I got was no output. What I came to realize is that you only should compare minutes if the hours were equal. I didn’t need the accuracy of minutes so I just removed the minute comparison. I’m also not proficient enough to rewrite it and nest everything correctly. Please don’t take this as criticism. This was the only post that got me to were I needed to be.
Are you using the code exactly as shown in Kermit’s post? If so it will work intermittently, because it is not completely correct. In the code above the Minutes are always evaluated. They only need to be evaluated if a given hour is equal to start or end hour. In any other case only the hours need evaluated. I just don’t know how to code it…
You don;'t need to do that any more. In the latest versions of the node, Kermit has introduced a time node that does exactly that.
At input_time value it will trigger the flow.
No… The time function from the home assistant websocket palette does that. There are many time tools in various palettes, I am referring to this one.
When it is time it triggers the flow.
So I thought of a work around, You could create a Boolean input helper say called “In The Zone”. The set up 2 automations to turn it on and off at the required start and end times. Then you can evaluate it with current state in node red.