mysmarthome/packages/zones.yaml

217 lines
7.7 KiB
YAML
Raw Normal View History

2019-04-17 22:46:06 +00:00
###############################################################################
# @author : Mahasri Kalavala
# @date : 04/15/2017
# @package : Zone
# @description : All the zones are defined here
###############################################################################
homeassistant:
customize:
input_boolean.home_mode_away:
friendly_name: Away Mode
zone.home:
friendly_name: Home
zone.work:
friendly_name: Office
group.zone_alerts:
order: 40
zone:
- name: work
latitude: !secret work_latitude
longitude: !secret work_longitude
radius: 200
icon: mdi:briefcase
input_boolean:
home_mode_away:
name: Away
2019-08-19 00:21:05 +00:00
initial: "off"
2019-04-17 22:46:06 +00:00
proximity:
home:
2019-08-19 00:21:05 +00:00
devices: device_tracker.life360_suresh
2019-04-17 22:46:06 +00:00
tolerance: 50
unit_of_measurement: mi
2019-08-19 00:21:05 +00:00
work:
devices: device_tracker.life360_suresh
2019-04-17 22:46:06 +00:00
tolerance: 50
unit_of_measurement: mi
###############################################################################
2019-08-19 00:21:05 +00:00
# _ _ _
# /\ | | | | (_)
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
2019-04-17 22:46:06 +00:00
# / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
# / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
2019-08-19 00:21:05 +00:00
#
2019-04-17 22:46:06 +00:00
###############################################################################
automation:
2019-08-19 00:21:05 +00:00
###############################################################################
# Zone based alerting
###############################################################################
2019-04-17 22:46:06 +00:00
- alias: Alert When Someone Enters a Zone
initial_state: true
trigger:
- platform: zone
entity_id:
2019-08-19 00:21:05 +00:00
- device_tracker.life360_hasika
- device_tracker.life360_mallika
- device_tracker.life360_srinika
- device_tracker.life360_suresh
2019-04-17 22:46:06 +00:00
zone: zone.home
event: enter
- platform: zone
2019-08-19 00:21:05 +00:00
entity_id: device_tracker.life360_suresh
2019-04-17 22:46:06 +00:00
zone: zone.work
event: enter
condition:
- condition: template
value_template: "{{ states('input_boolean.zone_alerts') == 'on' }}"
action:
- service: script.notify_me
data_template:
message: >
2019-08-19 00:21:05 +00:00
{{ trigger.entity_id.split('.')[1].split('_')[1] | title}} just entered {{ trigger.zone.attributes.friendly_name }}!
2019-04-17 22:46:06 +00:00
- service: script.voice_notify
data_template:
message: >
2019-08-19 00:21:05 +00:00
{{ trigger.entity_id.split('.')[1].split('_')[1] | title}} just entered {{ trigger.zone.attributes.friendly_name }}!
greeting: "no"
2019-04-17 22:46:06 +00:00
- alias: Alert When Someone Leaves a Zone
initial_state: true
trigger:
- platform: zone
entity_id:
2019-08-19 00:21:05 +00:00
- device_tracker.life360_hasika
- device_tracker.life360_mallika
- device_tracker.life360_srinika
- device_tracker.life360_suresh
2019-04-17 22:46:06 +00:00
zone: zone.home
event: leave
- platform: zone
2019-08-19 00:21:05 +00:00
entity_id: device_tracker.life360_suresh
2019-04-17 22:46:06 +00:00
zone: zone.work
event: leave
condition:
- condition: template
value_template: "{{ states('input_boolean.zone_alerts') == 'on' }}"
action:
- service: script.notify_me
data_template:
2019-08-19 00:21:05 +00:00
message: "{{ trigger.entity_id.split('.')[1].split('_')[1] | title}} just left {{ trigger.zone.attributes.friendly_name }}."
2019-04-17 22:46:06 +00:00
- service: script.voice_notify
data_template:
message: >-
2019-08-19 00:21:05 +00:00
{{ trigger.entity_id.split('.')[1].split('_')[1] | title }} just left {{ trigger.zone.attributes.friendly_name }}.
{% if trigger.entity_id.split('.')[1].split('_')[1] == "suresh" and trigger.zone.attributes.friendly_name | lower == "office" %}
2019-12-20 15:32:28 +00:00
and will be home in {{ (states('sensor.suresh2home') | int) + 5 }} minutes.
2019-04-17 22:46:06 +00:00
{% endif %}
2019-08-19 00:21:05 +00:00
greeting: "no"
2019-04-17 22:46:06 +00:00
2019-08-19 00:21:05 +00:00
###############################################################################
# Welcome family members when they come home
###############################################################################
2019-04-17 22:46:06 +00:00
- alias: Welcome Family
initial_state: true
trigger:
- platform: state
entity_id:
2019-08-19 00:21:05 +00:00
- device_tracker.life360_mallika
- device_tracker.life360_suresh
- device_tracker.life360_srinika
- device_tracker.life360_hasika
from: "not_home"
to: "home"
for: "00:02:00"
2019-04-17 22:46:06 +00:00
condition:
- condition: state
entity_id: input_boolean.zone_alerts
2019-08-19 00:21:05 +00:00
state: "on"
2019-04-17 22:46:06 +00:00
action:
- service: script.notify_me
data_template:
message: >
2019-08-19 00:21:05 +00:00
Welcome home, {{ trigger.entity_id.split('.')[1].split('_')[1] | title }}!
2019-04-17 22:46:06 +00:00
- service: script.voice_notify
data_template:
message: >
2019-08-19 00:21:05 +00:00
"Welcome home, {{ trigger.entity_id.split('.')[1].split('_')[1] | lower }}!"
greeting: "no"
2019-04-17 22:46:06 +00:00
- service: input_boolean.turn_off
entity_id: input_boolean.home_mode_away
2019-08-19 00:21:05 +00:00
##############################################################################
# Alert when every one is away
##############################################################################
2019-04-17 22:46:06 +00:00
- alias: Alert when everyone is AWAY
initial_state: true
trigger:
platform: time_pattern
minutes: 00
2019-08-19 00:21:05 +00:00
seconds: "/30"
2019-04-17 22:46:06 +00:00
condition:
- condition: template
2019-12-20 15:32:28 +00:00
value_template: "{{ states('input_boolean.home_mode_away') == 'off' }}"
2019-04-17 22:46:06 +00:00
- condition: template
value_template: >
2019-12-20 15:32:28 +00:00
{% set suresh = states('device_tracker.life360_suresh') %}
{% set mallika = states('device_tracker.life360_mallika') %}
{% set srinika = states('device_tracker.life360_srinika') %}
{% set hasika = states('device_tracker.life360_hasika') %}
2019-04-17 22:46:06 +00:00
{% if suresh != "home" and mallika != "home" and srinika != "home" and hasika != "home" %}
True
{% else %}
False
{% endif %}
action:
- service: input_boolean.turn_on
entity_id: input_boolean.home_mode_away
- alias: Home Mode Away ON
initial_state: true
trigger:
platform: state
entity_id: input_boolean.home_mode_away
2019-08-19 00:21:05 +00:00
to: "on"
2019-04-17 22:46:06 +00:00
action:
- service: script.home_mode_away
2019-08-19 00:21:05 +00:00
###############################################################################
# Proximity - Send an alert when someone is on their way home
###############################################################################
2019-04-17 22:46:06 +00:00
- alias: Send a message as I get closer to home
initial_state: true
trigger:
platform: numeric_state
entity_id: proximity.home
below: 5
above: 1
condition:
- condition: template
value_template: '{{ states.proximity.home.attributes.dir_of_travel == "towards" }}'
action:
- service: script.notify_me
data_template:
message: "Suresh is on his way home, he is within the 5 miles range. Should be home soon!"
- condition: template
value_template: >
2019-12-20 15:32:28 +00:00
{% set suresh = states('device_tracker.life360_suresh') %}
{% set mallika = states('device_tracker.life360_mallika') %}
{% set srinika = states('device_tracker.life360_srinika') %}
{% set hasika = states('device_tracker.life360_hasika') %}
2019-04-17 22:46:06 +00:00
{% if suresh != "home" and mallika != "home" and srinika != "home" and hasika != "home" %}
True
{% else %}
False
{% endif %}
- service: climate.set_away_mode
data:
entity_id: climate.dining_room
2019-08-19 00:21:05 +00:00
away_mode: "false"
2019-04-17 22:46:06 +00:00
- service: script.notify_me
data_template:
message: "Your Nest thermostat is set to HOME mode. Thank you!"