Motion sensor paired light

I have a few PIR sensor controlled lights, and I wanted to combine the on and off actions to a single blueprint. It is done by using the trigger variable: trigger.to_state.state

There are 3 inputs in this blueprint.

  1. Trigger motion sensor entity_id
  2. Controlled light entity_id
  3. How many seconds to keep the light on after no motion detected

Usually lights are turned on immediately when motion is detected, so I didn’t make a delay for the turn_on action.

blueprint:
  name: PIR paired Light
  description: PIR triggers light on and off
  domain: automation
  input:
    pir_id:
      name: Motion Entity ID
      description: entity_id of motion(PIR) sensor
      selector:
        target:
          entity:
            domain: binary_sensor
            device_class: motion
    light_id:
      name: Light Entity ID
      description: entity_id of light
      selector:
        target:
          entity:
            domain: light
    off_delay:
      name: Delay After No Motion
      description: Keep light for X seconds after no motion
      selector:
        number:
          min: 0
          max: 3600
          unit_of_measurement: seconds

trigger:
  - platform: state
    entity_id: !input pir_id
    from: "on"
    to: "off"
    for:
      seconds: !input off_delay
  - platform: state
    entity_id: !input pir_id
    from: "off"
    to: "on"

action:
  service: >
    light.turn_{{ trigger.to_state.state }}
  entity_id: !input light_id
3 Likes

hey still pretty new to this, but how do i use this blueprint?

Hi, I think you can check this link