Light automation - turn off switch unless then wait

Hi all,

I’m new to automation here, but familiar with home assistant. Just looking for some help on my first real automation setup. Any thoughts would be appreciated!

I have a room where one half is a laundry room and the other is used as a gym. Inside the laundry room I have a normal overhead light and in the gym area there are 2 Hue lights. I have a motion sensor in each area. The motion at the door turns on the Laundry room light by turning on the switch that has a shelly device in it. The motion around the corner turns on 2 Hue lights in the gym. The light switch that I have a shelly device in that controls the power to both areas. I keep this switch on at all times.

I have an automation setup for both areas to turn on with motion. This works fine, however when the 10 minute after motion timer switches off in the Landry room this means the gym lights go out too. How can I keep the 10 minute timeout for the Laundry area but only have the Landry light turn off if the gym lights are also off? I have the gym lights set at 90 minutes after occupancy is detected.

Laundry Motion Automation
alias: Laundry Room Motion and light
description: Turn office lights on/off on motion.
use_blueprint:
  path: homeassistant/motion_light.yaml
  input:
    motion_entity: binary_sensor.laundry_room_motion_occupancy
    light_target:
      area_id: laundry_eoo
    no_motion_wait: 600

Gym Motion Automation:
alias: Gym Motion Activated Lights
description: Turn office lights on/off on motion.
use_blueprint:
  path: homeassistant/motion_light.yaml
  input:
    motion_entity: binary_sensor.gym_motion_occupancy
    light_target:
      entity_id: light.gym
    no_motion_wait: 2700

Do the gym lights need to turn on when the laundry room motion sensor detects motion?

If not, the easiest way to solve the problem would be to switch from an area target to targeting the specific lights in the laundry room.

I would set an ID for each of the individual room motions in the automation.

EXAMPLE

trigger: state
entity_id:
  - binary_sensor.laundry_room_motion_occupancy
id: laundry
to: "on"

The ID above is laundry

This will allow you to set a conditional action

if:
  - condition: trigger
    id:
      - laundry
then:
  - action: 

add an if condition for gym and set the appropriate action.

By doing this you can individually control ON/OFF for the lights
I think this may provide you flexibility to change logic of automation to work better for you