Skip to content

Instantly share code, notes, and snippets.

@Resinchem
Created October 2, 2021 12:27
Show Gist options
  • Save Resinchem/6183b9b113a1e85298a553c51492f1d6 to your computer and use it in GitHub Desktop.
Save Resinchem/6183b9b113a1e85298a553c51492f1d6 to your computer and use it in GitHub Desktop.
Automated Garage Lighting
# =========================
# GARAGE OVERHEAD LIGHTS
# =========================
# Two manual entities (or helpers) are required for these
# automations:
# input_boolean.garage_motion_enable
# timer.garage_motion_time
# ---------------------------------------------------------
# Lights on via manual switch/doors closed (disable automation)
# ---------------------------------------------------------
- alias: Garage Lights on with Switch
trigger:
platform: state
entity_id: switch.garage_light_switch
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: "on"
- condition: state
entity_id: binary_sensor.garage_service_door
state: "off"
- condition: state
entity_id: binary_sensor.garage_laundry_door
state: "off"
action:
- service: input_boolean.turn_off
entity_id: input_boolean.garage_motion_enable
# ----------------------------------------------------------------------
# Lights Off (manual switch or motion) - reenable motion any time lights go off
# ----------------------------------------------------------------------
- alias: Garage Lights off
trigger:
platform: state
entity_id: switch.garage_light_switch
from: 'on'
to: 'off'
action:
- service: input_boolean.turn_on
entity_id: input_boolean.garage_motion_enable
# ----------------------------------------
# Lights On with door opening
# ----------------------------------------
# Lights on with service door open
- alias: Garage Lights on with service door
trigger:
platform: state
entity_id: binary_sensor.garage_service_door
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: 'on'
- condition: numeric_state
entity_id: sensor.garage_light_level
below: 120
action:
- service: switch.turn_on
entity_id: switch.garage_light_switch
- service: timer.start
data:
entity_id: timer.garage_motion_time
duration: '00:00:45'
# Lights on with Laundry Door open
- alias: Garage Lights on with Laundry Door
trigger:
platform: state
entity_id: binary_sensor.garage_laundry_door
from: "off"
to: "on"
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: "on"
- condition: numeric_state
entity_id: sensor.garage_light_level
below: 120
action:
- service: switch.turn_on
entity_id: switch.garage_light_switch
- service: timer.start
data:
entity_id: timer.garage_motion_time
duration: '00:00:45'
# ------------------------------------------
# Lights remain on/timer reset with motion
# ------------------------------------------
# Lights stay on with motion (restart timer)
- alias: Garage Lights on with motion
trigger:
platform: state
entity_id: binary_sensor.garage_motion
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: 'on'
action:
- service: timer.start
data:
entity_id: timer.garage_motion_time
duration: '00:00:45'
- alias: Garage Lights on with Rear motion
trigger:
platform: state
entity_id: binary_sensor.garage_motion_rear
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: 'on'
action:
- service: timer.start
data:
entity_id: timer.garage_motion_time
duration: '00:00:45'
# --------------------------------------
# Start timer when both doors closed
# --------------------------------------
# Start / Restart timer service door closed
- alias: Garage Timer start on service door closed
trigger:
platform: state
entity_id: binary_sensor.garage_service_door
from: "on"
to: "off"
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: "on"
- condition: state
entity_id: binary_sensor.garage_laundry_door
state: "off"
action:
- service: timer.start
data:
entity_id: timer.garage_motion_time
duration: "00:00:45"
# Start / Restart timer laundry door closed
- alias: Garage Timer start on laundry door closed
trigger:
platform: state
entity_id: binary_sensor.garage_laundry_door
from: "on"
to: "off"
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: "on"
- condition: state
entity_id: binary_sensor.garage_service_door
state: "off"
action:
- service: timer.start
data:
entity_id: timer.garage_motion_time
duration: "00:00:45"
# -----------------------------
# Garage Light timer
# ------------------------------
# Turn off lights upon timer expire, no open doors, no motion
- alias: Garage Light Motion Timer
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.garage_motion_time
condition:
- condition: state
entity_id: input_boolean.garage_motion_enable
state: "on"
- condition: state
entity_id: binary_sensor.garage_service_door
state: "off"
- condition: state
entity_id: binary_sensor.garage_laundry_door
state: "off"
- condition: state
entity_id: binary_sensor.garage_motion
state: "off"
- condition: state
entity_id: binary_sensor.garage_motion_rear
state: "off"
action:
- service: switch.turn_off
entity_id: switch.garage_light_switch
# ------------------------------------
# Notification for lights left on 30 min
# -------------------------------------
- alias: Garage Lights Left On Notify
trigger:
platform: state
entity_id: switch.garage_light_switch
from: 'off'
to: 'on'
for: '00:30:00'
action:
service: notify.mobile_app_galaxy_s10
data:
message: "Garage lights on for 30 minutes"
data:
actions:
- action: "garage_lights_turn_off"
title: "Turn off lights"
- alias: Garage Lights Off from Notify
trigger:
platform: event
event_type: mobile_app_notification_action
event_data:
action: garage_lights_turn_off
action:
service: switch.turn_off
entity_id: switch.garage_light_switch
# -----------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment