mysmarthome/packages/door_sensors.yaml

306 lines
12 KiB
YAML
Raw Normal View History

2019-04-17 22:46:06 +00:00
homeassistant:
2019-12-20 15:32:28 +00:00
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: >-
2019-12-20 15:32:28 +00:00
{% if states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == 'on' %}
2019-04-17 22:46:06 +00:00
Open
2019-12-20 15:32:28 +00:00
{% elif states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == 'off' %}
2019-04-17 22:46:06 +00:00
Closed
{% else %}
Unknown
{% endif %}
icon_template: >-
2019-12-20 15:32:28 +00:00
{% set door_status = states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') %}
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: >-
2019-12-20 15:32:28 +00:00
{% if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == 'on' %}
2019-04-17 22:46:06 +00:00
Open
2019-12-20 15:32:28 +00:00
{% elif states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == 'off' %}
2019-04-17 22:46:06 +00:00
Closed
{% else %}
Unknown
{% endif %}
friendly_name: Double Car Garage Door Sensor Status
icon_template: >-
2019-12-20 15:32:28 +00:00
{% set door_status = states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') %}
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 }}"
- platform: mqtt
state_topic: "/kitchen/motion"
name: "Kitchen Camera 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 }}"
- platform: mqtt
state_topic: "/frontroom/motion"
name: "Frontroom Camera 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
- alias: Kitchen Camera Motion Reset
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.kitchen_camera_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: "/kitchen/motion"
2019-12-20 15:32:28 +00:00
payload: "off"
2019-04-17 22:46:06 +00:00
retain: false
- alias: Frontroom Camera Motion Reset
initial_state: true
trigger:
- platform: state
entity_id: binary_sensor.frontroom_camera_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: "/frontroom/motion"
2019-12-20 15:32:28 +00:00
payload: "off"
2019-04-17 22:46:06 +00:00
retain: false
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:
- binary_sensor.two_car_garage_door_tilt_sensor_sensor
- binary_sensor.single_car_garage_door_tilt_sensor_sensor
2019-04-17 22:46:06 +00:00
condition:
- condition: template
2020-03-02 23:12:53 +00:00
value_template: "{{ trigger.from_state.state not in ['unavailable', 'unknown'] }}"
2019-04-17 22:46:06 +00:00
- condition: template
2020-03-02 23:12:53 +00:00
value_template: "{{ trigger.to_state.state not in ['unavailable', 'unknown'] }}"
2019-04-18 02:09:00 +00:00
- condition: template
value_template: "{{ states('input_boolean.garage_door_notifications') == 'on' }}"
2019-04-17 22:46:06 +00:00
action:
- service: switch.turn_on
entity_id: switch.garage
- service: script.notify_me
data_template:
message: >
2019-12-20 15:32:28 +00:00
{% if trigger.to_state.state | lower == "on" %}
{{ trigger.to_state.attributes.friendly_name }} is now OPENED!
{% elif trigger.to_state.state | lower == "off" %}
{{ trigger.to_state.attributes.friendly_name }} is now CLOSED!
{% endif %}
2019-04-17 22:46:06 +00:00
- service: script.voice_notify
data_template:
message: >
{% set doors = "" %}
2019-12-20 15:32:28 +00:00
{% if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == "on" and
states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == "on" %}
2020-03-02 23:12:53 +00:00
{% set doors = "Attention! Both Garage Doors are OPEN" %}
2019-12-20 15:32:28 +00:00
{% elif states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == "off" and
states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == "off" %}
2019-04-17 22:46:06 +00:00
{% set doors = "Both Garage Doors are now CLOSED" %}
{% else %}
{% if trigger.to_state.state | lower == "on" %}
Attention! Your {{ trigger.to_state.attributes.friendly_name }} is now OPENED!
{% elif trigger.to_state.state | lower == "off" %}
Your {{ trigger.to_state.attributes.friendly_name }} is now CLOSED!
{% endif %}
{% endif %}
{{ doors }}
- delay: "00:00:05"
- service: camera.snapshot
data_template:
entity_id: "camera.garage_camera"
2019-12-20 15:32:28 +00:00
filename:
"{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~
(states.automation.notify_garage_door_status.last_triggered ~ '').replace('-','_')
.replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}"
2019-04-17 22:46:06 +00:00
- service: notify.notify_smtp
data_template:
title: 'Garage Door Status {{ now().strftime("%d %h %Y, %I:%M:%S %p") }}'
message: >-
{% set doors = "" %}
2019-12-20 15:32:28 +00:00
{% if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == "on" and
states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == "on" %}
2019-04-17 22:46:06 +00:00
{% set doors = "Both Garage Doors are OPEN" %}
2019-12-20 15:32:28 +00:00
{% elif states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == "off" and
states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == "off" %}
2019-04-17 22:46:06 +00:00
{% set doors = "Both Garage Doors are CLOSED" %}
{% else %}
2019-12-20 15:32:28 +00:00
{% set doors = states.binary_sensor.single_car_garage_door_tilt_sensor_sensor.name ~ " is " ~
('Closed' if states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == 'off' else 'OPEN')
~ " and " ~ states('binary_sensor.two_car_garage_door_tilt_sensor_sensor.name') ~ " is " ~
('Closed' if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == 'off' else 'OPEN') %}
2019-04-17 22:46:06 +00:00
{% endif %}
Your {{doors}} on {{ now().strftime("%d %h %Y, at %I:%M:%S %p") }}. Please check the garage snapshot below.
data:
images:
2019-12-20 15:32:28 +00:00
- "{{ '/home/homeassistant/.homeassistant/www/downloads/camera/garage/garage_' ~
(states.automation.notify_garage_door_status.last_triggered ~ '').replace('-','_')
.replace(' ', '_').replace(':','_').replace('.','_').replace('+','_') ~ '.jpg' }}"
2019-04-17 22:46:06 +00:00
- service_template: >
{% if trigger.to_state.state | lower == "on" %}
switch.turn_on
{% else %}
switch.turn_off
{% endif%}
data:
entity_id: switch.garage
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:
2019-04-17 22:46:06 +00:00
- binary_sensor.aeotec_zw120_door_window_sensor_gen5_sensor
- binary_sensor.back_door_sensor_sensor
condition:
- condition: template
value_template: "{% if trigger.from_state %} True {% else %} False {% endif %}"
action:
- service: script.voice_notify
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 %}
2019-12-20 15:32:28 +00:00
greeting: "no"
2019-04-17 22:46:06 +00:00
only_at_night: >
2020-02-05 23:28:38 +00:00
{% if states('alarm_control_panel.home') == 'armed_home' %}
2019-04-17 22:46:06 +00:00
no
{% else %}
yes
{% endif %}
2020-02-05 23:28:38 +00:00
- alias: When Front Door Opens Turn Front Room Lights ON
initial_state: true
trigger:
platform: state
entity_id: binary_sensor.aeotec_zw120_door_window_sensor_gen5_sensor
to: "on"
condition:
- condition: template
value_template: "{{ states('sun.sun') == 'below_horizon' }}"
action:
- 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:
platform: state
2020-02-05 23:28:38 +00:00
entity_id: binary_sensor.back_door_sensor_sensor
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: template
value_template: "{{ states('sun.sun') == 'below_horizon' }}"
2019-04-17 22:46:06 +00:00
action:
2020-02-05 23:28:38 +00:00
- service: switch.turn_on
entity_id: switch.kitchen
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
2020-02-05 23:28:38 +00:00
entity_id: binary_sensor.garage_door_sensor_sensor
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
value_template: "{{ states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') == 'off' }}"
- condition: template
value_template: "{{ states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') == 'off' }}"
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