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 9 forks source link

Alarm Triggerd Node with delay leads to restart of node red #18

Open Blomus opened 3 years ago

Blomus commented 3 years ago

If I put an Alarm Triggerd Node with delay node red will be restarted after the delay has counted down. Due to the restart the State ist changed to home. A Alarm Triggered Node without delay works without problems.

Could you please check this?

macinspak commented 3 years ago

Can you post your flow here?

On Sun, 31 Jan 2021 at 10:28 pm, Blomus notifications@github.com wrote:

If I put an Alarm Triggerd Node with delay node red will be restarted after the delay has counted down. Due to the restart the State ist changed to home. A Alarm Triggered Node without delay works without problems.

Could you please check this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Anamico/node-red-contrib-alarm/issues/18, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHK2LGDB452ET6ZZKH2CSDS4VEHTANCNFSM4W3J2UVQ .

Blomus commented 3 years ago

[{"id":"4300689a.44214","type":"tab","label":"Alarm","disabled":false,"info":""},{"id":"fcc6eb2b.d1a8f","type":"homekit-service","z":"4300689a.44214","isParent":true,"bridge":"22213919.256466","parentService":"","name":"Security","serviceName":"SecuritySystem","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","firmwareRev":"","hardwareRev":"","softwareRev":"","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":440,"y":80,"wires":[["9990fd5e.a9db98"],[]]},{"id":"3aaee5b4.52a6b2","type":"function","z":"4300689a.44214","name":"Abwesend","func":"msg.payload = {SecuritySystemTargetState:1};\nmsg.hap = {\"oldValue\":0,\"newValue\":1};\nmsg.name =\"Security\";\nreturn msg","outputs":1,"noerr":0,"x":350,"y":220,"wires":[["fcc6eb2b.d1a8f","fac65ffd.2fae1"]]},{"id":"ea46834a.b127e","type":"inject","z":"4300689a.44214","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":160,"y":180,"wires":[["d69976a5.448dc"]]},{"id":"192d6ac7.08c3ed","type":"function","z":"4300689a.44214","name":"Nacht","func":"msg.payload = {SecuritySystemCurrentState:2};\nreturn msg","outputs":1,"noerr":0,"x":330,"y":260,"wires":[["fcc6eb2b.d1a8f","d9982441.6b64e8"]]},{"id":"d69976a5.448dc","type":"function","z":"4300689a.44214","name":"Zuhause","func":"msg.payload = {SecuritySystemTargetState:0};\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":180,"wires":[["fcc6eb2b.d1a8f","2ff5ebbe.4278bc"]]},{"id":"e24f4efc.655f58","type":"function","z":"4300689a.44214","name":"Aus","func":"msg.payload = {SecuritySystemCurrentState:3};\nreturn msg","outputs":1,"noerr":0,"x":330,"y":300,"wires":[["fcc6eb2b.d1a8f","e101129a.d69348"]]},{"id":"ec433959.8a1228","type":"inject","z":"4300689a.44214","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":220,"wires":[["3aaee5b4.52a6b2"]]},{"id":"9e1130f.d3055d","type":"inject","z":"4300689a.44214","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":260,"wires":[["192d6ac7.08c3ed"]]},{"id":"5edec50d.c845fc","type":"inject","z":"4300689a.44214","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":300,"wires":[["e24f4efc.655f58"]]},{"id":"82a8ea88.e16418","type":"function","z":"4300689a.44214","name":"Sonso Ansage Bewebung erkannt","func":"msg.payload = \"http://localhost:5005/Büro/say/Bewegung erkannt/de-de\";\n\n\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":760,"wires":[["39dde9a4.54669e"]]},{"id":"39dde9a4.54669e","type":"change","z":"4300689a.44214","name":"Url","rules":[{"t":"set","p":"method","pt":"msg","to":"GET","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":760,"wires":[["9427bc66.690fc8"]]},{"id":"9427bc66.690fc8","type":"http request","z":"4300689a.44214","name":"vor","method":"use","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":690,"y":760,"wires":[[]]},{"id":"72212f71.2f151","type":"inject","z":"4300689a.44214","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":700,"wires":[["82a8ea88.e16418"]]},{"id":"ffe3e5ac.fd3658","type":"AnamicoAlarmStateChanged","z":"4300689a.44214","name":"State Changed","panel":"f992f290.87311","format":"1","sendInitialState":1,"x":140,"y":60,"wires":[["fcc6eb2b.d1a8f"]]},{"id":"9e6bc6d2.471da8","type":"AnamicoAlarmSensor","z":"4300689a.44214","name":"Alarm Away","panel":"f992f290.87311","alarmStates":["1"],"triggerType":"1","x":770,"y":520,"wires":[]},{"id":"8c743475.05a4c","type":"hue-motion","z":"4300689a.44214","name":"Sensor Bad","bridge":"b8598d96.8cc6a","sensorid":"21","skipevents":false,"x":150,"y":520,"wires":[["a78aec81.9474d"]]},{"id":"4b6265e.a66171c","type":"AnamicoAlarmTriggered","z":"4300689a.44214","name":"Alarm","panel":"f992f290.87311","delay":"","x":150,"y":1020,"wires":[["54303c26.01b8cc"]]},{"id":"54303c26.01b8cc","type":"debug","z":"4300689a.44214","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":310,"y":1020,"wires":[]},{"id":"3fed098b.158316","type":"homekit-service","z":"4300689a.44214","isParent":true,"bridge":"22213919.256466","parentService":"","name":"Bewegung Flur","serviceName":"Switch","topic":"","filter":false,"manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","firmwareRev":"","hardwareRev":"","softwareRev":"","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"x":160,"y":580,"wires":[["36eb44ce.70ef2c"],[]]},{"id":"36eb44ce.70ef2c","type":"switch","z":"4300689a.44214","name":"True","property":"payload.On","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":330,"y":580,"wires":[["9e6bc6d2.471da8"]]},{"id":"2ff5ebbe.4278bc","type":"trigger","z":"4300689a.44214","op1":"{\"SecuritySystemTargetState\":0}","op2":"{\"SecuritySystemCurrentState\":0}","op1type":"json","op2type":"json","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"Home delay","x":510,"y":180,"wires":[["8291c258.c9724"]]},{"id":"8291c258.c9724","type":"AnamicoAlarmChangeState","z":"4300689a.44214","name":"Change State","panel":"f992f290.87311","format":"0","x":740,"y":320,"wires":[]},{"id":"fac65ffd.2fae1","type":"trigger","z":"4300689a.44214","op1":"{\"SecuritySystemTargetState\":1}","op2":"{\"SecuritySystemCurrentState\":1}","op1type":"json","op2type":"json","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"Away delay","x":510,"y":220,"wires":[["8291c258.c9724"]]},{"id":"d9982441.6b64e8","type":"trigger","z":"4300689a.44214","op1":"{\"SecuritySystemTargetState\":2}","op2":"{\"SecuritySystemCurrentState\":2}","op1type":"json","op2type":"json","duration":"2","extend":false,"units":"s","reset":"","bytopic":"all","name":"Night delay","x":510,"y":260,"wires":[["8291c258.c9724"]]},{"id":"e101129a.d69348","type":"trigger","z":"4300689a.44214","op1":"{\"SecuritySystemTargetState\":3}","op2":"{\"SecuritySystemCurrentState\":3}","op1type":"json","op2type":"json","duration":"500","extend":false,"units":"ms","reset":"","bytopic":"all","name":"Off delay","x":500,"y":300,"wires":[["8291c258.c9724"]]},{"id":"9990fd5e.a9db98","type":"AnamicoAlarmChangeState","z":"4300689a.44214","name":"Change State","panel":"f992f290.87311","format":"1","x":700,"y":40,"wires":[]},{"id":"10ebf8a9.945def","type":"AnamicoAlarmSensor","z":"4300689a.44214","name":"Alarm Night","panel":"f992f290.87311","alarmStates":["2"],"triggerType":"1","x":770,"y":580,"wires":[]},{"id":"810d1c84.47595","type":"AnamicoAlarmTriggered","z":"4300689a.44214","name":"No delay","panel":"f992f290.87311","delay":"","x":120,"y":760,"wires":[["82a8ea88.e16418"]]},{"id":"d50fbe2.643154","type":"link in","z":"4300689a.44214","name":"","links":["27da4407.48126c"],"x":115,"y":120,"wires":[[]]},{"id":"4a92a196.fa1238","type":"function","z":"4300689a.44214","name":"Sonso Ansage Alarm","func":"msg.payload = \"http://localhost:5005/Büro/say/Alarm wurde ausgelöst/de-de\";\n\n\nreturn msg;","outputs":1,"noerr":0,"x":360,"y":860,"wires":[["5ea38b5f.a5433c"]]},{"id":"5ea38b5f.a5433c","type":"change","z":"4300689a.44214","name":"Url","rules":[{"t":"set","p":"method","pt":"msg","to":"GET","tot":"str"},{"t":"set","p":"url","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":860,"wires":[["bea9b7fb.371e7"]]},{"id":"bea9b7fb.371e7","type":"http request","z":"4300689a.44214","name":"vor","method":"use","ret":"txt","paytoqs":false,"url":"","tls":"","persist":false,"proxy":"","authType":"","x":730,"y":860,"wires":[[]]},{"id":"a78aec81.9474d","type":"function","z":"4300689a.44214","name":"Motion2open","func":"msg.payload.open = msg.payload.motion;\nreturn msg; \n","outputs":1,"noerr":0,"x":390,"y":520,"wires":[["d77f608.017692"]]},{"id":"d77f608.017692","type":"switch","z":"4300689a.44214","name":"True","property":"payload.open","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":520,"wires":[["9e6bc6d2.471da8"]]},{"id":"e615e432.586948","type":"AnamicoAlarmTriggered","z":"4300689a.44214","name":"15 sec delay","panel":"f992f290.87311","delay":"15","x":130,"y":860,"wires":[["4a92a196.fa1238"]]},{"id":"22213919.256466","type":"homekit-bridge","z":"","bridgeName":"HomePilot","pinCode":"111-11-111","port":"","allowInsecureRequest":false,"manufacturer":"NRCHKB","model":"1.2.0","serialNo":"Default Serial Number","firmwareRev":"1.2.0","hardwareRev":"1.2.0","softwareRev":"1.2.0","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true},{"id":"f992f290.87311","type":"AnamicoAlarmPanel","z":"","name":"Alarm"},{"id":"b8598d96.8cc6a","type":"hue-bridge","z":"","name":"Philips hue","bridge":"192.168.1.105","key":"ClqSAnS4lHdqf13JfmVpsVWAETyE54yBtvUViXfu","interval":"3000","disableupdates":false}]

macinspak commented 3 years ago

Sorry about the delay, a busy week this week. Can you get a hold of the logs and see any crash details to post here? Or can you start nodered interactive and reproduce the issue. Want to make sure it's working for all cases, so motivated to help.

Blomus commented 3 years ago

Hi Macinspak,

attached you'll find my logs:

6 Feb 10:19:48 - [info] [AnamicoAlarmSensor:Alarm Away] triggered:true 6 Feb 10:19:48 - [info] [AnamicoAlarmChangeState:Change State] [object Object] (node:1740) UnhandledPromiseRejectionWarning: Error: Huejay: timeout of 15000ms exceeded at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15 at processTicksAndRejections (internal/process/task_queues.js:97:5) at runNextTicks (internal/process/task_queues.js:66:3) at listOnTimeout (internal/timers.js:518:9) at processTimers (internal/timers.js:492:7) (node:1740) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 79) (node:1740) UnhandledPromiseRejectionWarning: Error: Huejay: timeout of 15000ms exceeded at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15 at processTicksAndRejections (internal/process/task_queues.js:97:5) at runNextTicks (internal/process/task_queues.js:66:3) at listOnTimeout (internal/timers.js:518:9) at processTimers (internal/timers.js:492:7) (node:1740) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 81) (node:1740) UnhandledPromiseRejectionWarning: Error: Huejay: timeout of 15000ms exceeded at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15 at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:1740) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 83) 6 Feb 10:20:03 - [red] Uncaught Exception: 6 Feb 10:20:03 - TypeError: Cannot read property 'payload' of undefined at Timeout.emitAlarm [as _onTimeout] (/home/pi/.node-red/node_modules/node-red-contrib-alarm/alarm/triggered.js:41:69) at listOnTimeout (internal/timers.js:549:17) at processTimers (internal/timers.js:492:7) nodered.service: Main process exited, code=exited, status=1/FAILURE nodered.service: Failed with result 'exit-code'. nodered.service: Service RestartSec=100ms expired, scheduling restart. nodered.service: Scheduled restart job, restart counter is at 3. Stopped Node-RED graphical event wiring tool. Started Node-RED graphical event wiring tool. 6 Feb 10:20:05 - [info] Willkommen bei Node-RED!

6 Feb 10:20:05 - [info] Node-RED Version: v1.0.6 6 Feb 10:20:05 - [info] Node.js Version: v12.17.0 6 Feb 10:20:05 - [info] Linux 4.19.118-v7l+ arm LE 6 Feb 10:20:06 - [info] Paletten-Nodes werden geladen

macinspak commented 3 years ago

Please try with version 1.2.2

Blomus commented 3 years ago

I have updated to 1.2.2 but there is the AnamicoAlarmTriggered Node missing. Could you please check this?

macinspak commented 3 years ago

Really sorry about that, typo slipped through. Try 1.2.4 and let me know how you go.

This is a patch fix to stop a crash, but it may not always report the alarm source on a delayed trigger.

macinspak commented 3 years ago

@webfrank can you please look at this? It seems to happen due to the trigger source payload you added, when the trigger fires after a delay, the lastMsg node attribute is potentially missing (not populated on the initial trigger call?).

1.2.4 masks the problem by committing the trigger source if null. But it should be there on a delayed trigger most people would assume I think. Thanks

Blomus commented 3 years ago

Version 1.2.4 works very well and you're right, the alarm source is missing in the delayed trigger.

sumnerboy12 commented 2 years ago

The missing source in the delayed trigger has been fixed in #39 (pending merge).