Needing help with logic in flow to get indications working

Though the dashboard is used, it is more the mechanics in which I am stuck.

There are a lot of foreign nodes (extras).
I'll try to include their names.

But here's the problem.
I have a schedule which has 3 states.
I'll call the states: HOME, AWAY, and OFF.

HOME: Every day at a given time a signal is sent to do things.
Locally a template node indicates it is running.
After a time, another signal it sent to end things happening.
Likewise Locally the template node gets another message to say it is .... sleeping (Waiting the next invocation).

AWAY: Basically the same, but not every day.

OFF: All things are stopped and the template node is sent a different symbol indicating that all things are stopped.

The scan frequency is every minute.

Also, when it taken from OFF to either of the other modes, the template node gets a message updating its icon from the STOP to the SLEEP icon.

(Phew: Only one foreign node)

node-red-contrib-ui-time-scheduler

This is the basic mechanics of the flow. (From testing phase)
The RBE nodes are doing weird things.
They were replaced with this one instead.

This also helps show me what is going on with the nodes.

The real flow is a bit more complicated but for now if I can be sure this works, I know I am going in the right direction.
If it doesn't, then it would explain why the bigger flow isn't working.

[{"id":"1203562e.70696a","type":"function","z":"6dd5ca4d.d1958c","name":"RBE","func":"if (msg.reset == true)\n{\n    context.set(\"PREVIOUS\",0);\n    return;\n}\nvar previous = context.get(\"PREVIOUS\") || 0;\nvar incoming = msg.payload;\n\nif (incoming == previous)\n{\n    node.status({fill: \"red\"});\n    return;\n} else\ncontext.set(\"PREVIOUS\",msg.payload);\nnode.status({fill: \"gren\"});\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1740,"y":4690,"wires":[["be5910a4.a301d8","2f671020.e0ab8","24a824f6.7e1d5c"]]}]
[{"id":"315225bf.0e0a62","type":"file in","z":"bb2e50af.775dd8","name":"Plants","filename":"","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":670,"y":2270,"wires":[["ad43e469.e10b48"]]},{"id":"ad43e469.e10b48","type":"ui_time_scheduler","z":"bb2e50af.775dd8","group":"ecb4a309.eff9c","name":"Plants","refresh":"5","devices":["ScheduleHome","ScheduleNotHome"],"customPayload":false,"eventMode":false,"outputs":3,"order":5,"width":"6","height":"1","x":850,"y":2270,"wires":[[],["1b4144c4.5f2a83","dd599545.0ba668"],["ab4796e3.76a5e8","dd599545.0ba668"]]},{"id":"1b4144c4.5f2a83","type":"function","z":"bb2e50af.775dd8","name":"checkIfHome","func":"// THIS WILL ONLY SEND SOMETHING IF YOU ARE AT HOME\nif (flow.get(\"atHome\") === true) return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1050,"y":2270,"wires":[["3c72089.3472578"]]},{"id":"ab4796e3.76a5e8","type":"function","z":"bb2e50af.775dd8","name":"checkIfHome","func":"// THIS WILL ONLY SEND SOMETHING IF YOU ARE NOT AT HOME\nif (flow.get(\"atHome\") === false) return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1050,"y":2350,"wires":[["7ed31be2.7746b4"]]},{"id":"fee3973b.2df2f8","type":"ui_dropdown","z":"bb2e50af.775dd8","name":"am I at home","label":"","tooltip":"","place":"Select option","group":"ecb4a309.eff9c","order":2,"width":"4","height":"1","passthru":true,"multiple":false,"options":[{"label":"@Home","value":true,"type":"bool"},{"label":"not@Home","value":false,"type":"bool"},{"label":"Off","value":"off","type":"str"}],"payload":"","topic":"","x":690,"y":2110,"wires":[["c9214501.a9cca8"]]},{"id":"c9214501.a9cca8","type":"function","z":"bb2e50af.775dd8","name":"setAtHome","func":"flow.set(\"atHome\", msg.payload);","outputs":1,"noerr":0,"initialize":"","finalize":"","x":870,"y":2110,"wires":[[]]},{"id":"6cdb39f8.06c5b","type":"comment","z":"bb2e50af.775dd8","name":"Set your mode based on this dropdown","info":"","x":510,"y":2070,"wires":[]},{"id":"2834e59e.5f319a","type":"inject","z":"bb2e50af.775dd8","name":"SetValueAfterReboot","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":480,"y":2110,"wires":[["fee3973b.2df2f8"]]},{"id":"6cfe250b.58581c","type":"comment","z":"bb2e50af.775dd8","name":"Scheduler now has \"2 devices\" but we use them as \"home\" and \"not home schedule\"","info":"","x":650,"y":2210,"wires":[]},{"id":"249ffc69.998a8c","type":"inject","z":"bb2e50af.775dd8","name":"loadFileAfterReboot","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":2270,"wires":[["ae40d4b2.fc7bc"]]},{"id":"ae40d4b2.fc7bc","type":"function","z":"bb2e50af.775dd8","name":"build message","func":"var path = global.get(\"event_paths\");\nmsg.filename = path + \"test.txt\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":495,"y":2270,"wires":[["315225bf.0e0a62"]]},{"id":"c2ebe9e1.73b57","type":"change","z":"bb2e50af.775dd8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"atHome","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":2530,"wires":[["f29666d8.1fae8"]]},{"id":"13c0a3bc.293c14","type":"switch","z":"bb2e50af.775dd8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":690,"y":2530,"wires":[[],[],["f94c9c1e.dfb07","8db44b08.e8c148"]]},{"id":"8db44b08.e8c148","type":"trigger","z":"bb2e50af.775dd8","name":"OFF","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1340,"y":2480,"wires":[[]]},{"id":"d0724347.466218","type":"trigger","z":"bb2e50af.775dd8","name":"HOME","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1340,"y":2270,"wires":[[]]},{"id":"641984a1.1354a4","type":"trigger","z":"bb2e50af.775dd8","name":"AWAY","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1340,"y":2350,"wires":[[]]},{"id":"3c72089.3472578","type":"rbe","z":"bb2e50af.775dd8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1220,"y":2270,"wires":[["d0724347.466218","673b2d.f14bc4d4"]]},{"id":"7ed31be2.7746b4","type":"rbe","z":"bb2e50af.775dd8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1220,"y":2350,"wires":[["641984a1.1354a4","b8f82aae.078f58"]]},{"id":"f94c9c1e.dfb07","type":"change","z":"bb2e50af.775dd8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1030,"y":2440,"wires":[["3c72089.3472578","7ed31be2.7746b4"]]},{"id":"4b13bfcd.886ac8","type":"inject","z":"bb2e50af.775dd8","name":"HOME","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":340,"y":2350,"wires":[["5d95836a.1b91e4"]]},{"id":"5d95836a.1b91e4","type":"change","z":"bb2e50af.775dd8","name":"","rules":[{"t":"set","p":"atHome","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":2400,"wires":[[]]},{"id":"9b229bc4.156228","type":"inject","z":"bb2e50af.775dd8","name":"AWAY","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":340,"y":2400,"wires":[["5d95836a.1b91e4"]]},{"id":"9436244b.5e6a38","type":"inject","z":"bb2e50af.775dd8","name":"OFF","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":340,"y":2450,"wires":[["5d95836a.1b91e4"]]},{"id":"673b2d.f14bc4d4","type":"debug","z":"bb2e50af.775dd8","name":"HOME","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1340,"y":2210,"wires":[]},{"id":"b8f82aae.078f58","type":"debug","z":"bb2e50af.775dd8","name":"AWAY","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1340,"y":2410,"wires":[]},{"id":"f29666d8.1fae8","type":"rbe","z":"bb2e50af.775dd8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":510,"y":2530,"wires":[["13c0a3bc.293c14","9c576dbb.129e68"]]},{"id":"9c576dbb.129e68","type":"trigger","z":"bb2e50af.775dd8","name":"CLOCK","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":520,"y":2570,"wires":[[]]},{"id":"2d37930a.c1bf8c","type":"link in","z":"bb2e50af.775dd8","name":"","links":["dd599545.0ba668","c348ffc7.10c17"],"x":215,"y":2530,"wires":[["c2ebe9e1.73b57","27a38849.419878"]]},{"id":"dd599545.0ba668","type":"link out","z":"bb2e50af.775dd8","name":"","links":["2d37930a.c1bf8c"],"x":995,"y":2400,"wires":[]},{"id":"27a38849.419878","type":"trigger","z":"bb2e50af.775dd8","name":"CLOCK","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":320,"y":2570,"wires":[[]]},{"id":"ecb4a309.eff9c","type":"ui_group","name":"TempDemo","tab":"2936b813.6cde68","order":4,"disp":true,"width":"8","collapse":false},{"id":"2936b813.6cde68","type":"ui_tab","name":"Scheduler Demo","icon":"dashboard","order":21,"disabled":false,"hidden":false}]

Rather than the rbe node behaving weirdly I think it much more likely that you were not sending it the data you thought, therefore replicating the the node in a function will not help. Go back and use debug nodes around the rbe to work out what is going on.

1 Like

After that, I am thinking the true and false are not helping. I've changed them to home and away.

I'll see if things change now.

If you have 2 states which are opposite then it does not matter how to call them. Home and away is same as true and false if they represent state of presence. That is nature of boolean.
Boolean should not be used if there is more than 2 possible states.

Yes, I agree. Originally it was only two states. But: me being me, I then complicated it with a third.

So I stuck the off into the equation.

I am suspicious that @Colin is hinting that the true/false message is messing with the RBE node/s.

Certainly not. I think it most unlikely that there is a problem with that node, but if there is then it is critical to find it and to get it fixed as it is relied on by many many flows and if there is a problem we need to know about it. The way to do that, as I said, is to put a debug node before and after it and identify the failing situation.

The thing is I can sit here until the cows come home and it works.

But then without warning, it stops.

I haven't changed anything. Then a bit later on, it starts working again.

In the test flow I have the time down to 10 seconds rather than a minute.

Putting debug nodes (and/or trigger nodes) are not showing things.

I shall have to really pick it apart.

Set the debug nodes to output to the console, and give them descriptive names, then when it goes wrong you can look back through the log and see exactly what happens.

Now I am forced to ask: where is this log?

I've never used it, so it is a bit confusing trying to find it.

I did a couple of quick tests with just an inject and debug node set to output to console.

But I can't find this output.

node-RED log?

node-red-log
or for longer history look in syslog (on linux). Don't know where the long term log is on Windows.
Or just start node-red in a terminal and leave it open.

Well, after some heavy thinking, I am now 98% sure it is working.

[{"id":"315225bf.0e0a62","type":"file in","z":"bb2e50af.775dd8","name":"Plants","filename":"","format":"utf8","chunk":false,"sendError":false,"encoding":"none","x":670,"y":2270,"wires":[["ad43e469.e10b48"]]},{"id":"ad43e469.e10b48","type":"ui_time_scheduler","z":"bb2e50af.775dd8","group":"ecb4a309.eff9c","name":"Plants","refresh":"5","devices":["ScheduleHome","ScheduleNotHome"],"customPayload":false,"eventMode":false,"outputs":3,"order":5,"width":"6","height":"1","x":850,"y":2270,"wires":[[],["dd599545.0ba668","239a03ee.298c5c","386c3d37.0d3d3a"],["dd599545.0ba668","3031f2c3.fae30e"]]},{"id":"ae40d4b2.fc7bc","type":"function","z":"bb2e50af.775dd8","name":"build message","func":"var path = global.get(\"event_paths\");\nmsg.filename = path + \"test.txt\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":495,"y":2270,"wires":[["315225bf.0e0a62"]]},{"id":"dd599545.0ba668","type":"link out","z":"bb2e50af.775dd8","name":"","links":["2d37930a.c1bf8c"],"x":1075,"y":2400,"wires":[]},{"id":"239a03ee.298c5c","type":"function","z":"bb2e50af.775dd8","name":"xRBE","func":"if (msg.payload == false)\n{\n    msg.payload = \"OFF\";\n} else\nmsg.payload = \"ON\";\n\nif (msg.reset == true)\n{\n    context.set(\"PREVIOUS\",0);\n    node.status({});\n    return;\n}\nvar previous = context.get(\"PREVIOUS\") || 0;\nvar incoming = msg.payload;\n\n//node.warn(\"Previous is \" + previous);\n//node.warn(\"Incoming is \" + incoming);\n\nif (incoming == previous)\n{\n    node.status({fill: \"red\"});\n    return;\n} else\ncontext.set(\"PREVIOUS\",msg.payload);\nnode.status({fill: \"gren\"});\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1110,"y":2270,"wires":[["1ef3281c.830028","dc1c770e.1e025"]]},{"id":"3031f2c3.fae30e","type":"function","z":"bb2e50af.775dd8","name":"xRBE","func":"if (msg.payload == false)\n{\n    msg.payload = \"OFF\";\n} else\nmsg.payload = \"ON\";\n\nif (msg.reset == true)\n{\n    context.set(\"PREVIOUS\",0);\n    node.status({});\n    return;\n}\nvar previous = context.get(\"PREVIOUS\") || 0;\nvar incoming = msg.payload;\n\n//node.warn(\"Previous is \" + previous);\n//node.warn(\"Incoming is \" + incoming);\n\nif (incoming == previous)\n{\n    node.status({fill: \"red\"});\n    return;\n} else\ncontext.set(\"PREVIOUS\",msg.payload);\nnode.status({fill: \"gren\"});\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1110,"y":2310,"wires":[["40ed06f1.341f18"]]},{"id":"386c3d37.0d3d3a","type":"trigger","z":"bb2e50af.775dd8","name":"CLOCK","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1120,"y":2200,"wires":[[]]},{"id":"249ffc69.998a8c","type":"inject","z":"bb2e50af.775dd8","name":"loadFileAfterReboot","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":290,"y":2270,"wires":[["ae40d4b2.fc7bc"]]},{"id":"1ef3281c.830028","type":"switch","z":"bb2e50af.775dd8","name":"atHome=home?","property":"atHome","propertyType":"flow","rules":[{"t":"eq","v":"home","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1320,"y":2270,"wires":[["673b2d.f14bc4d4","d0724347.466218"]]},{"id":"f94c9c1e.dfb07","type":"change","z":"bb2e50af.775dd8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1110,"y":2440,"wires":[["3c72089.3472578","7ed31be2.7746b4","3031f2c3.fae30e","239a03ee.298c5c"]]},{"id":"dc1c770e.1e025","type":"trigger","z":"bb2e50af.775dd8","name":"CLOCK","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1280,"y":2200,"wires":[[]]},{"id":"40ed06f1.341f18","type":"switch","z":"bb2e50af.775dd8","name":"atHome=away?","property":"atHome","propertyType":"flow","rules":[{"t":"eq","v":"away","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1320,"y":2310,"wires":[["641984a1.1354a4","b8f82aae.078f58"]]},{"id":"673b2d.f14bc4d4","type":"debug","z":"bb2e50af.775dd8","name":"HOME","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1740,"y":2200,"wires":[]},{"id":"d0724347.466218","type":"trigger","z":"bb2e50af.775dd8","name":"HOME","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1740,"y":2260,"wires":[[]]},{"id":"13c0a3bc.293c14","type":"switch","z":"bb2e50af.775dd8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":3,"x":690,"y":2530,"wires":[[],[],["f94c9c1e.dfb07","8db44b08.e8c148"]]},{"id":"3c72089.3472578","type":"rbe","z":"bb2e50af.775dd8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1230,"y":2620,"wires":[["d0724347.466218","673b2d.f14bc4d4"]]},{"id":"7ed31be2.7746b4","type":"rbe","z":"bb2e50af.775dd8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":1230,"y":2700,"wires":[["641984a1.1354a4","b8f82aae.078f58"]]},{"id":"d0bb0439.a72dd","type":"inject","z":"bb2e50af.775dd8","name":"Reset","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":850,"y":2440,"wires":[["f94c9c1e.dfb07"]]},{"id":"641984a1.1354a4","type":"trigger","z":"bb2e50af.775dd8","name":"AWAY","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1740,"y":2310,"wires":[[]]},{"id":"b8f82aae.078f58","type":"debug","z":"bb2e50af.775dd8","name":"AWAY","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1740,"y":2370,"wires":[]},{"id":"8db44b08.e8c148","type":"trigger","z":"bb2e50af.775dd8","name":"OFF","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1740,"y":2430,"wires":[[]]},{"id":"f29666d8.1fae8","type":"rbe","z":"bb2e50af.775dd8","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":510,"y":2530,"wires":[["13c0a3bc.293c14","9c576dbb.129e68"]]},{"id":"1b4144c4.5f2a83","type":"function","z":"bb2e50af.775dd8","name":"checkIfHome","func":"// THIS WILL ONLY SEND SOMETHING IF YOU ARE AT HOME\nif (flow.get(\"atHome\") === \"home\") return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":2620,"wires":[["3c72089.3472578"]]},{"id":"ab4796e3.76a5e8","type":"function","z":"bb2e50af.775dd8","name":"checkIfHome","func":"// THIS WILL ONLY SEND SOMETHING IF YOU ARE NOT AT HOME\nif (flow.get(\"atHome\") === \"away\") return msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":2700,"wires":[["7ed31be2.7746b4"]]},{"id":"c2ebe9e1.73b57","type":"change","z":"bb2e50af.775dd8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"atHome","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":2530,"wires":[["f29666d8.1fae8"]]},{"id":"9c576dbb.129e68","type":"trigger","z":"bb2e50af.775dd8","name":"CLOCK","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":520,"y":2570,"wires":[[]]},{"id":"2d37930a.c1bf8c","type":"link in","z":"bb2e50af.775dd8","name":"","links":["dd599545.0ba668","c348ffc7.10c17"],"x":215,"y":2530,"wires":[["c2ebe9e1.73b57","27a38849.419878"]]},{"id":"27a38849.419878","type":"trigger","z":"bb2e50af.775dd8","name":"CLOCK","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"900","extend":false,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":320,"y":2570,"wires":[[]]},{"id":"4b13bfcd.886ac8","type":"inject","z":"bb2e50af.775dd8","name":"HOME","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"home","payloadType":"str","x":340,"y":2350,"wires":[["5d95836a.1b91e4"]]},{"id":"9b229bc4.156228","type":"inject","z":"bb2e50af.775dd8","name":"AWAY","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"away","payloadType":"str","x":340,"y":2400,"wires":[["5d95836a.1b91e4"]]},{"id":"9436244b.5e6a38","type":"inject","z":"bb2e50af.775dd8","name":"OFF","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"off","payloadType":"str","x":340,"y":2450,"wires":[["5d95836a.1b91e4"]]},{"id":"5d95836a.1b91e4","type":"change","z":"bb2e50af.775dd8","name":"","rules":[{"t":"set","p":"atHome","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":2400,"wires":[[]]},{"id":"ecb4a309.eff9c","type":"ui_group","name":"TempDemo","tab":"2936b813.6cde68","order":4,"disp":true,"width":"8","collapse":false},{"id":"2936b813.6cde68","type":"ui_tab","name":"Scheduler Demo","icon":"dashboard","order":21,"disabled":false,"hidden":false}]

What was causing confusion is/was that the schedule node was sending out true and false messages.

When they got into the RBE node (either kind I am suspicious) it threw a wobbly.

Redesigning the flow slightly and the function node which I was using as a newer kind of RBE it is working.

The trick is this code in the function node:

//  This part makes all the difference.
if (msg.payload == false)
{
    msg.payload = "OFF";
} else
msg.payload = "ON";
//  END

if (msg.reset == true)
{
    context.set("PREVIOUS",0);
    node.status({});
    return;
}
var previous = context.get("PREVIOUS") || 0;
var incoming = msg.payload;

if (incoming == previous)
{
    node.status({fill: "red"});
    return;
} else
context.set("PREVIOUS",msg.payload);
node.status({fill: "gren"});
return msg;

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.