Using a single automation for multiple devices

Can be done if you strategically name your entities

binary_sensor.kitchen_motion = light.kitchen
binary_sensor.bathroom_motion = light.bathroom
Etc

trigger:
  - platform: state 
    entity_id: &motion
      - binary_sensor.kitchen_motion
      - binary_sensor.bathroom_motion
      - ETC
    to: 'off' 
    for:
      minutes: 15
  - platform: state 
    entity_id: *motion
    to: 'on' 
action:
  service_template: "light.turn_{{ trigger.to_state.state }}"
  data_template:
    entity_id: >
      {{ trigger.to_state.entity_id
          |replace('binary_sensor', 'light') 
          |replace('_motion', '') }}

I’ve taken the liberty of adding the turn on part to the same automation (turns the light on instantly when motion, turns it off 15 minutes after motion stops).

7 Likes