I’d like to make my smart home system as follows:
The node red system would basically be divided into 7 physical subflow parts:
I. database (sqlite or mysql) management:
- current / daily / annual status of the device (status, event, action)
- device configuration
- error, warning
II. system startup (rpi start, deploy)
- Load devices configuration data and devices last status from database. Setting the state (according to what is loaded from the configuration database) on the output devices (previous state, specified state, state in progress at shutdown, etc.…)
- here I would set the dynamic ‘topic link in’ topic name (from the configuration database) which node is in the event handler subflow).
III. power failure management
In the event of a power failure (certainly rpi is on UPS, but it monitors the power failure), the process is like the previous point for each output device depending on the configuration database (eg. the garage door is closing when a power failure happens. After switching the power back on, based on the configuration database, either the closing will continue (closing command), or it will not do anything or it will is go to a basic state (open / close)
IV. Voice Control
- Amazon Alexa
- Siri
- Android
V. Notification
- E-mail
- mobile push message, etc ..
- etc ...
VI. basic relationships between devices
Subflows manages the basic relationship between different devices: e.g .:
- bedroom switch pressed: bedroom light on
- bedroom switch double pressing: bedroom lamp brightness set to 50%, etc.….
- Someone opened the garage door: message on the mobile that the garage is open
- etc ..
The subflows above would be handled in the background by node-red. If I like to add a new device (sensor, actuator (eg relay), garage door motor, etc.) to the smart home system, I would add it in the node-red editor with the necessary extra by inserting and modifying subflows, databases, other node red elements
The next schedule / event management subflow would be what the user (wife) could set up in the dashboard:
VII. User automation (schedule / event) management
These automations would be what the user (my wife / kids) could set up on the Dashboard. The user can add a new event to the events list. They choose which change of sensor state will be listen (bedroom temperature sensor), which actuator element should respond (IR remote for air conditioning unit). In addition they can scheduling this event. The selected sensor (eg temperature sensor) and actuator element (eg IR remote) would be stored in the event database, the scheduling (eg from July to September) would be stored in the schedule database. These data would be loaded from the event and schedule database when rpi is (re)started or Node Red deployed and set the topic of 'topic link in' node of event manager dynamically, that the event handler subflow receives only the status messages which the user want to monitor (changing of bedroom temperature sensor), and it doesn’t receive all status messages of all devices.
As I wrote, and you wrote it clearly too (with example), I can do it without dynamic topic addressing, but in this case the event handler ‘topic link in’ node will get a message status changing of all device, instead of just get one message when bedroom temperature sensor send status changing message.
That’s why I would like a dynamic ‘topic link in’ node.
I still don't understand why you say this is so specific, since all smart home apps handle user-configurable event handling (e.g. Xiaomi home app (Device selection -> Automation -> 'if' and 'then' options) (eWeLink app: Device selection -> Auto -> 'Control by' and 'set' option).
In these app the user can set on the user interface what should happen if a sensor changes its status The devices must be managed dynamically from the perspective of the event handler.
Certainly, I'm glad you did the 'topic link in' and 'topic link out' nodes, but I think this message transfer among nodes would be complete with dynamic 'topic link in'. I think many other places might need it, probably that's why somebody did the mqtt dynamic topic input node addition as well.
Thanks again to both of you for devoting so much time to me.
If you do not add 'topic link in' to the topic option via message, I will stick to mqtt messaging, as it is logically a better solution for me than the input node receives all device messages and the subsequent function node should select the one message is required from each message, or I try to learn the forts of custom node creation and supplement the ‘topic link in’ node with an input.
Thanks again for the help.