Create zones and arm/disarm

Hi. I have a few esp8266 boards spread around the building and they have sensors

  1. reed switches
  2. thermometers
  3. PIRs

and through mqtt they send their status/info in the mqtt broker (raspberry) and presented to the UI of node red. i am naive with node red, but i got it working fine to present the status of each sensor over mqtt. At the moment i have 15 entries for doors/windows/rooms in node red and i get the status of each one.
The overall system works fine and i would like to add a few touches by creating zones and arm/disarm on demand each zone. For example i would like to arm the outside of house windows and doors only.

i would appreciate any help available to create the zones and how to arm/disarm each zone, please.

Please provide more details of what you want to happen dependent on whether a zone is armed or disarmed.
Would the mapping of sensors to zones be fixed?

thanks for the quick reply. These are the actions that i would like to have

  • set which devices will in which zone and name the zone accordingly. eg kitchen, backyard etc
  • once a zone is armed then show all alerts on the UI of node red. If it is disarmed then do not show the alerts on the UI.
  • create a button so i could easily arm/disarm each zone separately. Then i will add a physical button somewhere so even the kids could enable it and an indication (led) that this zone is armed or disarmed.
1 Like

Do you need to do that via the UI or could that be built into the flow?

Via the UI will be ideal, please

That makes it much more difficult.

Whatever is easier, please

Well I would start with a ui-switch node on the dashboard for each zone. Then, for each zone feed all the sensors (from MQTT), and also the switch state, into a Join node configured similar to that in the cookbook example on Joining Streams. Set the Join node to output on every successive message and then each time anything changes you will get a message out with all the sensors and the enable state, so you can look at those and decide what to do.
For the ui, you haven't said what you want but perhaps a ui-table node showing all the enabled active sensors might be a good way to go.

Could you show me a printscreen please?
Lost you completely on what to do

Look at the example I linked to, import it and play with it and see what it does. Then once you understand how that works read my post again.
Edit, I see there is a typo in my post which messes up the meaning, I will correct that.

@Colin, if i got correct from the link you provided you said to get instead of temperature, humidity and pressure to have my list of each zone for example Bedroom_door1, Bedroom_door2, Bedroom_Window_1, Bedroom_Window_2 join into Zone_A

then create a second zone underneath it and call it kitchen/bathroom and have the corresponding sensors and a 3rd zone with whatever i need to call it?
How do i correct the names, please? Is this the correct approach?

Yes, though you show a Switch node instead of a Join node. Also you need the Arm/Disarm ui-switch connected into the join as you need that as well as the sensors to know what to do.
I don't know what you mean by correcting the names. What do the sensor topics look like?

Does this look better? εικόνα
Also what is the ui-switch component,i cannot find it in the list.
My topics currently are:
/device/alarm/sensor/livingroom_window
/device/alarm/sensor/livingroom_door
/device/alarm/sensor/Main_entrance
/device/alarm/sensor/hallway
/device/alarm/sensor/bedroom_1_door
/device/alarm/sensor/bedroom_1_window
/device/alarm/sensor/bedroom_2_door
/device/alarm/sensor/bedroom_2_window
/device/alarm/sensor/backyard
/device/alarm/sensor/frontyard

OK, that makes sense, in the real thing the inject nodes will be replaced by MQTT In nodes. The output from the Join will have to go to a processing node that works out what to do. Probably a Function node.

I assumed you had already been using the dashboard, perhaps not. ui-switch is the dashboard switch node, not to be confused with the Switch node.

image

@Colin, first of all i would like to thank you for your help in my steps with the config.
Is it looking better now?


What are my next steps, then?

I fear you have missed something fundamental in what the Join node is supposed to do. The purpose is to join all its inputs into one message so you can decide what to show. So you have to ask yourself what information do I need to know in order to display the information? As I understand your requirement, what you need is firstly the current sensor states, and you have those going into the Join node correctly. The other thing you need to know is whether the zone is enabled or disabled as the information you want to display also depends on that. Therefore you have to have the switch going into the Join node, which, unless I made some typos, is what I have been saying all along.

I also suggest you use MQTT to pass the switch states about. Wire the switches like this

image

and configure the switch as

image

Feed the switch topic into the join node along with all the others. Then put a debug node on the output and see what you get out. You may need to exercise the switches and sensor states once on startup. In order to make sure you don't have to do that every time, I suggest you make all the topics (sensors and switches) Retained in MQTT so that on a node-red restart or power up the switches will automatically go to the state they were before the restart and to make sure there are initial states for all the sensors.

Up to now i have the following:




is it OK? if yes then i have to move to the design part (add an image for each zone) and how to have a dedicated page for this flow instead of the default
http://ip_address:1880/ui so i could create more dedicated flows and access them individually.

No. As you have that, when you open/close bedroom_1_door it will switch the zone a enable/disable switch.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.