Hi Guys,
i have an issue regarding a filter on a time format.
I get a time as a “payload number” out of a Solar forecast. I like to have a countdown for that specific time to get my devices programmed on an easy way.
Do you have some ideas for me?
Hi Guys,
i have an issue regarding a filter on a time format.
I get a time as a “payload number” out of a Solar forecast. I like to have a countdown for that specific time to get my devices programmed on an easy way.
Do you have some ideas for me?
Have a function node and a delay node in between.
Function node:
msg.delay = (Date.parse(msg.payload)-Date.now());
For debug purpose, connect function node with debug node also and set the debug node to complete message.
Now you should see the delay in ms in the message/debug window.
Sorry. No the other way around.
The function node is the one that creates the delay time variable, and the delay node is the one that does the delay.
So:
State change node -> function node -> delay node -> debug on complete message
# optional but good for debug -> debug on complete message
Add this to your state change node:
[{"id":"c80feb0e082e9c75","type":"delay","z":"ebaa69a9.649708","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":500,"y":640,"wires":[["cb3b50a331cbd8f3"]]},{"id":"73922e666c8c925d","type":"function","z":"ebaa69a9.649708","name":"","func":"msg.delay = (Date.parse(msg.payload)-Date.now()) + 5000;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":700,"wires":[["c80feb0e082e9c75","cb3b50a331cbd8f3"]]},{"id":"cb3b50a331cbd8f3","type":"debug","z":"ebaa69a9.649708","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":720,"wires":[]}]
I just realized, you can probably use:
But that depends on what happens when this time happens.
Does it stay as 13:00 after 13:00? Or does it go to tomorrows data?
I think it will go to tomorrows data.
Can you show me the full node?
Thanks
I missed an s, but you get the idea.
I believe it won’t trigger if the sensor value changes before the time.
Can you look in the history if it changes before the time?
You could possibly offset with -5 minutes and it will probably not make any difference but still make sure the automation runs.
But this method is perhaps not as safe as the one mentioned above with delay.
Because if it predicts peak to be at 13:00, but the peak was actually at 12:45, and this sensor notices this it could display tomorrows value and your automation won’t run that day.
The delay method will run at the predicted time. If the time however changes during the day.
Say 12:00, then 12:30 and then goes to tomorrow, then the delay version will trigger twice.
Sorry, but i don´t get it. I only want an output like 12h or 1h until the daily peak.