I found that after upgrade to OP2 my Engine Timer flow didnt work so Ive updated it and included the code below.
You will need to install "node-red-contrib-key-value-store" in the NR Palette Manager but all other Nodes are standard.
In my setup, the MQTT/SignalK path "propulsion.state" is sent once a second by the ESP8266 which monitors the engine state. This signal is used to increment the timer.
If you have a constant Engine-On type signal then you'll need to change the flow to incorporate a repeating Injector Node to increment the timer.
(BTW I had to abandon the new "Hourglass" Node as I couldn't find a way to stop it if NR was shutdown with the timer running !)
You will need to install "node-red-contrib-key-value-store" in the NR Palette Manager but all other Nodes are standard.
In my setup, the MQTT/SignalK path "propulsion.state" is sent once a second by the ESP8266 which monitors the engine state. This signal is used to increment the timer.
If you have a constant Engine-On type signal then you'll need to change the flow to incorporate a repeating Injector Node to increment the timer.
(BTW I had to abandon the new "Hourglass" Node as I couldn't find a way to stop it if NR was shutdown with the timer running !)
Code:
[{"id":"a9de4276.efc69","type":"change","z":"4ca2fcda.21eb04","name":"","rules":[{"t":"set","p":"storedcount","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":80,"wires":[[]]},{"id":"89efefe.36aac1","type":"ui_text","z":"4ca2fcda.21eb04","group":"7a732336.738eac","order":8,"width":0,"height":0,"name":"","label":"Engine Hrs (Total)","format":"{{msg.payload}}","layout":"row-spread","x":1290,"y":400,"wires":[]},{"id":"ea645186.35d9a","type":"key-value-write","z":"4ca2fcda.21eb04","store":"d5ff438c.f2a6b","action":"set","key":"","keyvalue":"","name":"Write to store","x":650,"y":520,"wires":[["9b6af102.ea62","3935add.e1e5952"]]},{"id":"78f688cf.4b3e48","type":"key-value-read","z":"4ca2fcda.21eb04","store":"193dd33e.5d69ad","key":"","name":"Read Store","x":650,"y":80,"wires":[["a9de4276.efc69"]]},{"id":"a92c0b15.90dc08","type":"inject","z":"4ca2fcda.21eb04","name":"Reset Counters","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"x":480,"y":520,"wires":[["ea645186.35d9a"]]},{"id":"3c32d5a1.42a7ba","type":"mqtt in","z":"4ca2fcda.21eb04","name":"Eng ON","topic":"propulsion.state","qos":"0","datatype":"auto","broker":"2a82cc4c.c89264","x":70,"y":140,"wires":[["275bf305.baefdc"]]},{"id":"6c27818d.c1dd9","type":"switch","z":"4ca2fcda.21eb04","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":140,"wires":[["78f688cf.4b3e48","f68b2170.8ccf3"],["8e4feba2.55cee8"]]},{"id":"a2699026.64713","type":"ui_text","z":"4ca2fcda.21eb04","group":"7a732336.738eac","order":7,"width":0,"height":0,"name":"","label":"Engine Hrs (Trip)","format":"{{msg.payload}}","layout":"row-spread","x":1290,"y":320,"wires":[]},{"id":"f68b2170.8ccf3","type":"function","z":"4ca2fcda.21eb04","name":"Reset Trip Counter","func":"msg.reset = true;\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":120,"wires":[["42aec02a.5ff0e"]]},{"id":"9b6af102.ea62","type":"change","z":"4ca2fcda.21eb04","name":"","rules":[{"t":"set","p":"storedcount","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":860,"y":580,"wires":[[]]},{"id":"3935add.e1e5952","type":"change","z":"4ca2fcda.21eb04","name":"","rules":[{"t":"set","p":"tripcount","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":520,"wires":[[]]},{"id":"1c12756f.7ff62b","type":"function","z":"4ca2fcda.21eb04","name":"Prep Trip Display","func":"var time = global.get(\"tripcount\");\nvar hours = Math.floor(time / 3600);\ntime = time - hours * 3600;\nvar minutes = Math.floor(time / 60);\nvar seconds = time % 60;\nmsg.payload = hours + \"hr \" + minutes + \"m \" + seconds + \"s \";\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":320,"wires":[["a2699026.64713"]]},{"id":"703a5b8a.5ddb74","type":"function","z":"4ca2fcda.21eb04","name":"Prep Total Display","func":"var time = global.get(\"storedcount\") + global.get(\"tripcount\");\nvar hours = Math.floor(time / 3600);\ntime = time - hours * 3600;\nvar minutes = Math.floor(time / 60);\nvar seconds = time % 60;\nmsg.payload = hours + \"hr \" + minutes + \"m \" + seconds + \"s \";\nreturn msg;","outputs":1,"noerr":0,"x":1070,"y":400,"wires":[["89efefe.36aac1"]]},{"id":"8b58273a.09ce58","type":"rbe","z":"4ca2fcda.21eb04","name":"Once","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":330,"y":140,"wires":[["6c27818d.c1dd9"]],"info":"Only allow the engine on signal through once"},{"id":"a68442e1.79e4d","type":"key-value-write","z":"4ca2fcda.21eb04","store":"193dd33e.5d69ad","action":"set","key":"","keyvalue":"","name":"Write Store","x":1270,"y":200,"wires":[[]]},{"id":"42aec02a.5ff0e","type":"counter","z":"4ca2fcda.21eb04","inc":1,"name":"","x":640,"y":320,"wires":[["26f1a5aa.2ebc7a"]]},{"id":"26f1a5aa.2ebc7a","type":"change","z":"4ca2fcda.21eb04","name":"","rules":[{"t":"set","p":"tripcount","pt":"global","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":320,"wires":[["1c12756f.7ff62b"]]},{"id":"6d592bfc.31e7f4","type":"switch","z":"4ca2fcda.21eb04","name":"Only Count \"1\"s","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":360,"y":320,"wires":[["42aec02a.5ff0e","703a5b8a.5ddb74"]]},{"id":"9f66c09c.d61a9","type":"function","z":"4ca2fcda.21eb04","name":"Calc TotalCount","func":"msg.payload = global.get(\"storedcount\") + global.get(\"tripcount\");\nreturn msg;","outputs":1,"noerr":0,"x":1060,"y":200,"wires":[["a68442e1.79e4d"]]},{"id":"66dacabb.53f3d4","type":"inject","z":"4ca2fcda.21eb04","name":"Initialize","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":460,"y":40,"wires":[["78f688cf.4b3e48"]]},{"id":"275bf305.baefdc","type":"function","z":"4ca2fcda.21eb04","name":"S-N","func":"msg.payload = Number(msg.payload);\nmsg.topic = \"\";\nreturn msg;","outputs":1,"noerr":0,"x":190,"y":140,"wires":[["8b58273a.09ce58","6d592bfc.31e7f4"]]},{"id":"8e4feba2.55cee8","type":"delay","z":"4ca2fcda.21eb04","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":830,"y":200,"wires":[["9f66c09c.d61a9"]]},{"id":"28f86ffc.a3507","type":"inject","z":"4ca2fcda.21eb04","name":"Initialize","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":460,"y":220,"wires":[["26f1a5aa.2ebc7a"]]},{"id":"4958dabb.1c0f84","type":"inject","z":"4ca2fcda.21eb04","name":"Initialize","topic":"","payload":"storedcount","payloadType":"global","repeat":"","crontab":"","once":true,"onceDelay":"1","x":460,"y":400,"wires":[["703a5b8a.5ddb74"]]},{"id":"7a732336.738eac","type":"ui_group","z":"","name":"Pi Status","tab":"f287220a.330a","order":1,"disp":false,"width":5,"collapse":false},{"id":"d5ff438c.f2a6b","type":"key-value-store","z":"","filepath":"store.json","namespace":"","name":"Counter_store"},{"id":"193dd33e.5d69ad","type":"key-value-store","z":"","filepath":"store.json","namespace":"","name":"Counter_store"},{"id":"2a82cc4c.c89264","type":"mqtt-broker","z":"","broker":"10.10.10.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"f287220a.330a","type":"ui_tab","z":"","name":"NavPi Status","icon":"dashboard","order":4,"disabled":false,"hidden":false}]