Skip to content

Instantly share code, notes, and snippets.

@Resinchem
Last active March 8, 2023 15:58
Show Gist options
  • Save Resinchem/7295d35d6878f00d93d069ed5c6bd40f to your computer and use it in GitHub Desktop.
Save Resinchem/7295d35d6878f00d93d069ed5c6bd40f to your computer and use it in GitHub Desktop.
Home Assistant WLED Stair Lighting
# ==========================================================
# This version is for Home Assistant releases
# 2021.11 or earlier. See the stair_lights_ha_2021_21.yaml
# for all later releases of Home Assistant
3 ==========================================================
# BASEMENT STAIR LED LIGHTING WITH MOTION DETECTION
# LED lighting is auto-on based on motion detection at top and bottom of stairs.
# Initial motion at bottom, lights sequence up the stairs from the bottom.
# Initial motion at top, lights sequence down the stairs from the top.
# Sequence continues until opposite motion detector fires movement, turning lights off.
# Defaults to 15 seconds before auto-shutoff if no futher motion detected.
# Enable/disable automation via the input_boolean.stair_auto_leds
# Entiies:
# light.stair_lights
# binary_sensor.stair_motion_top
# binary_sensor.stair_motion_bottom
# timer.stair_motion_timer
# input_boolean.stair_auto_leds
# input_boolean.stair_top_motion
# input_boolean_stair_bottom_motion
##################################
# Stair Lights On with Top Motion
#################################
- alias: Top Motion Lights On
trigger:
platform: state
entity_id: binary_sensor.stair_motion_top
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.stair_auto_leds
state: "on"
- condition: state
entity_id: light.stair_lights
state: 'off'
action:
- service: wled.effect
data:
entity_id: light.stair_lights
effect: 'Wipe'
reverse: true
speed: 220
- service: light.turn_on
data:
entity_id: light.stair_lights
rgb_color: [255,255,255]
- service: input_boolean.turn_on
entity_id: input_boolean.stair_top_motion
- service: timer.start
data:
entity_id: timer.stair_motion_timer
duration: '00:00:15'
###################################
# Stair Lights Off with Top Motion
##################################
- alias: Top Motion Lights Off
trigger:
platform: state
entity_id: binary_sensor.stair_motion_top
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: light.stair_lights
state: 'on'
- condition: state
entity_id: input_boolean.stair_auto_leds
state: "on"
action:
- service: light.turn_off
entity_id: light.stair_lights
####################################
# Stair Lights on with Bottom Motion
####################################
- alias: Bottom Motion Lights On
trigger:
platform: state
entity_id: binary_sensor.stair_motion_bottom
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.stair_auto_leds
state: "on"
- condition: state
entity_id: light.stair_lights
state: 'off'
action:
- service: wled.effect
data:
entity_id: light.stair_lights
effect: 'Wipe'
reverse: false
speed: 220
- service: light.turn_on
data:
entity_id: light.stair_lights
rgb_color: [255,255,255]
- service: input_boolean.turn_on
entity_id: input_boolean.stair_bottom_motion
- service: timer.start
data:
entity_id: timer.stair_motion_timer
duration: '00:00:15'
#####################################
# Stair Lights off with Bottom Motion
#####################################
- alias: Bottom Motion Lights Off
trigger:
platform: state
entity_id: binary_sensor.stair_motion_bottom
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: light.stair_lights
state: 'on'
- condition: state
entity_id: input_boolean.stair_auto_leds
state: "on"
action:
- service: light.turn_off
entity_id: light.stair_lights
###########################
# Stair Timer Expiration
###########################
- alias: Stair Timer Expires
trigger:
platform: event
event_type: timer.finished
event_data:
entity_id: timer.stair_motion_timer
condition:
# Assure no motion occuring
- condition: state
entity_id: binary_sensor.stair_motion_top
state: 'off'
- condition: state
entity_id: binary_sensor.stair_motion_bottom
state: 'off'
action:
# Reset input booleans and turn off lights
- service: input_boolean.turn_off
entity_id: input_boolean.stair_top_motion
- service: input_boolean.turn_off
entity_id: input_boolean.stair_bottom_motion
- service: light.turn_off
entity_id: light.stair_lights
@Resinchem
Copy link
Author

Resinchem commented Nov 3, 2020

See video of lights in action here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment