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 Triggered not activating #37

Closed sarreck closed 2 years ago

sarreck commented 2 years ago

I have a small test flow configured as pictured below. I am able to trigger a sensor, change and read state. However the "Alarm Triggered" node never activates. Screenshot 2022-05-08 152602

The Alarm Triggered node is configured as: image

The sensor and Alarm Triggered node are set to use the same panel. In this example the sensor is set to trigger in 'away' mode, however I have tried with all

There is no information in the node red logs or any debug output other than what is shown in the first image.

Node-RED is version - 2.2.2 node-red-contrib-alarm is version - 1.2.5

I am happy to provide any other information that is required to troubleshoot.

Thank you for your help and this great package

macinspak commented 2 years ago

Sorry for the delay getting back to you on this one. I've had a bit going on.

So it's puzzling, I've been trying to work out what may be wrong. I'll set up a similar flow to test, but can you also export your flow and attach here? Then I can also import that one in case I cannot reproduce. Also a good idea to store the test flow in the issue.

Thanks, Andrew

macinspak commented 2 years ago

Hmmm. I am unable to replicate. I just set up this test and it triggers perfectly. Note that trying to trigger twice will not work though, you need to change the alarm panel mode before it will trigger again.

Here's the initial mode set: Screen Shot 2022-05-17 at 4 15 58 pm

and here is after I trigger the sensor: Screen Shot 2022-05-17 at 4 16 11 pm

Can you please try again and export your flow?

sarreck commented 2 years ago

Thanks for looking into this.

I have included my flows below. Is it possible for you to also attach the test ones you have shown above so that I can see if its just an error on my part?

[ { "id": "e876b8ab35832dae", "type": "AnamicoAlarmSensor", "z": "806ac584249bdc6a", "name": "testSensor", "panel": "8b6addb6d72fdbd5", "alarmStates": "1", "triggerType": "1", "x": 2410, "y": 160, "wires": [] }, { "id": "21ca414d21ee61b3", "type": "AnamicoAlarmTriggered", "z": "806ac584249bdc6a", "name": "testalarm", "panel": "8b6addb6d72fdbd5", "delay": "5", "x": 2200, "y": 340, "wires": [ [ "9a1989cea2eb3ba1" ] ] }, { "id": "79985119c4c61843", "type": "AnamicoAlarmChangeState", "z": "806ac584249bdc6a", "name": "Change State", "panel": "8b6addb6d72fdbd5", "format": "2", "x": 2780, "y": 480, "wires": [] }, { "id": "a7654ae6a4d28ab6", "type": "switch", "z": "806ac584249bdc6a", "name": "Home Away Night Off", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "Home", "vt": "str" }, { "t": "eq", "v": "Away", "vt": "str" }, { "t": "eq", "v": "Night", "vt": "str" }, { "t": "eq", "v": "Off", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 4, "x": 2380, "y": 480, "wires": [ [ "4183483d3a76a559" ], [ "bc736861c0c79c84" ], [ "b132f74e1ebb4024" ], [ "62994874034fc16c" ] ] }, { "id": "4183483d3a76a559", "type": "template", "z": "806ac584249bdc6a", "name": "Home", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "0", "output": "str", "x": 2570, "y": 420, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "bc736861c0c79c84", "type": "template", "z": "806ac584249bdc6a", "name": "Away", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "1", "output": "str", "x": 2570, "y": 460, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "b132f74e1ebb4024", "type": "template", "z": "806ac584249bdc6a", "name": "Night", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "2", "output": "str", "x": 2570, "y": 500, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "62994874034fc16c", "type": "template", "z": "806ac584249bdc6a", "name": "Off", "field": "payload", "fieldType": "msg", "format": "handlebars", "syntax": "mustache", "template": "3", "output": "str", "x": 2570, "y": 540, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "a1eae8917763b0f0", "type": "inject", "z": "806ac584249bdc6a", "name": "open", "props": [ { "p": "payload.open", "v": "true", "vt": "bool" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "x": 2190, "y": 160, "wires": [ [ "e876b8ab35832dae", "aa4d50bff75ea7bb" ] ] }, { "id": "9a1989cea2eb3ba1", "type": "debug", "z": "806ac584249bdc6a", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 2430, "y": 340, "wires": [] }, { "id": "17d5c6f52313908b", "type": "AnamicoAlarmStateChanged", "z": "806ac584249bdc6a", "name": "test", "panel": "8b6addb6d72fdbd5", "format": "2", "sendInitialState": false, "x": 2190, "y": 280, "wires": [ [ "efc65c1c4c039832" ] ] }, { "id": "efc65c1c4c039832", "type": "debug", "z": "806ac584249bdc6a", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 2430, "y": 280, "wires": [] }, { "id": "aa4d50bff75ea7bb", "type": "debug", "z": "806ac584249bdc6a", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 2410, "y": 100, "wires": [] }, { "id": "afceeb36bd05801d", "type": "mqtt in", "z": "806ac584249bdc6a", "name": "", "topic": "alarm/state", "qos": "2", "datatype": "auto", "broker": "18fcde916a0f22ea", "nl": false, "rap": true, "rh": 0, "inputs": 0, "x": 2160, "y": 480, "wires": [ [ "a7654ae6a4d28ab6" ] ] }, { "id": "8b6addb6d72fdbd5", "type": "AnamicoAlarmPanel", "name": "TestPanel" }, { "id": "18fcde916a0f22ea", "type": "mqtt-broker", "name": "192.168.20.104", "broker": "192.168.20.104", "port": "1883", "clientid": "", "usetls": false, "protocolVersion": "4", "keepalive": "60", "cleansession": true, "birthTopic": "", "birthQos": "0", "birthPayload": "", "birthMsg": {}, "closeTopic": "", "closeQos": "0", "closePayload": "", "closeMsg": {}, "willTopic": "", "willQos": "0", "willPayload": "", "willMsg": {}, "sessionExpiry": "" } ]

macinspak commented 2 years ago

OK, I imported your flow and yours did not trigger

BUT, I checked your config for the sensor node and it was set to "Away" mode, so it would never trigger on "Home" mode. Screen Shot 2022-05-22 at 11 06 38 am

So I changed it to "Home" mode (with the panel still set to "Home"), and redeployed: Screen Shot 2022-05-22 at 11 06 44 am

and it triggers fine (as you would expect: Screen Shot 2022-05-22 at 11 08 42 am

Can you change the sensor configuration to the required trigger modes, deploy and test again?

Let me know either way, so I can close this ticket or investigate further.

sarreck commented 2 years ago

So I have changed the TestSensor from Away to home and deployed but I am still only getting a "trigger" on testSensor.

I have removed all nodes and re-imported the flow from above to make sure nothing has changed. I set the Panel to "Home" (via MQTT) and the panel shows the correct mode.

I then inject the Open message into the testSensor, it shows Trigger but nothing else.

image

Could this be an issue with my NodeRed version ( 2.2.2)? Is there a proven test flow I can import so that I can make sure its not just me doing something wrong?

Thanks for your help, I really appreciate it.

macinspak commented 2 years ago

Weird. Ok so I thought it was a misconfiguration, but maybe not.

I’ll try and check if something is related to that node version, and check which ones I’m running it on.

also, can you add an exception catch and debug the msg body for that to see if something is throwing an exception?

sarreck commented 2 years ago

Thanks

I have added an exception catch and I am not seeing any output image

I have also deleted everything and started again from scratch with the same result.

sarreck commented 2 years ago

I don't think these logs are relevant but I am adding just in case:

This is the nodered log when I send the MQTT message to update the Change State Node.

Triggering the sensor doesn't result in any logs.

22 May 19:10:49 - [info] [AnamicoAlarmChangeState:3e83e6c727506b0a] [object Object] 22 May 19:10:49 - [info] [AnamicoAlarmPanel:panel1] setState 22 May 19:10:49 - [info] [AnamicoAlarmPanel:panel1] {"topic": "alarm/state","payload": {"SecuritySystemTargetState": "0", "SecuritySystemCurrentState": "0","fromHomekit": false},"qos": 0,"retain": false,"_msgid": "5cc63b82fae4d8ae"} 22 May 19:10:49 - [info] [AnamicoAlarmPanel:panel1] newState: 0 = 0 || 0 22 May 19:10:49 - [info] [AnamicoAlarmPanel:panel1] localState: 0 22 May 19:10:49 - [info] [AnamicoAlarmPanel:panel1] alarmType: 0 = undefined || 0 22 May 19:10:49 - [info] [AnamicoAlarmPanel:panel1] alarmSource: undefined 22 May 19:10:49 - [info] [AnamicoAlarmPanel:panel1] local 22 May 19:10:49 - [info] [AnamicoAlarmStateChanged:49326feecc37546d] new State 22 May 19:10:49 - [info] [AnamicoAlarmStateChanged:49326feecc37546d] {"topic": "alarm/state","payload": {"SecuritySystemCurrentState": "0", "alarmState": "Home", "isAlarm": false}, "qos": 0, "retain": false, "_msgid": "5cc63b82fae4d8ae"}

I have had someone else test the flow in the previous message and they are having the same issues. They are also using NodeRed 2.2.2 in a docker environment.

macinspak commented 2 years ago

OK, so tested v0.19.5 Node-red on Docker, and v1.2.7 on linux. Maybe it is a version thing, I haven't had to update these nodes in a while as it's been working fine.

Can you try and run on a pre v2 node-red docker image just to be sure, and I'll try on a latest version.

macinspak commented 2 years ago

Aha! Worked it out.

Your flow is using strings, not numerics. For some reason the changing of the panel "seems" to work with strings, but the panel state string "0" then does not equal the alarm sensor mode numeric 0.

So switch your panel set nodes to set numeric 0, 1, 2 and 3 for the 4 modes and it should work fine.

I'll look at a fix later to make it catch that issue and report it properly. Maybe the node should say " is not a number" or something if you set value mode for the node and send it a string? What do you think?

macinspak commented 2 years ago

Please confirm this one works for you now:

[ { "id": "e876b8ab35832dae", "type": "AnamicoAlarmSensor", "z": "1de68baa3dd6d736", "name": "testSensor", "panel": "8b6addb6d72fdbd5", "alarmStates": [ "0", "1", "2" ], "triggerType": "1", "x": 630, "y": 240, "wires": [] }, { "id": "21ca414d21ee61b3", "type": "AnamicoAlarmTriggered", "z": "1de68baa3dd6d736", "name": "testalarm", "panel": "8b6addb6d72fdbd5", "delay": "5", "x": 420, "y": 420, "wires": [ [ "9a1989cea2eb3ba1" ] ] }, { "id": "79985119c4c61843", "type": "AnamicoAlarmChangeState", "z": "1de68baa3dd6d736", "name": "Change State", "panel": "8b6addb6d72fdbd5", "format": "2", "x": 1000, "y": 560, "wires": [] }, { "id": "a1eae8917763b0f0", "type": "inject", "z": "1de68baa3dd6d736", "name": "open", "props": [ { "p": "payload.open", "v": "true", "vt": "bool" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "x": 410, "y": 240, "wires": [ [ "e876b8ab35832dae", "aa4d50bff75ea7bb" ] ] }, { "id": "9a1989cea2eb3ba1", "type": "debug", "z": "1de68baa3dd6d736", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 650, "y": 420, "wires": [] }, { "id": "17d5c6f52313908b", "type": "AnamicoAlarmStateChanged", "z": "1de68baa3dd6d736", "name": "test", "panel": "8b6addb6d72fdbd5", "format": "2", "sendInitialState": false, "x": 410, "y": 360, "wires": [ [ "efc65c1c4c039832" ] ] }, { "id": "efc65c1c4c039832", "type": "debug", "z": "1de68baa3dd6d736", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 650, "y": 360, "wires": [] }, { "id": "aa4d50bff75ea7bb", "type": "debug", "z": "1de68baa3dd6d736", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "statusVal": "", "statusType": "auto", "x": 630, "y": 180, "wires": [] }, { "id": "01dbec3aa0428da1", "type": "inject", "z": "1de68baa3dd6d736", "name": "home", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "0", "payloadType": "num", "x": 610, "y": 500, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "fc7266f6bef50769", "type": "inject", "z": "1de68baa3dd6d736", "name": "away", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "1", "payloadType": "num", "x": 610, "y": 540, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "fbacde596285e0d1", "type": "inject", "z": "1de68baa3dd6d736", "name": "night", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "2", "payloadType": "num", "x": 610, "y": 580, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "e0bea128efe26856", "type": "inject", "z": "1de68baa3dd6d736", "name": "off", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "3", "payloadType": "num", "x": 610, "y": 620, "wires": [ [ "79985119c4c61843" ] ] }, { "id": "8b6addb6d72fdbd5", "type": "AnamicoAlarmPanel", "name": "TestPanel" } ]

sumnerboy12 commented 2 years ago

Bingo - I am the "someone else" that was verifying this issue with @sarreck. I just updated my test flow to use a numeric payload when setting the alarm state and now everything is working as expected - thank you very much for digging thru the code and figuring this one out!!

Fantastic little package you have developed here - can't wait to get it into production ;).

sumnerboy12 commented 2 years ago

One question - when the alarm is triggered and the delay expires, I am seeing the following payload on the AlarmTriggered node;

image

Should source be populated with something? I was expecting to see a reference to the sensor that triggered the alarm. Or is that only populated for HomeKit style integration?

sarreck commented 2 years ago

I can confirm that everything is working after changing from a string to a number

I am happy it was such a simple fix.

Thank you for your help and patience

macinspak commented 2 years ago

One question - when the alarm is triggered and the delay expires, I am seeing the following payload on the AlarmTriggered node;

image

Should source be populated with something? I was expecting to see a reference to the sensor that triggered the alarm. Or is that only populated for HomeKit style integration?

Hmm, yes it should. This was an extension someone submitted, so not sure why it doesn’t work with a delay node. I might be able to find some time in the next few weeks to look into it, as it is useful, but it should have the name of the trigger node in it I believe.

Thanks for reporting it.