mirror of
https://github.com/skalavala/mysmarthome.git
synced 2025-09-13 15:05:00 +00:00
micor changes and clean up.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
>
|
||||
>
|
||||
{% macro weather_update() -%}
|
||||
Outside temperature is {{ states.sensor.dark_sky_apparent_temperature.state | round(0) }} degrees.
|
||||
Outside temperature is {{ states('sensor.dark_sky_apparent_temperature') | round(0) }} degrees.
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro uv_levels() -%}
|
||||
{%- set uv = states.sensor.pws_uv.state | int -%}
|
||||
{%- set uv = states('sensor.pws_uv') | int -%}
|
||||
{%- if uv >= 6 and uv <= 7 -%}
|
||||
Current UV index is high. Please be careful outdoors.
|
||||
{%- elif uv >= 8 and uv <= 10 -%}
|
||||
@@ -15,47 +15,47 @@
|
||||
Good UV levels.
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro USPS() -%}
|
||||
USPS is going to deliver {{ states.sensor.usps_mail.state }} mails today.
|
||||
USPS is going to deliver {{ states('sensor.usps_mail') }} mails today.
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro alert_battery_levels() %}
|
||||
{% for item in states if 'battery_level' in item.attributes and item.attributes.battery_level | int > 0 and item.attributes.battery_level | float <= 10.0 -%}{{- item.attributes.friendly_name ~ " battery is less than 10 percent" -}}
|
||||
{%- if loop.first %}, {% elif loop.last %}, {% else %}, {% endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro tesla_status() -%}
|
||||
{%- if states("sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor") != "unknown" -%}
|
||||
Your Tesla car battery is at {{ states.sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor.state }} percent ({{ (states.sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor.state | int) | round(0) }} miles).
|
||||
Your Tesla car battery is at {{ states('sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor') }} percent ({{ (states('sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor') | int) | round(0) }} miles).
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro pollen_levels() -%}
|
||||
Pollen level is {{ states.sensor.pollen_level.state }}.
|
||||
Pollen level is {{ states('sensor.pollen_level') }}.
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro humidity_status() -%}
|
||||
Home humidity is {{ states('sensor.dining_room_thermostat_humidity') }} percent.
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro alarm_status() -%}
|
||||
Your home is {{ "SECURED!" if states('alarm_control_panel.simplisafe') == "armed_away" or states('alarm_control_panel.simplisafe') == "armed_home" else "UNSECURED!" }}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro single_car_garage_door_status() -%}
|
||||
{%- if states.binary_sensor.single_car_garage_door_tilt_sensor_sensor.state|lower == "on" -%}
|
||||
{%- if states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') |lower == "on" -%}
|
||||
{{ states.binary_sensor.single_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro two_car_garage_door_status() -%}
|
||||
{% if states.binary_sensor.two_car_garage_door_tilt_sensor_sensor.state|lower == "on" %}
|
||||
{% if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') |lower == "on" %}
|
||||
{{ states.binary_sensor.two_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro garage_status() -%}
|
||||
{%- set single_car_garage = single_car_garage_door_status() -%}
|
||||
{%- set two_car_garage = two_car_garage_door_status() -%}
|
||||
@@ -67,11 +67,11 @@
|
||||
Warning! {{ single_car_garage }} {{ two_car_garage }}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro plural(name) -%}
|
||||
{{- "true" if name.endswith("s") else "false" -}}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro light_status() -%}
|
||||
{%- set lights_switches = ["light.family_room",
|
||||
"light.master_bedroom",
|
||||
@@ -94,7 +94,7 @@
|
||||
{% endif %}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro mother_of_all_macros() -%}
|
||||
{{ alarm_status() }}
|
||||
{{ garage_status() }}
|
||||
@@ -107,5 +107,5 @@
|
||||
{{ alert_battery_levels() }}
|
||||
{{ light_status() }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{{- mother_of_all_macros() -}}
|
||||
|
||||
{{- mother_of_all_macros() -}}
|
||||
|
@@ -46,23 +46,23 @@
|
||||
|
||||
{#- Provides Home Security System Status -#}
|
||||
{%- macro alarm_status() -%}
|
||||
{%- if states.alarm_control_panel.simplisafe.state | lower == "disarmed" -%}
|
||||
{%- if states('alarm_control_panel.simplisafe') | lower == "disarmed" -%}
|
||||
Your home security system is switched OFF. You may want to turn it ON.
|
||||
{%- elif states.alarm_control_panel.simplisafe.state | lower == "armed_away" -%}
|
||||
{%- elif states('alarm_control_panel.simplisafe') | lower == "armed_away" -%}
|
||||
Your home security system is set to away mode.
|
||||
{%- elif states.alarm_control_panel.simplisafe.state | lower == "armed_home" -%}
|
||||
{%- elif states('alarm_control_panel.simplisafe') | lower == "armed_home" -%}
|
||||
Your home security system is ON, and your home is secured.
|
||||
{%- endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{#- Provides Trash and Recycle Reminder -#}
|
||||
{%- macro trash_recycle_status() -%}
|
||||
{%- set flag = false -%}
|
||||
{%- if states.sensor.trash_day.state | lower == "yes" -%}
|
||||
{%- if states('sensor.trash_day') | lower == "yes" -%}
|
||||
Your trash will be picked up tomorrow. Did you leave the trash bin outside?.
|
||||
{%- set flag = true -%}
|
||||
{%- endif %}
|
||||
{%- if states.sensor.recycle_day.state | lower == "yes" -%}
|
||||
{%- if states('sensor.recycle_day') | lower == "yes" -%}
|
||||
{%- if flag -%}
|
||||
Also, your recycle stuff will be picked up tomorrow as well! Please leave both recycle bin and trash cans outside if you haven't!.
|
||||
{%- else -%}
|
||||
@@ -70,19 +70,19 @@
|
||||
{%- endif -%}
|
||||
{%- endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro outside_weather() -%}
|
||||
{%- if states('sensor.dark_sky_minutely_summary') != "unknown" -%}
|
||||
Outside, it is going to be {{states('sensor.dark_sky_minutely_summary')}}.
|
||||
{%- endif -%}
|
||||
{%- if states('sensor.dark_sky_apparent_temperature') != "unknown" %}
|
||||
The temperature outside is around {{ states.sensor.dark_sky_apparent_temperature.state | round(0)}} degrees.
|
||||
The temperature outside is around {{ states('sensor.dark_sky_apparent_temperature') | round(0)}} degrees.
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro pihole() -%}
|
||||
{%- if states.sensor.ads_blocked_today.state|int > 100 -%}
|
||||
Our internet blocking system has blocked {{states.sensor.ads_blocked_today.state}} ads today.
|
||||
{%- if states('sensor.ads_blocked_today') |int > 100 -%}
|
||||
Our internet blocking system has blocked {{states('sensor.ads_blocked_today') }} ads today.
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
@@ -103,35 +103,35 @@
|
||||
|
||||
{#- Provides Garage Doors Status -#}
|
||||
{%- macro single_car_garage_door_status() -%}
|
||||
{% if states.binary_sensor.single_car_garage_door_tilt_sensor_sensor.state|lower == "on" %}
|
||||
{% if states('binary_sensor.single_car_garage_door_tilt_sensor_sensor') |lower == "on" %}
|
||||
{{ states.binary_sensor.single_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{%- macro two_car_garage_door_status() -%}
|
||||
{% if states.binary_sensor.two_car_garage_door_tilt_sensor_sensor.state|lower == "on" %}
|
||||
{% if states('binary_sensor.two_car_garage_door_tilt_sensor_sensor') |lower == "on" %}
|
||||
{{ states.binary_sensor.two_car_garage_door_tilt_sensor_sensor.attributes.friendly_name }} is OPEN
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro tesla_status() %}
|
||||
{%- if states("binary_sensor.tesla_model_3_5yj3e1ea8jf010610_charger_sensor") != "unknown" -%}
|
||||
Your Tesla Car is {{ 'not' if states.binary_sensor.tesla_model_3_5yj3e1ea8jf010610_charger_sensor.state == "off" }} plugged in.
|
||||
Your Tesla Car is {{ 'not' if states('binary_sensor.tesla_model_3_5yj3e1ea8jf010610_charger_sensor') == "off" }} plugged in.
|
||||
{% endif %}
|
||||
|
||||
{%- if states("sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor") != "unknown" and states("sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor") != "unknown" and states('sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor') | int > 0 -%}
|
||||
Tesla Car battery is at {{ states.sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor.state }}%, and you can drive about {{ (states.sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor.state | int) | round(0) }} miles.
|
||||
Tesla Car battery is at {{ states('sensor.tesla_model_3_5yj3e1ea8jf010610_battery_sensor') }}%, and you can drive about {{ (states.sensor.tesla_model_3_5yj3e1ea8jf010610_range_sensor.state | int) | round(0) }} miles.
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{#- Check for low humidity levels in autumn, winter and high levels during rest of the year -#}
|
||||
{%- macro humidity_status() -%}
|
||||
{%- if states.sensor.season.state| lower == "autumn" or states.sensor.season.state| lower == "winter" %}
|
||||
{%- if states.sensor.dining_room_thermostat_humidity.state | int < 30 -%}
|
||||
{%- if states('sensor.season') | lower == "autumn" or states('sensor.season') | lower == "winter" %}
|
||||
{%- if states('sensor.dining_room_thermostat_humidity') | int < 30 -%}
|
||||
Home humidity is less than 30%.
|
||||
{%- endif -%}
|
||||
{% else %}
|
||||
{%- if states.sensor.dining_room_thermostat_humidity.state | default(0) | int > 60 -%}
|
||||
{%- if states('sensor.dining_room_thermostat_humidity') | default(0) | int > 60 -%}
|
||||
Home humidity is more than 60%.
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
@@ -187,5 +187,5 @@
|
||||
{{- humidity_status() -}}
|
||||
{{- outside_weather() }} Everything else looks good. {{ getGreeting() }}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{{- clean_up(run_script()) -}}
|
||||
|
@@ -6,13 +6,15 @@
|
||||
{%- endmacro %}
|
||||
|
||||
{# Birthday notifications #}
|
||||
{%- macro birthday_countdown( name, days2go ) -%}
|
||||
{%- if days2go == 0 -%}
|
||||
Today is {{name}}'s Birthday!. Happy Birthday to you, my dear {{name}}!!!.
|
||||
{%- elif days2go == 1 -%}
|
||||
Tomorrow is {{name}}'s Birthday! HURRAY!!!
|
||||
{%- elif days2go > 1 and days2go <= 10 -%}
|
||||
{{name}}'s Birthday is in {{days2go}} days! HURRAY!!!
|
||||
{%- macro birthday_countdown(name, days2go) -%}
|
||||
{%if days2go != 'unknown' %}
|
||||
{%- if days2go |int == 0 -%}
|
||||
Today is {{name}}'s Birthday!. Happy Birthday to you, my dear {{name}}!!!.
|
||||
{%- elif days2go |int == 1 -%}
|
||||
Tomorrow is {{name}}'s Birthday! HURRAY!!!
|
||||
{%- elif days2go |int > 1 and days2go |int <= 10 -%}
|
||||
{{name}}'s Birthday is in {{days2go}} days! HURRAY!!!
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
@@ -58,7 +60,7 @@
|
||||
{% else %}
|
||||
{% set days2NextEvent = strptime((now().year ~ "-12-31 12:02:05"), '%Y-%m-%d %H:%M:%S').strftime('%j') | int - (now().strftime('%j') | int) + (strptime(states.calendar.suresh_kalavala.attributes.start_time, '%Y-%m-%d %H:%M:%S').strftime('%j') | int) -%}
|
||||
{% endif -%}
|
||||
{% if days2NextEvent <= (states.input_number.calendar_remind_before_days.state | int) %}
|
||||
{% if days2NextEvent <= states('input_number.calendar_remind_before_days') | int %}
|
||||
Your next event. {{ states.calendar.suresh_kalavala.attributes.message }} . starts
|
||||
{% if days2NextEvent == 0 | int %}
|
||||
today at {{ strptime(states.calendar.suresh_kalavala.attributes.start_time, '%Y-%m-%d %H:%M:%S').strftime('%I:%M %p') }}.
|
||||
@@ -83,7 +85,7 @@
|
||||
{% else %}
|
||||
{% set days2NextEvent = strptime((now().year ~ "-12-31 12:02:05"), '%Y-%m-%d %H:%M:%S').strftime('%j') | int - (now().strftime('%j') | int) + (strptime(states.calendar.holidays_in_india.attributes.start_time, '%Y-%m-%d %H:%M:%S').strftime('%j') | int) -%}
|
||||
{% endif -%}
|
||||
{% if days2NextEvent <= (states.input_number.calendar_remind_before_days.state | int) %}
|
||||
{% if days2NextEvent <= (states('input_number.calendar_remind_before_days') | int) %}
|
||||
{% if days2NextEvent == 0 | int %}
|
||||
Today is {{ states.calendar.holidays_in_india.attributes.message | replace(".", "")}}.
|
||||
{%- elif days2NextEvent == 1 %}
|
||||
@@ -106,7 +108,7 @@
|
||||
{% else %}
|
||||
{% set days2NextEvent = strptime((now().year ~ "-12-31 12:02:05"), '%Y-%m-%d %H:%M:%S').strftime('%j') | int - (now().strftime('%j') | int) + (strptime(states.calendar.holidays_in_united_states.attributes.start_time, '%Y-%m-%d %H:%M:%S').strftime('%j') | int) -%}
|
||||
{% endif -%}
|
||||
{% if days2NextEvent <= (states.input_number.calendar_remind_before_days.state | int) %}
|
||||
{% if days2NextEvent <= (states('input_number.calendar_remind_before_days') | int) %}
|
||||
{% if days2NextEvent == 0 | int %}
|
||||
Today is {{ states.calendar.holidays_in_united_states.attributes.message | replace(".", "")}}.
|
||||
{%- elif days2NextEvent == 1 %}
|
||||
@@ -161,9 +163,9 @@
|
||||
|
||||
{# Drone Flying Weather #}
|
||||
{%- macro drone_weather() -%}
|
||||
{% if states.binary_sensor.good_weather_to_fly_drones.state| lower == "on" and
|
||||
states.device_tracker.life360_suresh.state == "home" and
|
||||
states.sun.sun.state == "above_horizon" %}
|
||||
{% if states('binary_sensor.good_weather_to_fly_drones')| lower == "on" and
|
||||
states('device_tracker.life360_suresh') == "home" and
|
||||
states('sun.sun') == "above_horizon" %}
|
||||
It is now a great weather to fly drone outside.
|
||||
{% endif %}
|
||||
{%- endmacro -%}
|
||||
@@ -202,9 +204,9 @@
|
||||
{{ USPS() }}
|
||||
{{ tesla_status() }}
|
||||
{{ drone_weather() }}
|
||||
{{ birthday_countdown("Mallika", states.input_label.mallika_birthday_days2go.state | int ) }}
|
||||
{{ birthday_countdown("Srinika", states.input_label.srinika_birthday_days2go.state | int ) }}
|
||||
{{ birthday_countdown("Hasika", states.input_label.hasika_birthday_days2go.state | int ) }}
|
||||
{{ birthday_countdown("Mallika", states('input_label.mallika_birthday_days2go')) }}
|
||||
{{ birthday_countdown("Srinika", states('input_label.srinika_birthday_days2go')) }}
|
||||
{{ birthday_countdown("Hasika", states('input_label.hasika_birthday_days2go')) }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{# Call the macro #}
|
||||
|
Reference in New Issue
Block a user