mysmarthome/packages/motion_timers.yaml

308 lines
9.8 KiB
YAML
Raw Normal View History

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
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"
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:
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"
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
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('sun.sun') == 'below_horizon' }}"
2019-04-17 22:46:06 +00:00
- service: homeassistant.turn_on
entity_id: switch.zwave_smart_switch_switch
- 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
2019-04-17 22:46:06 +00:00
action:
- service: switch.turn_off
entity_id: switch.office_room
- service: homeassistant.turn_off
entity_id: switch.zwave_smart_switch_switch
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"
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' }}"
2019-04-17 22:46:06 +00:00
- service: homeassistant.turn_on
entity_id: switch.zwave_smart_switch_switch
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
# Front Room:
# Timer Elapsed - Turn OFF lights
###############################################################################
2019-04-17 22:46:06 +00:00
- alias: Frontroom 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_frontroom
2019-04-17 22:46:06 +00:00
condition:
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('input_boolean.working_in_office_room') == 'off' }}"
2019-04-17 22:46:06 +00:00
action:
- service: homeassistant.turn_off
2020-03-02 23:12:53 +00:00
entity_id: switch.zwave_smart_switch_switch
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"
2019-04-17 22:46:06 +00:00
action:
- service: switch.turn_on
entity_id: switch.kitchen
- 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"
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 %}
entity_id: switch.kitchen
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:
2019-04-17 22:46:06 +00:00
- binary_sensor.tv_multi_sensor_sensor
- 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' }}"
action:
- service: light.turn_on
entity_id: light.family_room
data_template:
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"
2019-04-17 22:46:06 +00:00
action:
- service: light.turn_off
entity_id: light.family_room
2019-12-20 15:32:28 +00:00
- delay: "00:00:05"
2019-04-17 22:46:06 +00:00
- service: light.turn_off
entity_id: light.family_room
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"
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
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"
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
2019-12-20 15:32:28 +00:00
- delay: "00:00:05"
2019-04-17 22:46:06 +00:00
- service: light.turn_off
entity_id: light.master_bedroom
2019-12-20 15:32:28 +00:00
# Garage:
# Motion Detected - Turn ON the light and extend timer
#
# Added a condition - if the lights were just turn off in the last 30 seconds,
# do not turn ON the lights again
###############################################################################
2019-04-17 22:46:06 +00:00
- alias: Garage Motion & Timer
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.garage_motion
2019-12-20 15:32:28 +00:00
from: "off"
to: "on"
2019-04-17 22:46:06 +00:00
condition:
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('input_boolean.working_in_garage') | lower == 'on' }}"
2019-04-17 22:46:06 +00:00
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ (as_timestamp(now()) - as_timestamp(states.switch.garage.last_updated)) | int > 30 }}"
2019-04-17 22:46:06 +00:00
action:
- service: switch.turn_on
entity_id: switch.garage
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"
2019-04-17 22:46:06 +00:00
action:
- service: timer.start
entity_id: timer.timer_garage
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"
2019-04-17 22:46:06 +00:00
action:
- service: switch.turn_off
entity_id: switch.garage