2019-04-17 22:46:06 +00:00
|
|
|
homeassistant:
|
2020-03-21 01:25:56 +00:00
|
|
|
customize:
|
|
|
|
package.door_sensors:
|
2019-04-17 22:46:06 +00:00
|
|
|
sensor:
|
|
|
|
- platform: template
|
|
|
|
sensors:
|
|
|
|
single_car_garage_door_sensor_status:
|
|
|
|
friendly_name: Single Car Garage Door Sensor Status
|
|
|
|
value_template: >-
|
2020-09-28 01:29:23 +00:00
|
|
|
{% if states('binary_sensor.door_window_sensor_158d0004248d5b') == 'on' %}
|
2019-04-17 22:46:06 +00:00
|
|
|
Open
|
2020-09-28 01:29:23 +00:00
|
|
|
{% elif states('binary_sensor.door_window_sensor_158d0004248d5b') == 'off' %}
|
2019-04-17 22:46:06 +00:00
|
|
|
Closed
|
|
|
|
{% else %}
|
|
|
|
Unknown
|
|
|
|
{% endif %}
|
|
|
|
icon_template: >-
|
2020-09-28 01:29:23 +00:00
|
|
|
{% set door_status = states('binary_sensor.door_window_sensor_158d0004248d5b') %}
|
2019-04-17 22:46:06 +00:00
|
|
|
{% if door_status == 'unknown' %}
|
|
|
|
mdi:alert-circle
|
|
|
|
{% else %}
|
|
|
|
{% if door_status == 'on' %}
|
|
|
|
mdi:garage-open
|
|
|
|
{% else %}
|
|
|
|
mdi:garage
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
2019-12-20 15:32:28 +00:00
|
|
|
|
2019-04-17 22:46:06 +00:00
|
|
|
- platform: template
|
|
|
|
sensors:
|
|
|
|
two_car_garage_door_sensor_status:
|
|
|
|
value_template: >-
|
2020-09-28 01:29:23 +00:00
|
|
|
{% if states('binary_sensor.door_window_sensor_158d0004231f7b') == 'on' %}
|
2019-04-17 22:46:06 +00:00
|
|
|
Open
|
2020-09-28 01:29:23 +00:00
|
|
|
{% elif states('binary_sensor.door_window_sensor_158d0004231f7b') == 'off' %}
|
2019-04-17 22:46:06 +00:00
|
|
|
Closed
|
|
|
|
{% else %}
|
|
|
|
Unknown
|
|
|
|
{% endif %}
|
|
|
|
friendly_name: Double Car Garage Door Sensor Status
|
|
|
|
icon_template: >-
|
2020-09-28 01:29:23 +00:00
|
|
|
{% set door_status = states('binary_sensor.door_window_sensor_158d0004231f7b') %}
|
2019-04-17 22:46:06 +00:00
|
|
|
{% if door_status == 'unknown' %}
|
|
|
|
mdi:alert-circle
|
|
|
|
{% else %}
|
|
|
|
{% if door_status == 'on' %}
|
|
|
|
mdi:garage-open
|
|
|
|
{% else %}
|
|
|
|
mdi:garage
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
binary_sensor:
|
|
|
|
- platform: mqtt
|
|
|
|
state_topic: "/garage/motion"
|
|
|
|
name: "Garage Motion"
|
|
|
|
device_class: motion
|
2019-12-20 15:32:28 +00:00
|
|
|
payload_on: "on"
|
|
|
|
payload_off: "off"
|
2019-04-17 22:46:06 +00:00
|
|
|
value_template: "{{ value }}"
|
|
|
|
|
|
|
|
###############################################################################
|
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:
|
|
|
|
- alias: Garage Motion Reset
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.garage_motion
|
2019-12-20 15:32:28 +00:00
|
|
|
to: "on"
|
|
|
|
from: "off"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
2019-12-20 15:32:28 +00:00
|
|
|
- delay: "00:00:30"
|
2019-04-17 22:46:06 +00:00
|
|
|
- service: mqtt.publish
|
|
|
|
data:
|
|
|
|
topic: "/garage/motion"
|
2019-12-20 15:32:28 +00:00
|
|
|
payload: "off"
|
2019-04-17 22:46:06 +00:00
|
|
|
retain: false
|
|
|
|
|
2021-01-10 20:03:52 +00:00
|
|
|
- alias: Turn Garage Lights On When Motion Detected or Door Opened
|
2020-07-17 01:15:43 +00:00
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.motion_sensor_158d000272bf48
|
|
|
|
to: "on"
|
2021-01-10 20:03:52 +00:00
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
2020-07-17 01:15:43 +00:00
|
|
|
action:
|
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.garage
|
|
|
|
|
2019-12-20 15:32:28 +00:00
|
|
|
################################################################################
|
|
|
|
# Notifies when either of the garage door is opened or closed
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Notify Garage Door Status
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
2019-12-20 15:32:28 +00:00
|
|
|
entity_id:
|
2020-09-30 02:36:02 +00:00
|
|
|
- binary_sensor.door_window_sensor_158d0004248d5b # Single car garage
|
2022-12-04 17:38:48 +00:00
|
|
|
- binary_sensor.door_window_sensor_158d0004231f7b # 2 Car Garage
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.garage
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2019-04-17 22:46:06 +00:00
|
|
|
data_template:
|
2022-12-04 17:38:48 +00:00
|
|
|
message: >
|
|
|
|
{% set doors = "" %}
|
|
|
|
{% if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and
|
|
|
|
states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %}
|
|
|
|
{% set doors = "Attention! Both Garage Doors are OPEN" %}
|
|
|
|
{% elif states('binary_sensor.door_window_sensor_158d0004231f7b') == "off" and
|
|
|
|
states('binary_sensor.door_window_sensor_158d0004248d5b') == "off" %}
|
|
|
|
{% set doors = "Both Garage Doors are now CLOSED" %}
|
|
|
|
{% else %}
|
|
|
|
{% if trigger.from_state.state != trigger.to_state.state and trigger.to_state.state | lower == "on" %}
|
|
|
|
{% set doors = "Attention! Your {{ trigger.to_state.attributes.friendly_name }} is now OPENED!" %}
|
|
|
|
{% elif trigger.from_state.state != trigger.to_state.state and trigger.to_state.state | lower == "off" %}
|
|
|
|
{% set doors = "Your {{ trigger.to_state.attributes.friendly_name }} is now CLOSED!" %}
|
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
{{ doors }} - {{ trigger.to_state.attributes.friendly_name }}: from '{{trigger.from_state.state}}'', to: '{{ trigger.to_state.state }}'
|
|
|
|
notify_options:
|
|
|
|
- voice
|
|
|
|
- led
|
|
|
|
- tv
|
|
|
|
- email
|
|
|
|
- telegram
|
2019-04-17 22:46:06 +00:00
|
|
|
- delay: "00:00:05"
|
|
|
|
- service: camera.snapshot
|
|
|
|
data_template:
|
2022-11-30 00:50:52 +00:00
|
|
|
entity_id: "camera.garage"
|
2022-12-04 17:38:48 +00:00
|
|
|
filename: "{{ '/config/www/downloads/camera/garage/garage_' ~
|
2020-09-30 02:36:02 +00:00
|
|
|
((state_attr('automation.notify_garage_door_status', 'last_triggered') |string).replace('-','_')
|
|
|
|
.replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg') }}"
|
2022-12-04 17:38:48 +00:00
|
|
|
# - service: script.notify_family
|
|
|
|
# data_template:
|
|
|
|
# message: >
|
|
|
|
# {% set doors = "" %}
|
|
|
|
# {% if states('binary_sensor.door_window_sensor_158d0004231f7b') == "on" and
|
|
|
|
# states('binary_sensor.door_window_sensor_158d0004248d5b') == "on" %}
|
|
|
|
# {% set doors = "Attention! Both Garage Doors are OPEN" %}
|
|
|
|
# {% elif states('binary_sensor.door_window_sensor_158d0004231f7b') == "off" and
|
|
|
|
# states('binary_sensor.door_window_sensor_158d0004248d5b') == "off" %}
|
|
|
|
# {% set doors = "Both Garage Doors are now CLOSED" %}
|
|
|
|
# {% else %}
|
|
|
|
# {% if trigger.from_state.state != trigger.to_state.state and trigger.to_state.state | lower == "on" %}
|
|
|
|
# {% set doors = "Attention! Your {{ trigger.to_state.attributes.friendly_name }} is now OPENED!" %}
|
|
|
|
# {% elif trigger.from_state.state != trigger.to_state.state and trigger.to_state.state | lower == "off" %}
|
|
|
|
# {% set doors = "Your {{ trigger.to_state.attributes.friendly_name }} is now CLOSED!" %}
|
|
|
|
# {% endif %}
|
|
|
|
# {% endif %}
|
|
|
|
# {{ doors }}
|
|
|
|
# url: >
|
|
|
|
# {{ '/config/www/downloads/camera/garage/garage_' ~
|
|
|
|
# ((state_attr('automation.notify_garage_door_status', 'last_triggered') |string).replace('-','_')
|
|
|
|
# .replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg') }}
|
|
|
|
# notify_options:
|
|
|
|
# - telegram
|
|
|
|
# - email
|
|
|
|
# - tv
|
|
|
|
- service: switch.turn_off
|
2020-09-30 02:36:02 +00:00
|
|
|
entity_id: switch.garage
|
2019-04-17 22:46:06 +00:00
|
|
|
|
2022-12-04 17:38:48 +00:00
|
|
|
###############################################################################
|
2019-12-20 15:32:28 +00:00
|
|
|
# Notify Entry Door Status
|
|
|
|
###############################################################################
|
2020-02-05 23:28:38 +00:00
|
|
|
- alias: Voice Notify Entry Door Status
|
2019-04-17 22:46:06 +00:00
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
2019-12-20 15:32:28 +00:00
|
|
|
entity_id:
|
2020-09-28 01:29:23 +00:00
|
|
|
- binary_sensor.door_window_sensor_158d000424a6d6 # Front Door
|
|
|
|
- binary_sensor.door_window_sensor_158d00040ad8fc # Back Door
|
2021-01-10 20:03:52 +00:00
|
|
|
- binary_sensor.door_window_sensor_158d0004880f30 # Garage Entry Door
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
|
|
|
- condition: template
|
2020-03-14 00:10:10 +00:00
|
|
|
value_template: "{{ trigger.from_state.state not in ['unavailable', 'unknown'] }}"
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: template
|
|
|
|
value_template: "{{ trigger.from_state.state != trigger.to_state.state }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
2022-12-03 16:28:12 +00:00
|
|
|
- service: script.notify_family
|
2019-04-17 22:46:06 +00:00
|
|
|
data_template:
|
|
|
|
message: >
|
|
|
|
{% if trigger.to_state.state | lower == "on" %}
|
|
|
|
Your {{ trigger.to_state.attributes.friendly_name.replace('Sensor', '') }} is OPEN,
|
2020-02-05 23:28:38 +00:00
|
|
|
{% if states('alarm_control_panel.home') == 'armed_home' or
|
|
|
|
states('alarm_control_panel.home') == 'armed_away' %}
|
2019-04-17 22:46:06 +00:00
|
|
|
But your home security system is ON.
|
|
|
|
{% endif %}
|
|
|
|
{% elif trigger.to_state.state | lower == "off" %}
|
|
|
|
Your {{ trigger.to_state.attributes.friendly_name.replace('Sensor', '') }} is CLOSED!
|
|
|
|
{% endif %}
|
2022-12-03 16:28:12 +00:00
|
|
|
notify_options:
|
2022-12-04 17:38:48 +00:00
|
|
|
# - telegram
|
2022-12-03 16:28:12 +00:00
|
|
|
- tv
|
|
|
|
- led
|
2022-12-04 17:38:48 +00:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# Light automations when doors are opened
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
|
2020-02-05 23:28:38 +00:00
|
|
|
- alias: When Front Door Opens Turn Front Room Lights ON
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
2020-09-28 01:29:23 +00:00
|
|
|
entity_id: binary_sensor.door_window_sensor_158d000424a6d6
|
2020-02-05 23:28:38 +00:00
|
|
|
to: "on"
|
|
|
|
condition:
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service: script.frontdoor_cam
|
2020-02-05 23:28:38 +00:00
|
|
|
- condition: template
|
|
|
|
value_template: "{{ states('sun.sun') == 'below_horizon' }}"
|
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.front_room
|
|
|
|
|
|
|
|
- alias: When Back Door Opens Turn Kitchen Lights ON
|
2019-04-17 22:46:06 +00:00
|
|
|
initial_state: true
|
|
|
|
trigger:
|
2020-07-17 01:15:43 +00:00
|
|
|
- platform: state
|
2020-09-28 01:29:23 +00:00
|
|
|
entity_id: binary_sensor.door_window_sensor_158d00040ad8fc
|
2020-07-17 01:15:43 +00:00
|
|
|
to: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service_template: "script.{{ ['patio_cam', 'playarea_cam'] | random }}"
|
2020-02-05 23:28:38 +00:00
|
|
|
- condition: template
|
|
|
|
value_template: "{{ states('sun.sun') == 'below_horizon' }}"
|
|
|
|
- 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
|
|
|
|
2020-02-05 23:28:38 +00:00
|
|
|
################################################################################
|
|
|
|
# When I open the garage door
|
|
|
|
# if it is dark outside, OR
|
|
|
|
# both the garage doors are closed
|
|
|
|
# ==> turn the Garage lights ON, and start timer!
|
|
|
|
################################################################################
|
|
|
|
- alias: Garage Lights On When Door is Opened
|
2019-04-17 22:46:06 +00:00
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
2021-01-10 20:03:52 +00:00
|
|
|
entity_id: binary_sensor.door_window_sensor_158d0004880f30
|
2019-12-20 15:32:28 +00:00
|
|
|
to: "on"
|
2019-04-17 22:46:06 +00:00
|
|
|
condition:
|
2020-02-05 23:28:38 +00:00
|
|
|
condition: or
|
|
|
|
conditions:
|
|
|
|
- condition: template
|
|
|
|
value_template: '{{states.sun.sun.state == "below_horizon"}}'
|
|
|
|
- condition: and
|
|
|
|
conditions:
|
|
|
|
- condition: template
|
2020-09-28 01:29:23 +00:00
|
|
|
value_template: "{{ states('binary_sensor.door_window_sensor_158d0004248d5b') == 'off' }}"
|
2020-02-05 23:28:38 +00:00
|
|
|
- condition: template
|
2020-09-28 01:29:23 +00:00
|
|
|
value_template: "{{ states('binary_sensor.door_window_sensor_158d0004231f7b') == '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:
|
2020-02-05 23:28:38 +00:00
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.garage
|
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.timer_garage
|
2021-01-10 20:03:52 +00:00
|
|
|
|
2022-12-04 17:38:48 +00:00
|
|
|
###############################################################################
|
|
|
|
# MASTER BATHROOM AUTOMATIONS
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Only turn ON lights at 25% at night
|
|
|
|
#
|
2021-01-10 20:03:52 +00:00
|
|
|
- alias: Master Bathroom Door Opened After Dark
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: binary_sensor.door_window_sensor_158d000424718f
|
|
|
|
to: "on"
|
|
|
|
condition:
|
|
|
|
- condition: template
|
2022-11-30 00:50:52 +00:00
|
|
|
value_template: '{{states("sun.sun") == "below_horizon"}}'
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service: light.turn_on
|
|
|
|
entity_id: light.master_bathroom_lights
|
|
|
|
data:
|
|
|
|
brightness: 64 # 25% of brightness
|
|
|
|
transition: 5
|
|
|
|
|
|
|
|
- alias: Master Bathroom Door Opened During The Day
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: binary_sensor.door_window_sensor_158d000424718f
|
|
|
|
to: "on"
|
|
|
|
condition:
|
|
|
|
- condition: template
|
2022-11-30 00:50:52 +00:00
|
|
|
value_template: '{{states("sun.sun") == "above_horizon"}}'
|
2021-01-10 20:03:52 +00:00
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service: light.turn_on
|
|
|
|
entity_id: light.master_bathroom_lights
|
|
|
|
data:
|
2022-11-30 00:50:52 +00:00
|
|
|
brightness: 254 # 100% of brightness
|
|
|
|
transition: 5
|
|
|
|
|
|
|
|
- alias: Master Bathroom Toilet Door Opened
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: binary_sensor.door_window_sensor_158d00044e5cb3
|
|
|
|
to: "on"
|
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.master_bathroom_toilet_light
|
|
|
|
|
|
|
|
- alias: Turn off Master Bathroom Toilet if the door is open for too long
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: binary_sensor.door_window_sensor_158d00044e5cb3
|
|
|
|
to: "on"
|
|
|
|
for:
|
|
|
|
minutes: 3
|
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service: switch.turn_off
|
|
|
|
data_template:
|
|
|
|
entity_id: switch.master_bathroom_toilet_light
|
|
|
|
|
2022-12-04 17:38:48 +00:00
|
|
|
###############################################################################
|
|
|
|
# GUEST BATHROOM AUTOMATIONS
|
|
|
|
###############################################################################
|
2022-11-30 00:50:52 +00:00
|
|
|
|
|
|
|
- alias: Guest Bathroom Door Opened
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
platform: state
|
|
|
|
entity_id: binary_sensor.door_window_sensor_158d00045ab168
|
|
|
|
to: "on"
|
|
|
|
condition:
|
|
|
|
- condition: state
|
|
|
|
entity_id: input_boolean.light_automations
|
|
|
|
state: "on"
|
|
|
|
action:
|
|
|
|
- service: switch.turn_on
|
2022-12-03 16:28:12 +00:00
|
|
|
entity_id: switch.guest_bathroom_lights
|