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
|
|
|
|
group.zone_alerts:
|
|
|
|
order: 40
|
|
|
|
|
|
|
|
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:
|
2022-11-30 01:48:51 +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
|
|
|
# _ _ _
|
|
|
|
# /\ | | | | (_)
|
|
|
|
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
|
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:
|
2022-11-30 01:48:51 +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
|
|
|
|
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:
|
2022-11-30 01:48:51 +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
|
|
|
|
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:
|
2022-11-30 01:48:51 +00:00
|
|
|
- device_tracker.life360_mallika
|
|
|
|
- device_tracker.life360_suresh
|
|
|
|
- device_tracker.life360_srinika
|
|
|
|
- device_tracker.life360_hasika
|
2019-08-19 00:21:05 +00:00
|
|
|
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
|
2022-11-30 00:50:52 +00:00
|
|
|
- service: switch.turn_on
|
|
|
|
entity_id: switch.chromecast_monitor
|
2019-04-17 22:46:06 +00:00
|
|
|
|
2019-08-19 00:21:05 +00:00
|
|
|
##############################################################################
|
|
|
|
# Alert when every one is away
|
|
|
|
##############################################################################
|
2022-11-30 00:50:52 +00:00
|
|
|
- alias: Poll Home Away Mode
|
2019-04-17 22:46:06 +00:00
|
|
|
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
|
|
|
action:
|
2022-11-30 00:50:52 +00:00
|
|
|
- service_template: >-
|
2022-11-30 01:48:51 +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') -%}
|
2022-11-30 00:50:52 +00:00
|
|
|
{{ 'input_boolean.turn_on' if suresh != "home" and mallika != "home" and srinika != "home" and hasika != "home" else 'input_boolean.turn_off' }}
|
2019-04-17 22:46:06 +00:00
|
|
|
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!"
|
2022-11-30 01:48:51 +00:00
|
|
|
|
|
|
|
####################################################################################
|
|
|
|
- alias: Srinika Left Home
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: device_tracker.life360_srinika
|
|
|
|
from: "home"
|
|
|
|
to: "not_home"
|
|
|
|
for: "00:02:00"
|
|
|
|
action:
|
|
|
|
- service: switch.turn_off
|
|
|
|
entity_id:
|
|
|
|
- switch.srinika_bedroom
|
|
|
|
- switch.srinika_bedroom_fan
|
|
|
|
- switch.srinika_bedroom_fan_light
|
|
|
|
- light.srinika_led_dimmer_switch
|
|
|
|
- switch.srinika_bedroom_closet
|
|
|
|
- switch.srinika_bedroom_accent_lights
|
|
|
|
|
|
|
|
####################################################################################
|
|
|
|
- alias: Hasika Left Home
|
|
|
|
initial_state: true
|
|
|
|
trigger:
|
|
|
|
- platform: state
|
|
|
|
entity_id: device_tracker.life360_hasika
|
|
|
|
from: "home"
|
|
|
|
to: "not_home"
|
|
|
|
for: "00:02:00"
|
|
|
|
action:
|
|
|
|
- service: switch.turn_off
|
|
|
|
entity_id:
|
|
|
|
- switch.hasika_bedroom
|
|
|
|
- switch.hasika_bedroom_fan
|
|
|
|
- switch.hasika_bedroom_fan_light
|
|
|
|
- light.hasika_led_dimmer_switch
|
|
|
|
- switch.hasika_bedroom_closet
|
|
|
|
- switch.hasika_bed_accent
|