micor changes and clean up.

This commit is contained in:
Mahasri Kalavala
2019-12-20 10:32:28 -05:00
parent a3c869e9e8
commit 87961b393c
45 changed files with 1628 additions and 1728 deletions

View File

@@ -18,7 +18,7 @@
# Update: I added mqtt code to refresh the sensor values dynamically.
# The sensor values update on hourly basis.
#
# PLEASE NOTE THAT THIS PACKAGE USES "DATE" SENSOR. IF YOU SEE THE BIRTHDAY
# PLEASE NOTE THAT THIS PACKAGE USES "DATE" SENSOR. IF YOU SEE THE BIRTHDAY
# VALUES AS "NOT SET", YOU NEED TO ADD THE FOLLOWING TO YOUR CONFIGURATION FILE
#
# sensor:
@@ -27,7 +27,7 @@
# - 'time'
# - 'date'
# - 'date_time'
# - 'time_date'
# - 'time_date'
#
###############################################################################
homeassistant:
@@ -51,32 +51,31 @@ input_label:
name: Mallika's Birthday
###############################################################################
# _ _ _
# /\ | | | | (_)
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
# _ _ _
# /\ | | | | (_)
# / \ _ _| |_ ___ _ __ ___ __ _| |_ _ ___ _ __ ___
# / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
# / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
# /_/ \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
#
#
###############################################################################
automation:
###############################################################################
# Build the excitement
###############################################################################
###############################################################################
# Build the excitement
###############################################################################
- alias: Birthday Countdown 30 Days
initial_state: true
trigger:
platform: state
entity_id:
entity_id:
- input_label.srinika_birthday_days2go
- input_label.hasika_birthday_days2go
- input_label.mallika_birthday_days2go
condition:
- condition: state
entity_id: group.all_devices
state: 'home'
state: "home"
- condition: template
value_template: "{{ trigger.to_state.state | int > 0 and trigger.to_state.state | int < 30 }}"
action:
@@ -84,21 +83,21 @@ automation:
data_template:
message: "{{ trigger.entity_id.split('.')[1].split('_')[0] | title }}'s Birthday is only {{ trigger.to_state.state }} days to go!"
###############################################################################
# Celebrate Birthday!!!
###############################################################################
###############################################################################
# Celebrate Birthday!!!
###############################################################################
- alias: Today is the Birthday
initial_state: true
trigger:
platform: state
entity_id:
entity_id:
- input_label.srinika_birthday_days2go
- input_label.hasika_birthday_days2go
- input_label.mallika_birthday_days2go
condition:
- condition: state
entity_id: group.all_devices
state: 'home'
state: "home"
- condition: template
value_template: "{{ trigger.to_state.state | int == 0 }}"
action:
@@ -106,14 +105,14 @@ automation:
data_template:
message: "Hurray! Today is {{ trigger.entity_id.split('.')[1].split('_')[0] | title }}'s Birthday!"
###############################################################################
# Announce Happy Birthday message every hour starting 7 am until 9 PM
###############################################################################
###############################################################################
# Announce Happy Birthday message every hour starting 7 am until 9 PM
###############################################################################
- alias: Random Birthday Wishes
initial_state: true
trigger:
platform: time_pattern
hours: '/1'
hours: "/1"
minutes: 3
seconds: 00
condition:
@@ -121,18 +120,18 @@ automation:
conditions:
- condition: state
entity_id: group.all_devices
state: 'home'
state: "home"
- condition: time
after: '07:00:00'
before: '21:00:00'
after: "07:00:00"
before: "21:00:00"
- condition: or
conditions:
- condition: template
value_template: "{{ states.input_label.srinika_birthday_days2go.state | int == 0 }}"
value_template: "{{ states('input_label.srinika_birthday_days2go') | int == 0 }}"
- condition: template
value_template: "{{ states.input_label.hasika_birthday_days2go.state | int == 0 }}"
value_template: "{{ states('input_label.hasika_birthday_days2go') | int == 0 }}"
- condition: template
value_template: "{{ states.input_label.mallika_birthday_days2go.state | int == 0 }}"
value_template: "{{ states('input_label.mallika_birthday_days2go') | int == 0 }}"
action:
- service: script.voice_notify
data_template:
@@ -142,34 +141,34 @@ automation:
- service: script.voice_notify
data_template:
message: "Alexa, Sing Happy Birthday Song."
greeting: 'no'
greeting: "no"
- alias: Update Birthdays
initial_state: true
trigger:
- platform: time_pattern
minutes: '/5'
minutes: "/5"
seconds: 00
- platform: homeassistant
event: start
condition:
- condition: template
value_template: "{{ states.input_label.srinika_birthday.state.split('-') | length > 0 }}"
value_template: "{{ states('input_label.srinika_birthday').split('-') | length > 0 }}"
- condition: template
value_template: "{{ states.input_label.hasika_birthday.state.split('-') | length > 0 }}"
value_template: "{{ states('input_label.hasika_birthday').split('-') | length > 0 }}"
- condition: template
value_template: "{{ states.input_label.mallika_birthday.state.split('-') | length > 0 }}"
value_template: "{{ states('input_label.mallika_birthday').split('-') | length > 0 }}"
action:
- service: input_label.set_value
data_template:
entity_id: input_label.srinika_birthday_days2go
value: >
{% set year = states.sensor.date.state.split('-')[0] %}
{% set month = states.sensor.date.state.split('-')[1] %}
{% set date = states.sensor.date.state.split('-')[2] %}
{% set year = states('sensor.date').split('-')[0] %}
{% set month = states('sensor.date').split('-')[1] %}
{% set date = states('sensor.date').split('-')[2] %}
{% if states('input_label.srinika_birthday') != "unknown" %}
{%- set bDayMonth = states.input_label.srinika_birthday.state.split('-')[0] -%}
{%- set bDayDate = states.input_label.srinika_birthday.state.split('-')[1] -%}
{%- set bDayMonth = states('input_label.srinika_birthday').split('-')[0] -%}
{%- set bDayDate = states('input_label.srinika_birthday').split('-')[1] -%}
{%- set numOfDays = ((as_timestamp(strptime(year ~ '-' ~ bDayMonth ~ '-' ~ bDayDate , '%Y-%m-%d')) | timestamp_custom('%j', true) | int ) - (as_timestamp(strptime(year ~ '-' ~ month~ '-' ~ date , '%Y-%m-%d')) | timestamp_custom('%j', true) | int)) -%}
{%- if numOfDays < 0 -%}
{{ numOfDays + 365 }}
@@ -183,12 +182,12 @@ automation:
data_template:
entity_id: input_label.hasika_birthday_days2go
value: >
{% set year = states.sensor.date.state.split('-')[0] %}
{% set month = states.sensor.date.state.split('-')[1] %}
{% set date = states.sensor.date.state.split('-')[2] %}
{% set year = states('sensor.date').split('-')[0] %}
{% set month = states('sensor.date').split('-')[1] %}
{% set date = states('sensor.date').split('-')[2] %}
{% if states('input_label.hasika_birthday') != "unknown" %}
{%- set bDayMonth = states.input_label.hasika_birthday.state.split('-')[0] -%}
{%- set bDayDate = states.input_label.hasika_birthday.state.split('-')[1] -%}
{%- set bDayMonth = states('input_label.hasika_birthday').split('-')[0] -%}
{%- set bDayDate = states('input_label.hasika_birthday').split('-')[1] -%}
{%- set numOfDays = ((as_timestamp(strptime(year ~ '-' ~ bDayMonth ~ '-' ~ bDayDate , '%Y-%m-%d')) | timestamp_custom('%j', true) | int ) - (as_timestamp(strptime(year ~ '-' ~ month~ '-' ~ date , '%Y-%m-%d')) | timestamp_custom('%j', true) | int)) -%}
{%- if numOfDays < 0 -%}
{{ numOfDays + 365 }}
@@ -202,12 +201,12 @@ automation:
data_template:
entity_id: input_label.mallika_birthday_days2go
value: >
{% set year = states.sensor.date.state.split('-')[0] %}
{% set month = states.sensor.date.state.split('-')[1] %}
{% set date = states.sensor.date.state.split('-')[2] %}
{% set year = states('sensor.date').split('-')[0] %}
{% set month = states('sensor.date').split('-')[1] %}
{% set date = states('sensor.date').split('-')[2] %}
{% if states('input_label.mallika_birthday') != "unknown" %}
{%- set bDayMonth = states.input_label.mallika_birthday.state.split('-')[0] -%}
{%- set bDayDate = states.input_label.mallika_birthday.state.split('-')[1] -%}
{%- set bDayMonth = states('input_label.mallika_birthday').split('-')[0] -%}
{%- set bDayDate = states('input_label.mallika_birthday').split('-')[1] -%}
{%- set numOfDays = ((as_timestamp(strptime(year ~ '-' ~ bDayMonth ~ '-' ~ bDayDate , '%Y-%m-%d')) | timestamp_custom('%j', true) | int ) - (as_timestamp(strptime(year ~ '-' ~ month~ '-' ~ date , '%Y-%m-%d')) | timestamp_custom('%j', true) | int)) -%}
{%- if numOfDays < 0 -%}
{{ numOfDays + 365 }}
@@ -216,4 +215,4 @@ automation:
{%- endif -%}
{% else %}
-
{% endif %}
{% endif %}