Skip to content

Instantly share code, notes, and snippets.

@JoshBello
Last active November 28, 2025 16:49
Show Gist options
  • Select an option

  • Save JoshBello/410b7690f44378371a12f34c00fabe7c to your computer and use it in GitHub Desktop.

Select an option

Save JoshBello/410b7690f44378371a12f34c00fabe7c to your computer and use it in GitHub Desktop.
blueprint:
name: Motion-Activated Light (Night Only)
description: Turn on a light when motion is detected, but only between sunset and sunrise.
domain: automation
input:
motion_sensor:
name: Motion Sensor
description: The motion sensor that triggers the automation
selector:
entity:
domain: binary_sensor
device_class: motion
light_target:
name: Light
description: The light to control
selector:
entity:
domain: light
sunset_offset:
name: Sunset Offset
description: Time offset after sunset (negative = before sunset)
default: 0
selector:
number:
min: -120
max: 120
unit_of_measurement: minutes
mode: slider
sunrise_offset:
name: Sunrise Offset
description: Time offset before sunrise (negative = before sunrise)
default: 0
selector:
number:
min: -120
max: 120
unit_of_measurement: minutes
mode: slider
triggers:
- trigger: state
entity_id: !input motion_sensor
to: "on"
conditions:
- condition: or
conditions:
- condition: sun
after: sunset
after_offset: !input sunset_offset
- condition: sun
before: sunrise
before_offset: !input sunrise_offset
actions:
- action: light.turn_on
entity_id: !input light_target
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment