Anamico / node-red-contrib-alarm

Nodes to build your own home alarm system. Designed to work easily with (but does not require) homekit.
MIT License
24 stars 8 forks source link

Alarm Triggered Node does not forward msg content from Alarm Sensor Node #7

Closed Vermatic closed 5 years ago

Vermatic commented 5 years ago

Please check out the following sample flow.

The 2 triggers to the 2 Alarm Sensor Nodes set different msg.name.

This information is forwarded by the Alarm Changed Node correctly, the msg.name stays intact.

However this information is lost by the Alarm Triggered Node, it does not include the msg.name any more.

[{"id":"6fae9bf8.a4959c","type":"tab","label":"Alarm","disabled":false,"info":""},{"id":"8bd5b109.2dc0f","type":"AnamicoAlarmSensor","z":"6fae9bf8.a4959c","name":"Sensor 1","panel":"abd3ea6.4f26698","alarmStates":"1","x":480,"y":140,"wires":[]},{"id":"4805869f.3a2d28","type":"AnamicoAlarmChangeState","z":"6fae9bf8.a4959c","name":"","panel":"abd3ea6.4f26698","format":"2","x":399,"y":304,"wires":[]},{"id":"9378f121.974468","type":"inject","z":"6fae9bf8.a4959c","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["fe178b42.b889a"]]},{"id":"fb03b1ce.a8ad7","type":"AnamicoAlarmSensor","z":"6fae9bf8.a4959c","name":"Sensor 2","panel":"abd3ea6.4f26698","alarmStates":"1","x":480,"y":200,"wires":[]},{"id":"74ecf1d4.f09bf","type":"inject","z":"6fae9bf8.a4959c","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":200,"wires":[["b83332d4.53344"]]},{"id":"47d30035.686a9","type":"inject","z":"6fae9bf8.a4959c","name":"Arm","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":203,"y":279,"wires":[["4805869f.3a2d28"]]},{"id":"9e213fcf.2d453","type":"inject","z":"6fae9bf8.a4959c","name":"Disarm","topic":"","payload":"3","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":203,"y":319,"wires":[["4805869f.3a2d28"]]},{"id":"b30636c6.1f1878","type":"debug","z":"6fae9bf8.a4959c","name":"Alarm received","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":905,"y":142,"wires":[]},{"id":"44795cad.729c0c","type":"debug","z":"6fae9bf8.a4959c","name":"State Changed","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":905,"y":202,"wires":[]},{"id":"55bf04cf.cc3714","type":"AnamicoAlarmTriggered","z":"6fae9bf8.a4959c","name":"","panel":"abd3ea6.4f26698","delay":"2","x":735,"y":142,"wires":[["b30636c6.1f1878"]]},{"id":"89f9fd41.39c458","type":"AnamicoAlarmStateChanged","z":"6fae9bf8.a4959c","name":"State Changed","panel":"abd3ea6.4f26698","format":"2","sendInitialState":1,"x":705,"y":202,"wires":[["44795cad.729c0c"]]},{"id":"fe178b42.b889a","type":"change","z":"6fae9bf8.a4959c","name":"","rules":[{"t":"set","p":"name","pt":"msg","to":"Sensor 1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":140,"wires":[["8bd5b109.2dc0f"]]},{"id":"b83332d4.53344","type":"change","z":"6fae9bf8.a4959c","name":"","rules":[{"t":"set","p":"name","pt":"msg","to":"Sensor 2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":200,"wires":[["fb03b1ce.a8ad7"]]},{"id":"abd3ea6.4f26698","type":"AnamicoAlarmPanel","z":"","name":"AlarmPanel"}]

macinspak commented 5 years ago

Thanks, the original intention was to just trigger a new message after the delay.

So if you had a 10 second delay, but the node received 5 messages in that time as various alarms, this node was only intended to "trigger" the siren. If it needed to include any components of the 5 messages it received to cause the alarm, which msg.name should it use? the one from the 1st or second message? Or the last one?

For example, a burglar trips the door sensor, then the hall sensor and then the back door sensor. Which "name" should be sent after the 10 second delay?

I could have it perhaps cache the initial message or just use the latest one?

What is the use case you are trying to set up?

Vermatic commented 5 years ago

Thanks for the clarification. I think I got the intention wrong then.

I actually wired my whole alarm notification mechanism (including sending e-mail etc.) to the Alarm Triggered Node, because I thought that this was the right thing to do.

No I understand that it makes more sense to wire it to Alarm Changed Node instead, because it already carries the information I am looking for.