I have a flow where I monitor the ONLINE status of a device, I would like to be informed of the occasion that the thermostat is OFFLINE and act upon that status in another flow
NR receives a JSON from the google API, the response is set to a Global context value:
With the result in the context view:
Looks ok?
Then that value is injected every 5 minutes to another flow, to act on the status:
[{"id":"19ce323c.e5c9ae","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"9a8ecb6d.3dfe28","type":"inject","z":"19ce323c.e5c9ae","name":"","props":[{"p":"payload.living.status","v":"living.status","vt":"global"}],"repeat":"300","crontab":"","once":true,"onceDelay":"20","topic":"","payloadType":"str","x":150,"y":280,"wires":[["4c3fb2eb.153b1c","a381d841.df3f48"]]},{"id":"a381d841.df3f48","type":"debug","z":"19ce323c.e5c9ae","name":"living status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":400,"y":200,"wires":[]},{"id":"4c3fb2eb.153b1c","type":"rbe","z":"19ce323c.e5c9ae","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload.living.status","x":370,"y":280,"wires":[["184ffa4e.75a186","2342d694.542a5a"]]},{"id":"72b6af3a.9eae","type":"comment","z":"19ce323c.e5c9ae","name":"Thermostat living online check, set failsafe","info":"","x":240,"y":240,"wires":[]},{"id":"184ffa4e.75a186","type":"switch","z":"19ce323c.e5c9ae","name":"Living online","property":"payload.living.status","propertyType":"msg","rules":[{"t":"eq","v":"ONLINE","vt":"str"},{"t":"eq","v":"OFFLINE","vt":"str"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":550,"y":280,"wires":[["c1ffb1f6.23019"],["e88f5414.7bf4d8"],["fe2d01ae.bdb49"]]},{"id":"2342d694.542a5a","type":"debug","z":"19ce323c.e5c9ae","name":"living status RBE","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":630,"y":200,"wires":[]},{"id":"c1ffb1f6.23019","type":"change","z":"19ce323c.e5c9ae","name":"online","rules":[{"t":"set","p":"payload.chatId","pt":"msg","to":"chatid","tot":"num"},{"t":"set","p":"payload.type","pt":"msg","to":"message","tot":"str"},{"t":"set","p":"payload.content","pt":"msg","to":"Living thermostat online","tot":"str"},{"t":"set","p":"living.failsafe","pt":"global","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":240,"wires":[["15e1986c.9c9738","ef0efb43.3a45e8"]]},{"id":"e88f5414.7bf4d8","type":"change","z":"19ce323c.e5c9ae","name":"offline","rules":[{"t":"set","p":"payload.chatId","pt":"msg","to":"chatid","tot":"num"},{"t":"set","p":"payload.type","pt":"msg","to":"message","tot":"str"},{"t":"set","p":"payload.content","pt":"msg","to":"Living thermostat offline","tot":"str"},{"t":"set","p":"living.failsafe","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":280,"wires":[["15e1986c.9c9738","cf364f61.9f59b"]]},{"id":"fe2d01ae.bdb49","type":"change","z":"19ce323c.e5c9ae","name":"other","rules":[{"t":"set","p":"payload.chatId","pt":"msg","to":"chatid","tot":"num"},{"t":"set","p":"payload.type","pt":"msg","to":"message","tot":"str"},{"t":"set","p":"payload.content","pt":"msg","to":"Living thermostat otherwise","tot":"str"},{"t":"set","p":"living.failsafe","pt":"global","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":320,"wires":[["15e1986c.9c9738","81ac392e.9b23b8"]]},{"id":"81ac392e.9b23b8","type":"debug","z":"19ce323c.e5c9ae","name":"other","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":320,"wires":[]},{"id":"cf364f61.9f59b","type":"debug","z":"19ce323c.e5c9ae","name":"offline","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":280,"wires":[]},{"id":"ef0efb43.3a45e8","type":"debug","z":"19ce323c.e5c9ae","name":"online","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":950,"y":240,"wires":[]},{"id":"15e1986c.9c9738","type":"telegram sender","z":"19ce323c.e5c9ae","name":"Catch","bot":"f0af1e3f.3cb23","x":950,"y":360,"wires":[[]]},{"id":"f0af1e3f.3cb23","type":"telegram bot","botname":"Home_bot","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"60000","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]
I've set a RBE after the inject, because I only want to receive a msg when the status has changed.
Living status debug:
{"living":{"status":"ONLINE"}}
So far so good, thermostat is ONLINE (checked that in the global context) both debug living status and living status RBE give the expected result: every 5 min a message in the debug living status, and nothing in the living status RBE.
Then the evaluation of the msg.payload.living.status that has been injected:
msg.payload.content of the 3 change nodes on port 1,2,3 is online, offline and otherwise.
After deploy, I get an ONLINE message, that's good.
22/11/2020, 19:52:56node: living status
msg.payload : Object
{ living: object }
22/11/2020, 19:52:56node: living status RBE
msg.payload : Object
object
living: object
status: "ONLINE"
22/11/2020, 19:52:56node: online
msg.payload : Object
object
living: object
chatId: 1311535761
type: "message"
content: "Living thermostat online"
22/11/2020, 19:52:57node: living status
msg.payload : Object
object
living: object
status: "ONLINE"
Injecting numerous times, no message. Looks like RBE is working ok.
But after some minutes and then every 5 minutes, an OFFLINE message is received, the message does not leave a trace in the RBE debug node, nor in the offline debug node.
I am puzzled...