First timer out of my depth. I am in the midst of building a kind of traffic light system for our examination rooms in order to see the occupancy from the hospital hallway.
The location: 6 exam rooms in a hallway, all rooms “walkthrough” type (one door to lobby and one door to hospital hallway), about 3 meters wide and 4 meters long, doors at each end of the rooms.
The lights: 6 led pucks in series running WLED outside above each door. Divided into 6 segments
The sensors: One Apollo MSR-2 in the corner of every exam room at head height (2m from the vet, 3.5m from the pet owner)
The zones: 2 occupancy zones, vet occupancy zone and pet owner zone.
The goal:
Have the led be green when room is empty.
Have the led turn red if there is a pet owner sitting in one corner of the room + presence of a veterinarian/nurse in other side of the room.
Have the led turn yellow when just the pet owner is waiting on owner side of the room
The questions (Please excuse beginner ignorance):
I am creating an automation for each MSR-2? What is the smartest way of automating this kind of system in home assistant?
Should I have an automation for each trigger and action, or should all triggers/actions be under one automation?
Which triggers to use (Zone 2-3 became not occupied/occupied, gate still/move energy, radar target became not occupied, radar moving target stopped detecting motion)?
Should I be using building blocks and conditions?
Light action “toggle” or “turn on”?
Should I be using YAML or can I do without? (no experience)
For most high-level problem statements like this, Home Assistant will give you many possible avenues at a solution. The answers to the questions you’re asking are going to depend on what specific avenues seem best to you based on what you want to accomplish, since ultimately you’re going to know more about your problem statement than you can practicably put into a forum post.
I encourage you to at least get started with creating an automation, and post your code here when you get stuck, so that you’re asking specific questions rather than very open-ended ones. To me it sounds like you should be able to build the automation(s) you want using just the GUI. (But when you ask questions here, copy and paste the YAML, using the editor’s </> Preformatted Text option; it’s much easier for most people to look at that and answer questions than to look at screenshots of the GUI.)
If you want to do the exact same thing in each of your 6 rooms, you probably don’t want a different automation for each room. You can figure out which room a trigger happens in by assigning an ID to the trigger.
If you really wanted to, you’d be able to accomplish everything with just one automation by assigning trigger IDs based on the room AND the kind of trigger (e.g., exam_1_green for when your sensor detects no occupancy) , and some people prefer that approach. With a background in programming, I usually prefer to keep automations that do different things (like turn lights on or off) to separate automations, but how to do it in any given instance to me is a question of whether I’m duplicating code or eliminating duplication. How to tackle that is going to be based on what makes the logic easiest to create and maintain for you.
Good advice. Some addidions of my own: start small with one automation for one bit of the problem in one room. Expand on that until it fits your problem.
If you have one room working, expand to the others. You can use ids as described above, but another approach could be to modify the first automation and turn it into a blueprint. But that is for later.
Great advice above. Another thought to throw into the mix is that “presence detection” is hard to get accurate all the time. It can easily get “pretty close”, but being 100% accurate 100% of the time in your scenario of distinguishing people on two sides if a room is going to be really challenging. You may end up needing multiple sensors (motion, pressure-mats on the floor, etc.) with logic to combine them.
But whatever automatic sensors you go with, consider also having a “manual override” way to set the lights when needed. The HA app should be fine for this, or maybe you need some sort of push button or switch on the wall. But there should likely be some quick way you can just set it to what it needs to be now, and figure out why it didn’t detect that customer later…
I don’t own an MSR-2 and don’t know much about it, so for the purpose of this answer I will just assume that 2 zones work like having 2 separate presence detectors (one pointing at the Vet and the other the owner).
If so I would start by trying to get one room working:
Start with one automation.
Trigger on any change to presence on either sensor.
Then use a choose condition:
If the Vet is present set the light Red.
If the Owner is present set the light Yellow.
Else (Default Action) set the light Green.
If both the Vet and Owner are present, because the Vet condition is first the light will be Red.
I would use the turn on action for all 3 conditions.
If there is already an automation for another light that is typically turned on when the first person arrives in the morning and off when the last person leaves I would add to that to:
Turn on all lights (green color) when the main light is turned on.
Turn off all the lights when the main light is turned off.
As others have pointed out presence detectors are pretty good but they are not foolproof, so as a next step I may add a “Template Binary Sensor” for both of the real sensors - using the delay_off flag (for say 15 seconds) that way the presence will still be registered on the HA side even if there is a blip in actual detection.
Note: I am assuming that it’s not super critical if the lights occasionally read wrong so I am not overdoing it, if that is a real problem I might add door sensors so that presence is only cleared if the door is open.
The “delay_off” flag requires you to edit the Yaml, you can do it from the UI for everything else.
Finally if it all looks good for one room you have two choices:
Simply copy the automation 5 times for the other rooms.
Ensure all the lights and sensor have sequential names (Sensor1, 2, 3…) then you should be able to generify the single automation to handle all the rooms.