2019-04-17 22:46:06 +00:00
|
|
|
###############################################################################
|
|
|
|
# @author : Mahasri Kalavala
|
|
|
|
# @date : 11/19/2017
|
|
|
|
# @package : Timers and Lights/Switches
|
|
|
|
# @description : All lights and switches are now timer enabled
|
2019-12-20 15:32:28 +00:00
|
|
|
# and the timer automatically extends when there is
|
2019-04-17 22:46:06 +00:00
|
|
|
# motion. When timer elapses, it turns off lights.
|
|
|
|
###############################################################################
|
|
|
|
homeassistant:
|
|
|
|
customize:
|
|
|
|
timer.timer_kitchen:
|
|
|
|
hidden: true
|
|
|
|
timer.timer_familyroom:
|
|
|
|
hidden: true
|
|
|
|
timer.timer_frontroom:
|
|
|
|
hidden: true
|
|
|
|
timer.timer_garage:
|
|
|
|
hidden: true
|
|
|
|
timer.timer_diningroom:
|
|
|
|
hidden: true
|
|
|
|
timer.timer_masterbedroom:
|
|
|
|
hidden: true
|
2021-01-10 20:03:52 +00:00
|
|
|
timer.timer_masterbathroom:
|
|
|
|
hidden: true
|
2019-04-17 22:46:06 +00:00
|
|
|
timer.timer_officeroom:
|
|
|
|
hidden: true
|
|
|
|
|
|
|
|
timer:
|
|
|
|
timer_kitchen:
|
2019-12-20 15:32:28 +00:00
|
|
|
duration: "00:10:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
timer_familyroom:
|
2019-12-20 15:32:28 +00:00
|
|
|
duration: "00:05:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
timer_frontroom:
|
2019-12-20 15:32:28 +00:00
|
|
|
duration: "00:05:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
timer_garage:
|
2019-12-20 15:32:28 +00:00
|
|
|
duration: "00:05:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
timer_masterbedroom:
|
2019-12-20 15:32:28 +00:00
|
|
|
duration: "00:05:00"
|
2021-01-10 20:03:52 +00:00
|
|
|
timer_masterbathroom:
|
|
|
|
duration: "00:05:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
timer_officeroom:
|
2019-12-20 15:32:28 +00:00
|
|
|
duration: "00:05:00"
|
2019-04-17 22:46:06 +00:00
|
|
|
|
|
|
|
###############################################################################
|
2019-12-20 15:32:28 +00:00
|
|
|
# _ _ _
|
|
|
|
# /\ | | | | (_)
|
|
|
|
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
|
2019-04-17 22:46:06 +00:00
|
|
|
# / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
|
|
|
|
# / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
|
|
|
|
# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
|
2019-12-20 15:32:28 +00:00
|
|
|
#
|
2019-04-17 22:46:06 +00:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
automation:
|
2021-01-10 20:03:52 +00:00
|
|
|
# Master Bathroom:
|
|
|
|
# Motion Detected - Turn ON the light and extend timer
|
|
|
|
###############################################################################
|
|
|
|
- alias: Master Bathroom Motion & Timer
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.motion_sensor_158d000464c25a
|
|
|
|
to: "on"
|
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_masterbathroom
|
|
|
|
- service: light.turn_on
|
|
|
|
entity_id: light.master_bathroom_lights
|
2022-11-30 00:50:52 +00:00
|
|
|
data:
|
|
|
|
brightness: 64 # 25% of brightness
|
|
|
|
transition: 5
|
|
|
|
- condition: template
|
|
|
|
value_template: '{{states("sun.sun") == "above_horizon"}}'
|
|
|
|
- service: light.turn_on
|
|
|
|
entity_id: light.master_bathroom_lights
|
|
|
|
data:
|
|
|
|
brightness: 254 # 100% of brightness
|
|
|
|
transition: 5
|
2021-01-10 20:03:52 +00:00
|
|
|
|
|
|
|
- alias: Master Bathroom Timer Elapsed
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: event
|
|
|
|
event_type: timer.finished
|
|
|
|
event_data:
|
|
|
|
entity_id: timer.timer_masterbathroom
|
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service_template: >
|
|
|
|
{{ 'light.turn_off' if states('binary_sensor.motion_sensor_158d000464c25a') != 'on' else 'timer.start' }}
|
|
|
|
data:
|
|
|
|
entity_id: "{{ 'light.master_bathroom_lights' if states('binary_sensor.motion_sensor_158d000464c25a') != 'on' else 'timer.timer_masterbathroom' }}"
|
|
|
|
|
2019-12-20 15:32:28 +00:00
|
|
|
# Office Room:
|
|
|
|
# Motion Detected - Turn ON the light and extend timer
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Officeroom Motion & Timer
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.motion_sensor_158d000272bfd7
|
2019-12-20 15:32:28 +00:00
|
|
|
to: "on"
|
2021-01-10 20:03:52 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_officeroom
|
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.office_room
|
|
|
|
|
|
|
|
- alias: Officeroom Timer Elapsed
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
2019-12-20 15:32:28 +00:00
|
|
|
- platform: event
|
|
|
|
event_type: timer.finished
|
|
|
|
event_data:
|
|
|
|
entity_id: timer.timer_officeroom
|
2021-01-10 20:03:52 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2021-03-22 01:56:34 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.working_in_office_room
|
|
|
|
state: "off"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
2021-01-10 20:03:52 +00:00
|
|
|
- service_template: >
|
|
|
|
{{ 'switch.turn_off' if states('binary_sensor.motion_sensor_158d000272bfd7') != 'on' else 'timer.start' }}
|
|
|
|
data:
|
|
|
|
entity_id: "{{ 'switch.office_room' if states('binary_sensor.motion_sensor_158d000272bfd7') != 'on' else 'timer.timer_officeroom' }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
|
2019-12-20 15:32:28 +00:00
|
|
|
# # Front Room:
|
|
|
|
# # Motion Detected - Turn ON the light and extend timer
|
|
|
|
# ###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Frontroom Motion & Timer
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.motion_sensor_158d00016db6d2
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "off"
|
|
|
|
to: "on"
|
2021-01-10 20:03:52 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_frontroom
|
|
|
|
- condition: template
|
2019-12-20 15:32:28 +00:00
|
|
|
value_template: "{{ states('sun.sun') == 'below_horizon' }}"
|
2020-03-02 23:12:53 +00:00
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.front_room
|
2019-04-17 22:46:06 +00:00
|
|
|
|
2019-12-20 15:32:28 +00:00
|
|
|
# Kitchen:
|
|
|
|
# Motion Detected - Turn ON the light and extend timer
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Kitchen Motion & Timer
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
2019-12-20 15:32:28 +00:00
|
|
|
entity_id:
|
2019-04-17 22:46:06 +00:00
|
|
|
- binary_sensor.motion_sensor_158d0001a662fe
|
|
|
|
- binary_sensor.kitchen_motion_sensor_sensor
|
|
|
|
- binary_sensor.basement_door_sensor_sensor
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "off"
|
|
|
|
to: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: sun.sun
|
2019-12-20 15:32:28 +00:00
|
|
|
state: "below_horizon"
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: switch.turn_on
|
2022-11-30 00:50:52 +00:00
|
|
|
entity_id: switch.kitchen_switch
|
2019-04-17 22:46:06 +00:00
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_kitchen
|
2019-12-20 15:32:28 +00:00
|
|
|
# Kitchen:
|
|
|
|
# Timer Elapsed - Turn OFF lights
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Kitchen Timer Elapsed
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: event
|
|
|
|
event_type: timer.finished
|
2019-12-20 15:32:28 +00:00
|
|
|
event_data:
|
|
|
|
entity_id: timer.timer_kitchen
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: sun.sun
|
2019-12-20 15:32:28 +00:00
|
|
|
state: "below_horizon"
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service_template: >
|
2019-12-20 15:32:28 +00:00
|
|
|
{% if now().hour|int >= states('sensor.bedtime_hour') |int and
|
|
|
|
now().minute|int >= states('sensor.bedtime_minute') |int %}
|
2019-04-17 22:46:06 +00:00
|
|
|
switch.turn_off
|
|
|
|
{% else %}
|
|
|
|
switch.turn_on
|
|
|
|
{% endif %}
|
2022-11-30 00:50:52 +00:00
|
|
|
entity_id: switch.kitchen_switch
|
2019-12-20 15:32:28 +00:00
|
|
|
# Family Room:
|
|
|
|
# Motion Detected - When TV is OFF, turn ON the light 100% and extend timer
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Family Room Motion & Timer
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
2019-12-20 15:32:28 +00:00
|
|
|
entity_id:
|
2021-01-10 20:03:52 +00:00
|
|
|
# - binary_sensor.tv_multi_sensor_sensor
|
2019-04-17 22:46:06 +00:00
|
|
|
- binary_sensor.motion_sensor_158d0001a25041
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "off"
|
|
|
|
to: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: sun.sun
|
2019-12-20 15:32:28 +00:00
|
|
|
state: "below_horizon"
|
2019-04-17 22:46:06 +00:00
|
|
|
- condition: template
|
|
|
|
value_template: "{{ states('input_boolean.movie_time') != 'on' }}"
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: light.turn_on
|
2020-09-05 02:12:14 +00:00
|
|
|
entity_id: light.hue_color_lamp_1, light.hue_color_lamp_2, light.hue_color_lamp_3
|
2022-12-05 00:02:34 +00:00
|
|
|
data:
|
2019-04-17 22:46:06 +00:00
|
|
|
brightness: >
|
2019-12-20 15:32:28 +00:00
|
|
|
{% if states('binary_sensor.sharp_tv') == "on" %}
|
2019-04-17 22:46:06 +00:00
|
|
|
25
|
|
|
|
{% else %}
|
|
|
|
254
|
|
|
|
{% endif %}
|
|
|
|
color_temp: 154
|
2019-12-20 15:32:28 +00:00
|
|
|
transition: 5
|
2019-04-17 22:46:06 +00:00
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_familyroom
|
2019-12-20 15:32:28 +00:00
|
|
|
# Family Room:
|
|
|
|
# Timer Elapsed - Turn OFF lights
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Family Room Timer Elapsed
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: timer.timer_familyroom
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "active"
|
|
|
|
to: "idle"
|
2021-01-10 20:03:52 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: light.turn_off
|
2020-09-05 02:12:14 +00:00
|
|
|
entity_id: light.hue_color_lamp_1, light.hue_color_lamp_2, light.hue_color_lamp_3
|
2019-12-20 15:32:28 +00:00
|
|
|
- delay: "00:00:05"
|
2019-04-17 22:46:06 +00:00
|
|
|
- service: light.turn_off
|
2020-09-05 02:12:14 +00:00
|
|
|
entity_id: light.hue_color_lamp_1, light.hue_color_lamp_2, light.hue_color_lamp_3
|
2019-12-20 15:32:28 +00:00
|
|
|
# Master Bedroom:
|
|
|
|
# Motion Detected - Turn ON the lights and extend timer
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Master Bedroom Motion & Timer
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.upstairs_multi_sensor_sensor
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "off"
|
|
|
|
to: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: sun.sun
|
2019-12-20 15:32:28 +00:00
|
|
|
state: "below_horizon"
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: light.turn_on
|
|
|
|
data:
|
|
|
|
entity_id: light.master_bedroom_1
|
2019-12-20 15:32:28 +00:00
|
|
|
rgb_color: [224, 175, 102]
|
2019-04-17 22:46:06 +00:00
|
|
|
brightness: 10
|
|
|
|
- service: light.turn_on
|
|
|
|
data:
|
|
|
|
entity_id: light.master_bedroom_2
|
2019-12-20 15:32:28 +00:00
|
|
|
rgb_color: [224, 175, 102]
|
2019-04-17 22:46:06 +00:00
|
|
|
brightness: 10
|
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_masterbedroom
|
2020-07-17 01:15:43 +00:00
|
|
|
|
2019-12-20 15:32:28 +00:00
|
|
|
# Master Bedroom:
|
|
|
|
# Timer Elapsed - Turn OFF lights
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Master Bedroom Timer Elapsed
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: timer.timer_masterbedroom
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "active"
|
|
|
|
to: "idle"
|
2021-01-10 20:03:52 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: light.turn_off
|
|
|
|
entity_id: light.master_bedroom_1
|
|
|
|
- service: light.turn_off
|
|
|
|
entity_id: light.master_bedroom_2
|
2020-07-17 01:15:43 +00:00
|
|
|
|
2019-12-20 15:32:28 +00:00
|
|
|
# Start the timer when the lights are ON
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Garage Timer Start When Garage Lights ON
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: switch.garage
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "off"
|
|
|
|
to: "on"
|
2021-01-10 20:03:52 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_garage
|
2020-07-17 01:15:43 +00:00
|
|
|
|
2019-12-20 15:32:28 +00:00
|
|
|
# Garage:
|
|
|
|
# Timer Elapsed - Turn OFF lights, when "I am not working"
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Garage Timer Elapsed
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: timer.timer_garage
|
2019-12-20 15:32:28 +00:00
|
|
|
from: "active"
|
|
|
|
to: "idle"
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.working_in_garage
|
2019-12-20 15:32:28 +00:00
|
|
|
state: "off"
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: switch.turn_off
|
|
|
|
entity_id: switch.garage
|