I’m trying to make an automation that can calculate the remaining time left on my cooker, using the estimated time stamp and deducting the current time. I’m failing miserably, I just can’t get my head around it.
so far I’ve come up with this:
[{"id":"b0647e2c628fdda4","type":"debug","z":"24f9f29f4151076e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1110,"y":1600,"wires":[]},{"id":"d1e8bc70a60ff147","type":"function","z":"24f9f29f4151076e","name":"function 1","func":"let a = new Date().getHours() + 2 //the + 2 is for time zone correction\nlet b = msg.payload.a\nlet c = a - b\n\nmsg.payload = c\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":1600,"wires":[["b0647e2c628fdda4"]]},{"id":"36719144d1b6394e","type":"api-current-state","z":"24f9f29f4151076e","name":"","server":"4e7f96b.0675968","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.top_oven_remaining_program_time","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload.a","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":470,"y":1600,"wires":[["d1e8bc70a60ff147"]]},{"id":"900273c38e1b8335","type":"inject","z":"24f9f29f4151076e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":200,"y":1720,"wires":[["36719144d1b6394e"]]},{"id":"4e7f96b.0675968","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
I’ve been trying to use the information from http://stevesnoderedguide.com/working-with-time but I think I’m too dumb to understand it. Can anyone point me in the right direction, please?