Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Rspurdy/465e63dc9c1709c0c5997e7a34adc001 to your computer and use it in GitHub Desktop.

Select an option

Save Rspurdy/465e63dc9c1709c0c5997e7a34adc001 to your computer and use it in GitHub Desktop.
Motion Activated Dim Light (Day or Night)
blueprint:
name: Motion Activated Dim Light (Day or Night)
description: >
Turns on a light at a defined brightness when motion is detected,
then turns it off after a configurable delay. Runs only during
daytime or nighttime based on the sun position.
domain: automation
input:
motion_sensor:
name: Motion Sensor
selector:
entity:
domain: binary_sensor
device_class: motion
target_light:
name: Light
selector:
target:
entity:
domain: light
brightness:
name: Brightness Level
description: Brightness percentage (1–100)
default: 30
selector:
number:
min: 1
max: 100
step: 1
unit_of_measurement: "%"
off_delay:
name: Turn Off Delay (seconds)
default: 120
selector:
number:
min: 5
max: 3600
step: 5
unit_of_measurement: seconds
run_when:
name: Run When
description: Choose whether this automation runs during the day or night
default: night
selector:
select:
options:
- label: Nighttime
value: night
- label: Daytime
value: day
mode: restart
trigger:
- platform: state
entity_id: !input motion_sensor
to: "on"
action:
- choose:
# 🌞 DAYTIME
- conditions:
- condition: template
value_template: "{{ iif(run_when == 'day', true, false) }}"
- condition: sun
after: sunrise
before: sunset
sequence:
- service: light.turn_on
target: !input target_light
data:
brightness_pct: !input brightness
# πŸŒ™ NIGHTTIME
- conditions:
- condition: template
value_template: "{{ iif(run_when == 'night', true, false) }}"
- condition: sun
after: sunset
before: sunrise
sequence:
- service: light.turn_on
target: !input target_light
data:
brightness_pct: !input brightness
- wait_for_trigger:
- platform: state
entity_id: !input motion_sensor
to: "off"
- delay:
seconds: !input off_delay
- condition: state
entity_id: !input motion_sensor
state: "off"
- service: light.turn_off
target: !input target_light
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment