-
Notifications
You must be signed in to change notification settings - Fork 4
Security System
cflurin edited this page Sep 3, 2018
·
10 revisions
A simple Security System
based on the dynamic state machine
:
- set all dsm's
- arm the security system
- try the sensor input simulation (magnet contact, button click)
- try disarm, reset
Note: The dsm properties can also be defined in the edit dsm node window, so you can remove the set
inject nodes
{
"triggerInput": "topic",
"stateOutput": "topic",
"currentState": "disarmed",
"states": {
"disarmed": {
"arm": "armed"
},
"armed": {
"disarm": "disarmed",
"open": "alarm_triggered"
},
"alarm_triggered": {
"disarm": "disarmed",
"reset": "armed"
}
}
}
{
"triggerInput": "topic",
"stateOutput": "topic",
"currentState": "disarmed",
"states": {
"disarmed": {
"arm": "armed"
},
"armed": {
"disarm": "disarmed",
"click": "alarm_triggered"
},
"alarm_triggered": {
"disarm": "disarmed",
"reset": "armed"
}
}
}
{
"triggerInput": "topic",
"stateOutput": "topic",
"currentState": "disarmed",
"states": {
"disarmed": {
"arm": "armed"
},
"armed": {
"disarm": "disarmed",
"alarm_triggered": "master_alarm"
},
"master_alarm": {
"disarm": "disarmed",
"reset": "armed"
}
}
}
[{"id":"27a9cc09.95f174","type":"dsm","z":"d0877ed4.9e0cc","name":"security_system","x":360,"y":3800,"wires":[[]]},{"id":"fac1e2fe.22fff","type":"inject","z":"d0877ed4.9e0cc","name":"set","topic":"set","payload":"{\"triggerInput\":\"topic\",\"stateOutput\":\"topic\",\"currentState\":\"disarmed\",\"states\":{\"disarmed\":{\"arm\":\"armed\"},\"armed\":{\"disarm\":\"disarmed\",\"alarm_triggered\":\"master_alarm\"},\"master_alarm\":{\"disarm\":\"disarmed\",\"reset\":\"armed\"}}}","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":3760,"wires":[["27a9cc09.95f174"]]},{"id":"7d40b564.9a0f6c","type":"link in","z":"d0877ed4.9e0cc","name":"to open alarm","links":["670d642e.b859bc","6f236bb5.7706c4","7c8dbc65.baaf54","b912b6d6.a75bd8"],"x":215,"y":3600,"wires":[["29d8b56e.a1ec6a"]]},{"id":"47ca850d.42d9cc","type":"inject","z":"d0877ed4.9e0cc","name":"disarm","topic":"disarm","payload":"{\"name\":\"security_system\",\"characteristic\":\"On\",\"value\":false}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":3460,"wires":[["b912b6d6.a75bd8"]]},{"id":"876269fb.34a4c8","type":"inject","z":"d0877ed4.9e0cc","name":"arm","topic":"arm","payload":"{\"name\":\"security_system\",\"characteristic\":\"On\",\"value\":true}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":3400,"wires":[["37213a57.4709a6"]]},{"id":"29d8b56e.a1ec6a","type":"dsm","z":"d0877ed4.9e0cc","name":"open alarm","x":350,"y":3600,"wires":[["4f2cfa49.8c54c4","cd96a8ad.e28378"]]},{"id":"f5697bd3.69b958","type":"inject","z":"d0877ed4.9e0cc","name":"set","topic":"set","payload":"{\"triggerInput\":\"topic\",\"stateOutput\":\"topic\",\"currentState\":\"disarmed\",\"states\":{\"disarmed\":{\"arm\":\"armed\"},\"armed\":{\"disarm\":\"disarmed\",\"open\":\"alarm_triggered\"},\"alarm_triggered\":{\"disarm\":\"disarmed\",\"reset\":\"armed\"}}}","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":3560,"wires":[["29d8b56e.a1ec6a"]]},{"id":"4f2cfa49.8c54c4","type":"debug","z":"d0877ed4.9e0cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":3600,"wires":[]},{"id":"b749944b.a30798","type":"link in","z":"d0877ed4.9e0cc","name":"to click alarm","links":["670d642e.b859bc","6f236bb5.7706c4","b912b6d6.a75bd8","f1f643db.de23f"],"x":215,"y":3700,"wires":[["1ac41cc2.04a2f3"]]},{"id":"1ac41cc2.04a2f3","type":"dsm","z":"d0877ed4.9e0cc","name":"click alarm","x":350,"y":3700,"wires":[["ee7310e7.5e16c","83ee0e1a.81cdd"]]},{"id":"aa551f89.d396b","type":"inject","z":"d0877ed4.9e0cc","name":"set","topic":"set","payload":"{\"triggerInput\":\"topic\",\"stateOutput\":\"topic\",\"currentState\":\"disarmed\",\"states\":{\"disarmed\":{\"arm\":\"armed\"},\"armed\":{\"disarm\":\"disarmed\",\"click\":\"alarm_triggered\"},\"alarm_triggered\":{\"disarm\":\"disarmed\",\"reset\":\"armed\"}}}","payloadType":"json","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":170,"y":3660,"wires":[["1ac41cc2.04a2f3"]]},{"id":"ee7310e7.5e16c","type":"debug","z":"d0877ed4.9e0cc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":3700,"wires":[]},{"id":"6f236bb5.7706c4","type":"link out","z":"d0877ed4.9e0cc","name":"from arm","links":["7d40b564.9a0f6c","b749944b.a30798","117b4cde.cd0523"],"x":375,"y":3400,"wires":[]},{"id":"b912b6d6.a75bd8","type":"link out","z":"d0877ed4.9e0cc","name":"from disarm","links":["7d40b564.9a0f6c","b749944b.a30798","117b4cde.cd0523"],"x":215,"y":3460,"wires":[]},{"id":"117b4cde.cd0523","type":"link in","z":"d0877ed4.9e0cc","name":"to security system","links":["6f236bb5.7706c4","b912b6d6.a75bd8","670d642e.b859bc","cd96a8ad.e28378","83ee0e1a.81cdd"],"x":215,"y":3800,"wires":[["27a9cc09.95f174"]]},{"id":"e176f395.dabb9","type":"inject","z":"d0877ed4.9e0cc","name":"reset","topic":"reset","payload":"{\"name\":\"security_system\",\"characteristic\":\"On\",\"value\":\"reset\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":3500,"wires":[["670d642e.b859bc"]]},{"id":"670d642e.b859bc","type":"link out","z":"d0877ed4.9e0cc","name":"from reset","links":["117b4cde.cd0523","7d40b564.9a0f6c","b749944b.a30798"],"x":215,"y":3500,"wires":[]},{"id":"37213a57.4709a6","type":"delay","z":"d0877ed4.9e0cc","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":260,"y":3400,"wires":[["6f236bb5.7706c4"]]},{"id":"336b0377.eb14ec","type":"comment","z":"d0877ed4.9e0cc","name":"Security System _____________________________________________________________","info":"","x":340,"y":3360,"wires":[]},{"id":"cd96a8ad.e28378","type":"link out","z":"d0877ed4.9e0cc","name":"from open alarm","links":["117b4cde.cd0523"],"x":515,"y":3640,"wires":[]},{"id":"83ee0e1a.81cdd","type":"link out","z":"d0877ed4.9e0cc","name":"fromc lick alarm","links":["117b4cde.cd0523"],"x":515,"y":3740,"wires":[]},{"id":"85c67fda.baba","type":"comment","z":"d0877ed4.9e0cc","name":"send a notification e.g to pushover","info":"","x":700,"y":3640,"wires":[]},{"id":"1184d16c.1cefcf","type":"inject","z":"d0877ed4.9e0cc","name":"button click","topic":"click","payload":"{\"name\":\"button\",\"characteristic\":\"On\",\"value\":\"click\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":530,"y":3500,"wires":[["f1f643db.de23f"]]},{"id":"b4295751.e58198","type":"comment","z":"d0877ed4.9e0cc","name":"Sensor input simulation","info":"","x":540,"y":3420,"wires":[]},{"id":"f1f643db.de23f","type":"link out","z":"d0877ed4.9e0cc","name":"from button click","links":["b749944b.a30798"],"x":675,"y":3500,"wires":[]},{"id":"2aacc2a7.4289ce","type":"inject","z":"d0877ed4.9e0cc","name":"magnet contact","topic":"open","payload":"{\"name\":\"garden door\",\"characteristic\":\"ContactSensorState\",\"value\":\"open\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":540,"y":3460,"wires":[["7c8dbc65.baaf54"]]},{"id":"7c8dbc65.baaf54","type":"link out","z":"d0877ed4.9e0cc","name":"from magnet contact","links":["7d40b564.9a0f6c"],"x":675,"y":3460,"wires":[]},{"id":"11a0b0bd.00cd5f","type":"comment","z":"d0877ed4.9e0cc","name":"send a notification e.g to pushover","info":"","x":700,"y":3740,"wires":[]}]