Check for value change, with delay

This is probably a simple one, but I can't seem to figure it out.

I have a shelly power plug connect to my clothes dryer that is reporting it's current usage (W) to me every minute (or less). I want to monitor for when the usage drops to 0 and stays at 0 for more that 2 minutes. The dryer sometimes stops running for a minute but then continues again:

image

A simple trigger node and filter with a 2 minute delay should have worked. The trigger node is set up as: send nothing, wait 2 minutes, send last message.

image

The msg out of the bottom "Format Data" node is just:

{ topic: deviceName, payload: `Currently ${state}` }

where ${state} is "Running" or "Stopped"

You should be able to add a trigger node after the format node. Setting it to output nothing and wait 2mins then output OG message, and reset if payload = Currently Running
e.g.

[{"id":"f4f8f9ca2dcf2bde","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Currently Running","payloadType":"str","x":770,"y":3840,"wires":[["6dd62ae4ed86486d"]]},{"id":"6dd62ae4ed86486d","type":"trigger","z":"b779de97.b1b46","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"120","extend":false,"overrideDelay":false,"units":"s","reset":"Currently Running","bytopic":"all","topic":"topic","outputs":1,"x":1030,"y":3860,"wires":[["8b4346f693c749e6"]]},{"id":"bbdb13729822dcd8","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Currentlt Stopped","payloadType":"str","x":770,"y":3900,"wires":[["6dd62ae4ed86486d"]]},{"id":"8b4346f693c749e6","type":"debug","z":"b779de97.b1b46","name":"debug 2487","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1190,"y":3860,"wires":[]}]

Can you explain this line of code for me:

  • What sort of entity is state (Is it a variable, a context variable, an environment variable?) and how does it get a value?
  • What sort of entity is deviceName?
  • What is the significance of the back ticks around msg.payload?

Since msg.payload can be an object, have you considered separating the element name and value, something like this?
msg.payload.currently = state

That is exactly what I have, but it's not working.

Can not help with limited info.

Export the flow and the data coming out of format node, both running and stopped. Add debug nodes.

Make sure data is in text format

P.S. did you look and try my flow as it also has a reset.

Full flow:

[{"id":"5eb9edf0837f1d1f","type":"change","z":"48f70e83376cab74","name":"Set Shelly Power Details","rules":[{"t":"set","p":"shellyDevices","pt":"flow","to":"{\"fcb467bee8f8\":\"Dryer|400|10\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":40,"wires":[[]]},{"id":"4f381a724fdd8d5e","type":"link in","z":"48f70e83376cab74","name":"Trigger - Startup","links":["6c98517f4e521057"],"x":255,"y":40,"wires":[["5eb9edf0837f1d1f"]],"icon":"font-awesome/fa-thumb-tack"},{"id":"e9c51bcd0ea74790","type":"link in","z":"48f70e83376cab74","name":"Shelly Power Plug","links":["28c4ec9d0ee61629"],"x":35,"y":40,"wires":[["fe62ef257cfd476a"]],"icon":"font-awesome/fa-power-off"},{"id":"287d959b0926e5af","type":"switch","z":"48f70e83376cab74","name":"Device\\n Select","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"Dryer","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":350,"y":200,"wires":[["ef823703414f6ee5"],[]]},{"id":"ef823703414f6ee5","type":"link out","z":"48f70e83376cab74","name":"Dryer","mode":"link","links":["1209f0c2142f9752","fdd086d6477d96ee","9073ec7eece2f082","95abbfd6d9cd2919","02638a08b47736df","e7a355f6fb9bbcdd","41d2b50f72c30a32","27809eae9606fc56"],"x":570,"y":200,"wires":[],"icon":"font-awesome/fa-power-off","l":true},{"id":"ab71ecb111df390a","type":"function","z":"48f70e83376cab74","name":"Format Data","func":"var deviceList = flow.get(\"shellyDevices\") || [];\nvar date = new Date();\n\nvar mac = (msg.topic.split(\"/\")[1]);\nvar split = deviceList[mac].split(\"|\");\n\nvar deviceName = split[0];\nvar upper = split[1] || 100;\nvar lower = split[2] || 100;\nvar delay = 0;\n\nvar flowGet = (flow.get(`p${deviceName}`)) || {};\nvar state = flowGet.state || \"Unknown\"\n\nif  (msg.payload.apower > upper)                              { state = \"Running\";    }\nif ((msg.payload.apower <  lower) && (state == \"Running\"))    { state = \"Stopped\";    }\nif ((msg.payload.output == true)  && (state == \"Turned Off\")) { state = \"Powered On\"; }\nif  (msg.payload.output == false)                             { state = \"Turned Off\"; }\n\nvar newMsg = {\n    topic: deviceName,\n    payload: {\n        state:   state,\n        updated: date,\n        apower:  msg.payload.apower,\n        output:  msg.payload.output\n    }\n}\n\nflow.set(`p${deviceName}`, newMsg.payload)\n\nnode.send([\n    newMsg,\n    {\n        topic: deviceName,\n        device: \"all\",\n        payload: `Currently ${state}`\n    }\n]);\n\nnode.done();\n","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":170,"y":220,"wires":[["287d959b0926e5af"],["f290713c97714078"]]},{"id":"cf03708640fd8d83","type":"rbe","z":"48f70e83376cab74","name":"Alerts","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":350,"y":340,"wires":[["ea7c34242b63ef6e"]]},{"id":"fe62ef257cfd476a","type":"delay","z":"48f70e83376cab74","name":"1/1s","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":55,"y":220,"wires":[["ab71ecb111df390a"]],"l":false},{"id":"f290713c97714078","type":"trigger","z":"48f70e83376cab74","name":"2m Delay","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":180,"y":280,"wires":[["cf03708640fd8d83"]]},{"id":"ea7c34242b63ef6e","type":"debug","z":"48f70e83376cab74","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":560,"y":340,"wires":[]},{"id":"c47da3ec3e77b47b","type":"group","z":"48f70e83376cab74","name":"fcb467bee8f8 - Dryer","style":{"label":true,"stroke":"#ffC000","fill":"#ffefbf","fill-opacity":"0.25","color":"#000000"},"nodes":["1209f0c2142f9752","61ded323022d768d","fff87ef59b875206","2c0e3d0a7f051bc2","5ee9e87afe31cea6","1ca9d9e903bf6855","2a8f95b75e09b830"],"x":14,"y":659,"w":512,"h":162},{"id":"1209f0c2142f9752","type":"link in","z":"48f70e83376cab74","g":"c47da3ec3e77b47b","name":"Dryer","links":["ef823703414f6ee5"],"x":55,"y":740,"wires":[["fff87ef59b875206","2a8f95b75e09b830"]],"icon":"font-awesome/fa-power-off"},{"id":"61ded323022d768d","type":"ui_chart","z":"48f70e83376cab74","g":"c47da3ec3e77b47b","name":"Chart","group":"e0cafeb5773c1b38","order":5,"width":15,"height":7,"label":"","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"Chart Coming Soon","dot":false,"ymin":"0","ymax":"","removeOlder":"3","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":270,"y":720,"wires":[[]]},{"id":"fff87ef59b875206","type":"change","z":"48f70e83376cab74","g":"c47da3ec3e77b47b","name":"Set apower","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.apower","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":155,"y":720,"wires":[["61ded323022d768d"]],"l":false},{"id":"2c0e3d0a7f051bc2","type":"ui_text","z":"48f70e83376cab74","g":"c47da3ec3e77b47b","group":"e0cafeb5773c1b38","order":4,"width":4,"height":1,"name":"Updated","label":"{{updated}}","format":"","layout":"row-right","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":440,"y":740,"wires":[]},{"id":"5ee9e87afe31cea6","type":"ui_text","z":"48f70e83376cab74","g":"c47da3ec3e77b47b","group":"e0cafeb5773c1b38","order":2,"width":5,"height":1,"name":"Curr W","label":"{{state}}","format":"{{apower}} W","layout":"row-spread","className":"","style":false,"font":"","fontSize":16,"color":"#000000","x":440,"y":700,"wires":[]},{"id":"1ca9d9e903bf6855","type":"ui_switch","z":"48f70e83376cab74","g":"c47da3ec3e77b47b","name":"State","label":"","tooltip":"","group":"e0cafeb5773c1b38","order":1,"width":2,"height":1,"passthru":false,"decouple":"true","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"power_settings_new","oncolor":"#38ff38","offvalue":"false","offvalueType":"bool","officon":"power_settings_new","offcolor":"#ff3838","animate":false,"className":"","x":430,"y":780,"wires":[[]]},{"id":"2a8f95b75e09b830","type":"function","z":"48f70e83376cab74","g":"c47da3ec3e77b47b","name":"Show Current State","func":"var func = global.get(\"func\");\nvar date = func.formatDate(msg.payload.updated)\n\nnode.status({\n   fill:  \"blue\",\n   shape: \"ring\",\n   text:  `${date.split(\" \")[2]} | ${msg.payload.state}`\n});\n\nmsg.apower  = msg.payload.apower;\nmsg.state   = msg.payload.state;\nmsg.payload = msg.payload.output;\nmsg.updated = date\n\nreturn msg;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":760,"wires":[["2c0e3d0a7f051bc2","5ee9e87afe31cea6","1ca9d9e903bf6855"]],"outputLabels":["stdout"]},{"id":"e0cafeb5773c1b38","type":"ui_group","name":"Dryer Usage","tab":"9777d11ed41b8896","order":1,"disp":true,"width":"15","collapse":false,"className":""},{"id":"9777d11ed41b8896","type":"ui_tab","name":"Shelly Power","icon":"power_settings_new","order":9,"disabled":false,"hidden":false}]

Input Value Example:

{"topic":"shellypluspluguk/fcb467bee8f8/status/switch:0","payload":{"id":0,"source":"button","output":true,"apower":780.5,"voltage":244.9,"current":3.29,"aenergy":{"total":10600.891,"by_minute":[12948.086,12904.32,12924.776],"minute_ts":1711806240},"temperature":{"tC":36.3,"tF":97.3}},"qos":0,"retain":false,"_msgid":"4f6892cd3f65690e","_event":"node:28c4ec9d0ee61629"}

Graph Data Output

[{"series":["Dryer"],"data":[[{"x":1711795076039,"y":599.7},{"x":1711795136035,"y":600.5},{"x":1711795196093,"y":609.4},{"x":1711795256094,"y":621.9},{"x":1711795316087,"y":625.5},{"x":1711795376080,"y":619.3},{"x":1711795429407,"y":636.8},{"x":1711795436073,"y":629.6},{"x":1711795496071,"y":642.2},{"x":1711795556070,"y":635.7},{"x":1711795616071,"y":652.4},{"x":1711795637397,"y":654.7},{"x":1711795676066,"y":651.4},{"x":1711795736064,"y":657.2},{"x":1711795772398,"y":670.5},{"x":1711795796064,"y":660.9},{"x":1711795797404,"y":490.3},{"x":1711795798404,"y":490.3},{"x":1711795799403,"y":458.3},{"x":1711795800404,"y":458.6},{"x":1711795801404,"y":746.6},{"x":1711795802404,"y":660.1},{"x":1711795803404,"y":660.1},{"x":1711795808390,"y":615.7},{"x":1711795809404,"y":466.7},{"x":1711795810405,"y":466.7},{"x":1711795812392,"y":754},{"x":1711795813403,"y":672.9},{"x":1711795814405,"y":672.9},{"x":1711795856063,"y":671.5},{"x":1711795916056,"y":685.6},{"x":1711795976057,"y":688.4},{"x":1711796036054,"y":685.6},{"x":1711796096046,"y":689.9},{"x":1711796156047,"y":695.9},{"x":1711796214380,"y":709.3},{"x":1711796216043,"y":705.2},{"x":1711796225374,"y":711.5},{"x":1711796276039,"y":707.1},{"x":1711796332377,"y":726.5},{"x":1711796336040,"y":719},{"x":1711796396036,"y":708.9},{"x":1711796456036,"y":721.3},{"x":1711796516041,"y":725.7},{"x":1711796576036,"y":728.6},{"x":1711796579377,"y":523},{"x":1711796580377,"y":523},{"x":1711796582363,"y":864.2},{"x":1711796583378,"y":727.9},{"x":1711796584379,"y":727.9},{"x":1711796590358,"y":618.8},{"x":1711796591377,"y":534.4},{"x":1711796592378,"y":534.4},{"x":1711796594359,"y":879.7},{"x":1711796595372,"y":744},{"x":1711796596373,"y":744},{"x":1711796636026,"y":732},{"x":1711796696029,"y":731.9},{"x":1711796756026,"y":738.6},{"x":1711796816020,"y":740.9},{"x":1711796876018,"y":740.8},{"x":1711796936014,"y":742.8},{"x":1711796996063,"y":744.9},{"x":1711797056057,"y":750.1},{"x":1711797116055,"y":753.1},{"x":1711797176060,"y":756.1},{"x":1711797236049,"y":754.6},{"x":1711797296050,"y":756.7},{"x":1711797356043,"y":755.3},{"x":1711797360326,"y":689.2},{"x":1711797361348,"y":551.1},{"x":1711797362348,"y":551.1},{"x":1711797364325,"y":905.8},{"x":1711797365342,"y":756.7},{"x":1711797366341,"y":756.7},{"x":1711797372327,"y":618.2},{"x":1711797373338,"y":566.7},{"x":1711797374339,"y":566.7},{"x":1711797375339,"y":616},{"x":1711797376339,"y":616},{"x":1711797377339,"y":904.8},{"x":1711797378340,"y":777.9},{"x":1711797379342,"y":777.9},{"x":1711797416045,"y":761.1},{"x":1711797476041,"y":763.4},{"x":1711797536039,"y":773.7},{"x":1711797596047,"y":771.6},{"x":1711797656036,"y":769.6},{"x":1711797716033,"y":778.9},{"x":1711797776030,"y":777.2},{"x":1711797836032,"y":774.7},{"x":1711797896022,"y":776.9},{"x":1711797956019,"y":781.8},{"x":1711798016018,"y":778.4},{"x":1711798076013,"y":781.9},{"x":1711798136010,"y":766.8},{"x":1711798142293,"y":682.5},{"x":1711798143310,"y":571.5},{"x":1711798144311,"y":571.5},{"x":1711798145318,"y":674.2},{"x":1711798146318,"y":674.2},{"x":1711798147319,"y":862.8},{"x":1711798148320,"y":768.7},{"x":1711798149320,"y":768.7},{"x":1711798154292,"y":617.7},{"x":1711798155313,"y":586.8},{"x":1711798156315,"y":586.8},{"x":1711798157315,"y":692.5},{"x":1711798158315,"y":692.5},{"x":1711798159314,"y":884.3},{"x":1711798160315,"y":788.5},{"x":1711798161315,"y":788.5},{"x":1711798196008,"y":778.8},{"x":1711798256013,"y":775},{"x":1711798316006,"y":779},{"x":1711798376002,"y":782},{"x":1711798436007,"y":782},{"x":1711798496001,"y":785.5},{"x":1711798555996,"y":799.3},{"x":1711798615993,"y":789.9},{"x":1711798675987,"y":793.9},{"x":1711798735994,"y":789.8},{"x":1711798796041,"y":796.4},{"x":1711798837278,"y":697.9},{"x":1711798838277,"y":697.9},{"x":1711798839278,"y":216.8},{"x":1711798840278,"y":221.7},{"x":1711798843266,"y":208.5},{"x":1711798854264,"y":205.4},{"x":1711798856033,"y":207.2},{"x":1711798916033,"y":208},{"x":1711798924260,"y":49.1},{"x":1711798925276,"y":4.2},{"x":1711798926278,"y":4.2},{"x":1711798927277,"y":237.7},{"x":1711798928277,"y":237.7},{"x":1711798929277,"y":207.2},{"x":1711798930278,"y":203.7},{"x":1711798935261,"y":192.6},{"x":1711798936262,"y":4},{"x":1711798937264,"y":4.1},{"x":1711798939277,"y":220.5},{"x":1711798940278,"y":220.5},{"x":1711798941278,"y":208.9},{"x":1711798942279,"y":206.9},{"x":1711798976027,"y":207.3},{"x":1711799036025,"y":206.8},{"x":1711799096023,"y":205.9},{"x":1711799105255,"y":216.7},{"x":1711799108256,"y":222},{"x":1711799109267,"y":454.9},{"x":1711799110267,"y":454.9},{"x":1711799111267,"y":556.5},{"x":1711799112268,"y":575.7},{"x":1711799113268,"y":596},{"x":1711799115254,"y":614.8},{"x":1711799117252,"y":628.6},{"x":1711799125256,"y":654.8},{"x":1711799128255,"y":664.3},{"x":1711799141251,"y":691.3},{"x":1711799151254,"y":700.5},{"x":1711799156022,"y":701.2},{"x":1711799216019,"y":707.5},{"x":1711799276018,"y":716.9},{"x":1711799336013,"y":729.5},{"x":1711799339244,"y":732.9},{"x":1711799364243,"y":736.5},{"x":1711799396013,"y":749.2},{"x":1711799456011,"y":742.3},{"x":1711799516003,"y":747},{"x":1711799576002,"y":751.4},{"x":1711799635999,"y":752.8},{"x":1711799695997,"y":756.4},{"x":1711799706228,"y":555.5},{"x":1711799707230,"y":555.9},{"x":1711799709242,"y":915},{"x":1711799710242,"y":915},{"x":1711799711243,"y":758.4},{"x":1711799712245,"y":755.2},{"x":1711799717241,"y":631.1},{"x":1711799718241,"y":631.1},{"x":1711799719242,"y":569.9},{"x":1711799720242,"y":571.6},{"x":1711799721242,"y":934.8},{"x":1711799722243,"y":934.8},{"x":1711799723244,"y":778.7},{"x":1711799724245,"y":775.4},{"x":1711799755994,"y":762.7},{"x":1711799815997,"y":764.6},{"x":1711799875992,"y":764.4},{"x":1711799935987,"y":764.8},{"x":1711799995985,"y":768.2},{"x":1711800055982,"y":767.9},{"x":1711800115979,"y":770.1},{"x":1711800175985,"y":771.5},{"x":1711800235979,"y":773.3},{"x":1711800295979,"y":776.6},{"x":1711800355973,"y":780.2},{"x":1711800415967,"y":778.5},{"x":1711800475965,"y":780.4},{"x":1711800487208,"y":645.8},{"x":1711800488208,"y":645.8},{"x":1711800489209,"y":582.1},{"x":1711800490209,"y":583},{"x":1711800491209,"y":823.9},{"x":1711800492209,"y":788.7},{"x":1711800498194,"y":774.5},{"x":1711800499210,"y":604.3},{"x":1711800500210,"y":604.3},{"x":1711800502195,"y":852.1},{"x":1711800503195,"y":815.7},{"x":1711800506197,"y":808.7},{"x":1711800535961,"y":786.7},{"x":1711800596012,"y":784.3},{"x":1711800656009,"y":785.3},{"x":1711800716011,"y":787.9},{"x":1711800776004,"y":791.4},{"x":1711800829199,"y":274.2},{"x":1711800830201,"y":274.2},{"x":1711800831201,"y":200.6},{"x":1711800832202,"y":201.4},{"x":1711800836002,"y":205.2},{"x":1711800895999,"y":203.8},{"x":1711800955999,"y":202.7},{"x":1711801016000,"y":207.7},{"x":1711801052173,"y":217.2},{"x":1711801055175,"y":218.5},{"x":1711801067173,"y":206.9},{"x":1711801072172,"y":204.5},{"x":1711801075991,"y":204.8},{"x":1711801081191,"y":467.9},{"x":1711801082191,"y":467.9},{"x":1711801083191,"y":553},{"x":1711801084191,"y":568.4},{"x":1711801085191,"y":588.6},{"x":1711801087170,"y":607.4},{"x":1711801089180,"y":620},{"x":1711801095172,"y":646.9},{"x":1711801096170,"y":651.2},{"x":1711801107172,"y":681.8},{"x":1711801109169,"y":685.6},{"x":1711801135989,"y":703.4},{"x":1711801195986,"y":704.2},{"x":1711801255988,"y":713.6},{"x":1711801261171,"y":715.9},{"x":1711801269177,"y":523.4},{"x":1711801270178,"y":523.4},{"x":1711801272166,"y":823.8},{"x":1711801273175,"y":713.7},{"x":1711801274175,"y":713.7},{"x":1711801280162,"y":648.5},{"x":1711801281180,"y":529.2},{"x":1711801282181,"y":529.2},{"x":1711801284161,"y":831.4},{"x":1711801285175,"y":729.4},{"x":1711801286176,"y":729.4},{"x":1711801315989,"y":720.6},{"x":1711801375978,"y":734.6},{"x":1711801435980,"y":734.4},{"x":1711801495976,"y":741.9},{"x":1711801555973,"y":741.2},{"x":1711801615968,"y":752.6},{"x":1711801675968,"y":752.9},{"x":1711801735966,"y":753.5},{"x":1711801795960,"y":758.7},{"x":1711801855961,"y":765.6},{"x":1711801886135,"y":766.9},{"x":1711801889139,"y":771.6},{"x":1711801915976,"y":760.2},{"x":1711801975962,"y":768.1},{"x":1711802035957,"y":765},{"x":1711802050146,"y":681.1},{"x":1711802051146,"y":568.4},{"x":1711802052147,"y":568.4},{"x":1711802053147,"y":660.2},{"x":1711802054147,"y":660.2},{"x":1711802055148,"y":865.4},{"x":1711802056148,"y":764.7},{"x":1711802057147,"y":764.7},{"x":1711802062137,"y":612.1},{"x":1711802063137,"y":583.3},{"x":1711802065154,"y":692.4},{"x":1711802066154,"y":692.4},{"x":1711802067155,"y":867.8},{"x":1711802068155,"y":781.4},{"x":1711802069155,"y":781.4},{"x":1711802095947,"y":768.8},{"x":1711802155948,"y":770.9},{"x":1711802215948,"y":771.4},{"x":1711802275943,"y":775.1},{"x":1711802335939,"y":771.5},{"x":1711802395992,"y":777.6},{"x":1711802455987,"y":790.1},{"x":1711802515990,"y":783.2},{"x":1711802575982,"y":788.2},{"x":1711802635979,"y":790.7},{"x":1711802695983,"y":790.3},{"x":1711802755980,"y":790.5},{"x":1711802805111,"y":625.1},{"x":1711802806112,"y":625.1},{"x":1711802807112,"y":207.8},{"x":1711802808113,"y":206.1},{"x":1711802815970,"y":202.7},{"x":1711802832098,"y":11.9},{"x":1711802833113,"y":4.1},{"x":1711802834114,"y":4.1},{"x":1711802835115,"y":274.7},{"x":1711802836115,"y":274.7},{"x":1711802837115,"y":201.2},{"x":1711802838115,"y":200.4},{"x":1711802843110,"y":181.6},{"x":1711802844109,"y":181.6},{"x":1711802845109,"y":4},{"x":1711802846110,"y":4.1},{"x":1711802847110,"y":226.2},{"x":1711802848111,"y":226.2},{"x":1711802849111,"y":200.7},{"x":1711802850111,"y":200.9},{"x":1711802875967,"y":203.3},{"x":1711802935970,"y":206.5},{"x":1711802995971,"y":209.3},{"x":1711802998090,"y":210.8},{"x":1711802999091,"y":210.8},{"x":1711803055962,"y":206.5},{"x":1711803057107,"y":465.6},{"x":1711803058107,"y":465.6},{"x":1711803059108,"y":555.4},{"x":1711803060109,"y":570.9},{"x":1711803061109,"y":593},{"x":1711803063086,"y":612.5},{"x":1711803065087,"y":627.2},{"x":1711803071090,"y":650.2},{"x":1711803074088,"y":663.1},{"x":1711803083088,"y":688.3},{"x":1711803093084,"y":696.8},{"x":1711803115957,"y":708.2},{"x":1711803175955,"y":705.3},{"x":1711803235955,"y":714.3},{"x":1711803261081,"y":725.4},{"x":1711803277078,"y":732.6},{"x":1711803295953,"y":727.1},{"x":1711803355946,"y":732.9},{"x":1711803415947,"y":742.3},{"x":1711803475944,"y":747.1},{"x":1711803535941,"y":749.8},{"x":1711803559071,"y":763.6},{"x":1711803595942,"y":746.2},{"x":1711803613076,"y":649.3},{"x":1711803614076,"y":649.3},{"x":1711803615076,"y":552.8},{"x":1711803616076,"y":553.2},{"x":1711803617076,"y":705.8},{"x":1711803618077,"y":808.9},{"x":1711803619077,"y":808.9},{"x":1711803620077,"y":746.7},{"x":1711803621076,"y":747.6},{"x":1711803625075,"y":587.8},{"x":1711803626075,"y":587.8},{"x":1711803628068,"y":712.3},{"x":1711803629075,"y":827.1},{"x":1711803630076,"y":827.1},{"x":1711803631076,"y":764.3},{"x":1711803632077,"y":767.8},{"x":1711803655938,"y":757.2},{"x":1711803715937,"y":751.9},{"x":1711803775943,"y":755.5},{"x":1711803835936,"y":764.9},{"x":1711803895925,"y":762.5},{"x":1711803955928,"y":761.2},{"x":1711804015924,"y":771},{"x":1711804075921,"y":772.4},{"x":1711804135921,"y":776.9},{"x":1711804195972,"y":776.9},{"x":1711804255964,"y":777.2},{"x":1711804315964,"y":777.2},{"x":1711804375959,"y":785},{"x":1711804395051,"y":606.1},{"x":1711804396051,"y":606.1},{"x":1711804398030,"y":894.4},{"x":1711804399047,"y":795.4},{"x":1711804400047,"y":795.4},{"x":1711804406033,"y":715.9},{"x":1711804407045,"y":598.8},{"x":1711804408046,"y":598.8},{"x":1711804410030,"y":903.5},{"x":1711804411043,"y":799.9},{"x":1711804412042,"y":799.9},{"x":1711804435958,"y":792.1},{"x":1711804495957,"y":788.2},{"x":1711804555951,"y":791.2},{"x":1711804615959,"y":796.2},{"x":1711804622021,"y":219},{"x":1711804623033,"y":205},{"x":1711804624033,"y":205},{"x":1711804667033,"y":217.9},{"x":1711804668034,"y":217.9},{"x":1711804675946,"y":219.1},{"x":1711804693022,"y":207},{"x":1711804735945,"y":208.7},{"x":1711804795949,"y":210.6},{"x":1711804803014,"y":206.4},{"x":1711804855951,"y":210.4},{"x":1711804874011,"y":529.7},{"x":1711804875025,"y":570.3},{"x":1711804876026,"y":570.3},{"x":1711804877027,"y":602.6},{"x":1711804878028,"y":602.6},{"x":1711804882009,"y":634.4},{"x":1711804883010,"y":639.7},{"x":1711804890012,"y":666.3},{"x":1711804893010,"y":673.9},{"x":1711804908007,"y":701},{"x":1711804915935,"y":706.5},{"x":1711804923011,"y":710.3},{"x":1711804975934,"y":713.2},{"x":1711805035932,"y":717.6},{"x":1711805095932,"y":727.3},{"x":1711805155929,"y":731.2},{"x":1711805175999,"y":652.2},{"x":1711805177010,"y":533.3},{"x":1711805178009,"y":533.3},{"x":1711805179017,"y":618.8},{"x":1711805180018,"y":618.8},{"x":1711805181017,"y":839.9},{"x":1711805182018,"y":732.7},{"x":1711805183017,"y":732.7},{"x":1711805187994,"y":579.1},{"x":1711805189010,"y":546.9},{"x":1711805190011,"y":546.9},{"x":1711805191012,"y":649.3},{"x":1711805192012,"y":649.3},{"x":1711805193013,"y":835.5},{"x":1711805194014,"y":749},{"x":1711805195015,"y":749},{"x":1711805215923,"y":739.1},{"x":1711805275924,"y":734},{"x":1711805335920,"y":740.8},{"x":1711805395917,"y":746.1},{"x":1711805455915,"y":748.8},{"x":1711805515919,"y":755.4},{"x":1711805575918,"y":753.4},{"x":1711805635906,"y":756.3},{"x":1711805695903,"y":758.7},{"x":1711805755906,"y":764.4},{"x":1711805815910,"y":764.6},{"x":1711805875897,"y":767.3}]],"labels":[""]}]

Then you would need to deal with the other 2 states which you did not tell us about.
something maybe like this

[{"id":"f4f8f9ca2dcf2bde","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Currently Running","payloadType":"str","x":630,"y":7720,"wires":[["aed113cde8fd1b7b"]]},{"id":"aed113cde8fd1b7b","type":"switch","z":"d1395164b4eec73e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Currently Stopped","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":7760,"wires":[["6dd62ae4ed86486d"],["f78e3f99973c29af"]]},{"id":"bbdb13729822dcd8","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Currently Stopped","payloadType":"str","x":630,"y":7760,"wires":[["aed113cde8fd1b7b"]]},{"id":"a7bde42e6c018b6e","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Powered On","payloadType":"str","x":610,"y":7800,"wires":[["aed113cde8fd1b7b"]]},{"id":"f39abaef9b7a63e9","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Turned Off","payloadType":"str","x":630,"y":7840,"wires":[["aed113cde8fd1b7b"]]},{"id":"6dd62ae4ed86486d","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1050,"y":7760,"wires":[["8b4346f693c749e6"]]},{"id":"f78e3f99973c29af","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":7800,"wires":[["6dd62ae4ed86486d"]]},{"id":"8b4346f693c749e6","type":"debug","z":"d1395164b4eec73e","name":"debug 2487","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1210,"y":7780,"wires":[]}]

We can ignore the other two states, they are not overly important.

Thank you for your example code, but it does not work, it's only sending "Currently Stopped" to the debug node, nothing else.

Then bypass the trigger node from the second switch output
e.g

[{"id":"f4f8f9ca2dcf2bde","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Currently Running","payloadType":"str","x":630,"y":7720,"wires":[["aed113cde8fd1b7b"]]},{"id":"aed113cde8fd1b7b","type":"switch","z":"d1395164b4eec73e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Currently Stopped","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":870,"y":7760,"wires":[["6dd62ae4ed86486d"],["f78e3f99973c29af","805a742a35c6e183"]]},{"id":"bbdb13729822dcd8","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"device1","payload":"Currently Stopped","payloadType":"str","x":630,"y":7760,"wires":[["aed113cde8fd1b7b"]]},{"id":"6dd62ae4ed86486d","type":"trigger","z":"d1395164b4eec73e","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1050,"y":7760,"wires":[["805a742a35c6e183"]]},{"id":"f78e3f99973c29af","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":7800,"wires":[["6dd62ae4ed86486d"]]},{"id":"805a742a35c6e183","type":"rbe","z":"d1395164b4eec73e","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":1150,"y":7840,"wires":[["8b4346f693c749e6"]]},{"id":"8b4346f693c749e6","type":"debug","z":"d1395164b4eec73e","name":"debug 2487","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1210,"y":7780,"wires":[]}]

It is a Template literal Template literals (Template strings) - JavaScript | MDN (mozilla.org)

1 down, two to go!

State is a string, as it deviceName.

OK, thanks.

Nothing I can do to help, sorry.

I had a similar problem where the module node-red-contrib-power-monitor was doing the job

1 Like