2019-04-17 22:46:06 +00:00
|
|
|
###############################################################################
|
|
|
|
# @author : Mahasri Kalavala
|
|
|
|
# @date : 11/07/2017
|
|
|
|
# @package : Work From Home (wfh)
|
2019-08-19 00:21:05 +00:00
|
|
|
# @description : Reminds me to Get Up and Walk around the house once
|
2019-04-17 22:46:06 +00:00
|
|
|
# every 30 minutes during Work From Home days
|
|
|
|
###############################################################################
|
|
|
|
homeassistant:
|
|
|
|
customize:
|
|
|
|
timer.wfh_timer:
|
|
|
|
hidden: true
|
|
|
|
|
|
|
|
timer:
|
|
|
|
wfh_timer:
|
2019-08-19 00:21:05 +00:00
|
|
|
duration: "00:30: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
|
|
|
# / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
|
|
|
|
# / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
|
|
|
|
# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
|
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
|
|
|
# Start WFH timer if Suresh is HOME during weekdays between 10 AM and 5 PM
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: WFH Timer Start
|
|
|
|
initial_state: false
|
|
|
|
trigger:
|
|
|
|
- platform: time_pattern
|
2019-08-19 00:21:05 +00:00
|
|
|
minutes: "/5"
|
2019-04-17 22:46:06 +00:00
|
|
|
seconds: 00
|
|
|
|
condition:
|
|
|
|
- condition: template
|
2019-12-20 15:32:28 +00:00
|
|
|
value_template: "{{ states('binary_sensor.workday_sensor') == 'on' }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
- condition: template
|
2019-08-19 00:21:05 +00:00
|
|
|
value_template: "{{ now().hour|int >= 10 and now().hour|int < 17 }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
- condition: template
|
2019-12-20 15:32:28 +00:00
|
|
|
value_template: "{{ states('timer.wfh_timer') == 'idle' }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
- condition: template
|
2019-12-20 15:32:28 +00:00
|
|
|
value_template: "{{ states('device_tracker.life360_suresh') == 'home' }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: timer.start
|
|
|
|
entity_id: timer.wfh_timer
|
|
|
|
|
2019-08-19 00:21:05 +00:00
|
|
|
# Timer elapsed... Remind Suresh to take a quick walk
|
|
|
|
# Restart the timer ONLY if the time is betwen office hours (10 AM and 5 PM)
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Timer Elapsed - Take a walk
|
|
|
|
initial_state: false
|
|
|
|
trigger:
|
|
|
|
- platform: event
|
|
|
|
event_type: timer.finished
|
2019-08-19 00:21:05 +00:00
|
|
|
event_data:
|
2019-04-17 22:46:06 +00:00
|
|
|
entity_id: timer.wfh_timer
|
|
|
|
action:
|
|
|
|
- service_template: >
|
|
|
|
{% if now().hour | int >= 10 and now().hour | int < 17 %}
|
|
|
|
timer.start
|
|
|
|
{% else %}
|
|
|
|
timer.cancel
|
|
|
|
{% endif %}
|
|
|
|
entity_id: timer.wfh_timer
|
|
|
|
- condition: template
|
2019-08-19 00:21:05 +00:00
|
|
|
value_template: "{{ now().hour|int >= 10 and now().hour|int < 17 }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
- service: script.voice_notify
|
|
|
|
data_template:
|
|
|
|
message: "It is time to stand up and walk around!"
|
|
|
|
|
2019-08-19 00:21:05 +00:00
|
|
|
# Cancel timer (if active) When Suresh left home
|
|
|
|
###############################################################################
|
2019-04-17 22:46:06 +00:00
|
|
|
- alias: Cancel WFH Timer When Suresh Leaves Home
|
|
|
|
initial_state: false
|
|
|
|
trigger:
|
|
|
|
- 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.home
|
|
|
|
event: leave
|
|
|
|
condition:
|
|
|
|
- condition: template
|
2019-12-20 15:32:28 +00:00
|
|
|
value_template: "{{ states('timer.wfh_timer') == 'active' }}"
|
2019-04-17 22:46:06 +00:00
|
|
|
action:
|
|
|
|
- service: timer.cancel
|
|
|
|
entity_id: timer.wfh_timer
|