Hi all,
I have an inverter that has a last connection date which I want to compare with the current
node red server time then be able to give the difference in hours/days/months/years(if applicable).
I have tried both ways of trying to generate a time stamp using a trigger node into a function node
and tried generating the time stamp internally of the function node but cant quiet work out how to
get the server time stamp to calculate and minus the last connected time stamp. Id been scouring
over the last few days trying to get this right. I am not sure what I am doing wrong.
Id really like to somehow create an alert of some kind if its not been connected for over 5 hours
and then id set it to send another alert after a couple hours if the message is still over that time.
Here is my code currently
[{"id":"93852779.708bb","type":"function","z":"fad30e4e.c7f78","name":"","func":"let LastCon = msg.payload.last_timestamp;\nlet SrvCon = Date.now()\n(LastCon * 1000) - SrvCon = msg.payload;\n//msg.topic = \"Inv-LastCon\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":1340,"wires":[["3388d803.9df328","9fb55a19.e5515"]]}]
a little extra
[{"id":"93852779.708bb","type":"function","z":"fad30e4e.c7f78","name":"","func":"let LastCon = msg.payload.last_timestamp;\nlet SrvCon = Date.now()\n(LastCon * 1000) - SrvCon = msg.payload;\n//msg.topic = \"Inv-LastCon\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":1340,"wires":[["3388d803.9df328","9fb55a19.e5515"]]},{"id":"3388d803.9df328","type":"debug","z":"fad30e4e.c7f78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":1340,"wires":[]},{"id":"8cbcf487.a0bc28","type":"debug","z":"fad30e4e.c7f78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1110,"y":1380,"wires":[]},{"id":"641be725.eca6e8","type":"trigger","z":"fad30e4e.c7f78","name":"Current","op1":"","op2":"","op1type":"nul","op2type":"date","duration":"100","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":880,"y":1380,"wires":[["8cbcf487.a0bc28"]]}]