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

add defaultState option to set a fallback alarm panel state #22

Open cupracer opened 3 years ago

cupracer commented 3 years ago

The alarm panel defaults to a hard-coded 0 state ("Home" mode), which immediately would result in an alarm after restarting Node-RED in case a "Home"-sensor triggers at this time.

I would like to avoid enabling the default use of persistent storage for global context variables. It would be sufficient for my environment to just start with a disabled alarm panel (state 3) instead of "Home"-mode (state 0).

To achieve this I extended the code to have a default/fallback state configurable instead of having it hard-coded to 0. It would be used whenever Node-RED is started without an existing global 'SecuritySystemCurrentState_' + node.nodeId variable.

This defaultState option as well defaults to 0, so it shouldn't disturb existing setups.

Note: For quite better solution to address this topic see #23 .