I’ve been using Home Assistant to control many things at my smart home, including a couple of lights which are toggled on and off with motion sensors. I have one of these in the bathroom, so the motion sensor detects when I enter the bathroom and its light turns on, and the light turns back off if the motion sensor doesn’t detect any motion in a specific period (60 seconds). Setting this automation is very easy using the motion-activated light blueprint , you just need to choose the entities for the motion sensor and the light, and Home Assistant handles all the hassle of figuring out the logic for when to turn the light on or off, and what to do when a motion is detected in the cool off period.

The problem is, that this blueprint is limited to one motion entity, so if you want to control a light in a large area that can’t be covered with one single sensor, you need to create a more complicated automation. This made me procrastinate on adding a second motion sensor to my bathroom for months, but when I got back to finally doing this last week, I found out that you can use the same blueprint to control a light with multiple sensors using Home Assistant Groups .

To create a new group:

  1. Visit Settings > Devices & services > Helpers > Create Helper > Group > Binary sensor group in your Home Assistant instance.
  2. Choose a name like Bathroom motion sensor group .
  3. Add the entities of the motion sensors in the Members section.
  4. Click Submit .
  5. After creating the group, edit it and choose Motion for Show as (otherwise, it won’t show up in the motion-activated light blueprint in the next step).
  6. Create a simple motion-activated light sensor using the automation blueprint, and choose the recently created group as the trigger.

That’s it. Now the light in the bathroom will automagically be toggled on and off when either of the motion sensors detect motion.

To make this more interesting, I wanted the light to stay on if the smart speaker in the bathroom is playing music (even if there is no motion, which means I’m taking a shower but the shower curtain blocks the motion sensors from detecting motion). To achieve this, I needed to add the state of my smart speaker to the group created above:

  1. Create a new binary sensor using templates to aggregate states like playing and paused as on , and others ( idle and off) as off for the smart speaker by visiting: Settings > Devices & services > Helpers > Create Helper > Template > Template a binary sensor.

  2. Choose a name like Smart speaker is playing.

  3. State template: {% if is_state('media_player.your_speaker_entity_id', 'playing') or is_state('media_player.your_speaker_entity_id', 'paused') %} true {% else %} false {% endif %} .

  4. Device class: Motion .

  5. Now edit the group that we created in step 5, and add this new binary sensor as another member to the group.

Let me know if you have any questions.


Comment? Reply via Email, Mastodon or Twitter.