2019-12-20 15:32:28 +00:00
>
2019-04-17 22:46:06 +00:00
{% macro weather_update() -%}
2020-02-05 23:28:38 +00:00
Outside temperature is {{ states('sensor.dark_sky_apparent_temperature') | round(0) }} degrees.
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro uv_levels() -%}
2020-02-05 23:28:38 +00:00
{%- 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 -%}
Current UV index is very high. It is not advised to go out.
{%- elif uv >= 11 -%}
Current UV index is extremely high. It is highly advised to stay indoors.
{%- else -%}
Good UV levels.
{%- endif -%}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro USPS() -%}
2020-02-05 23:28:38 +00:00
{%- if states('sensor.usps_mail') | int > 0 -%}
USPS is going to deliver {{ states('sensor.usps_mail') }} mails today.
{%- endif -%}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro alert_battery_levels() %}
2020-02-05 23:28:38 +00:00
{% 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 -%}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro tesla_status() -%}
2020-02-05 23:28:38 +00:00
{%- if states("sensor.tesla_model_3_range_sensor") != "unknown" -%}
Your Tesla car battery is at {{ states('sensor.tesla_model_3_battery_sensor') }} percent ({{ (states('sensor.tesla_model_3_range_sensor') | int) | round(0) }} miles).
{%- endif -%}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro pollen_levels() -%}
2020-02-05 23:28:38 +00:00
{% if states('sensor.pollen_level') != 'unknown' %}
Pollen level is {{ states('sensor.pollen_level') }}.
{% endif %}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro humidity_status() -%}
2020-02-05 23:28:38 +00:00
Home humidity is {{ states('sensor.dining_room_thermostat_humidity') }} percent.
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro alarm_status() -%}
2020-02-05 23:28:38 +00:00
Your home is {{ "SECURED!" if states('alarm_control_panel.home') == "armed_away" or states('alarm_control_panel.home') == "armed_home" else "UNSECURED!" }}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro single_car_garage_door_status() -%}
2020-02-05 23:28:38 +00:00
{%- 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 -%}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
{%- macro two_car_garage_door_status() -%}
2020-02-05 23:28:38 +00:00
{% 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 %}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro garage_status() -%}
2020-02-05 23:28:38 +00:00
{%- set single_car_garage = single_car_garage_door_status() -%}
{%- set two_car_garage = two_car_garage_door_status() -%}
{%- if single_car_garage | trim == "" and two_car_garage | trim == "" -%}
Both the garage doors are closed.
{%- elif single_car_garage | trim != "" and two_car_garage | trim != "" -%}
Warning! Both garage doors are OPEN!
{% else %}
Warning! {{ single_car_garage }} {{ two_car_garage }}
{%- endif -%}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro plural(name) -%}
2020-02-05 23:28:38 +00:00
{{- "true" if name.endswith("s") else "false" -}}
{%- endmacro -%}
{# a macro that removes all newline characters, empty spaces, and returns formatted text #}
{%- macro cleanup(data) -%}
{% for item in data.split("\n") if item | trim != "" -%}
{{ item | trim }}
{% endfor %}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro light_status() -%}
{%- set lights_switches = ["light.family_room",
"light.master_bedroom" ,
"switch.basement_left" ,
"switch.basement_right" ,
"switch.frontyard_light" ,
"switch.garage" ,
"switch.guest_bedroom" ,
"switch.prayer_room" ,
"switch.kids_bed_accent" ,
"switch.kids_bedroom" ,
"switch.kitchen" ,
"switch.office_room" ,
"switch.wemobackyardlightswitch" ,
"switch.zwave_smart_switch_switch" ] %}
2020-02-05 23:28:38 +00:00
{% for item in lights_switches -%}
{%- if states[item.split('.')[0]][item.split('.')[1]].state == "on" -%}
{%- set friendly_name = states[item.split('.')[0]][item.split('.')[1]].attributes.friendly_name -%}
{{ friendly_name }} {{ 'are' if plural(friendly_name) == "true" else 'is' }} ON.
{% endif %}
{%- endfor -%}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2019-04-17 22:46:06 +00:00
{%- macro mother_of_all_macros() -%}
2020-02-05 23:28:38 +00:00
{{ alarm_status() }}
{{ garage_status() }}
{{ USPS() }}
{{ tesla_status() }}
{{ weather_update() }}
{{ humidity_status() }}
{{ uv_levels() }}
{{ pollen_levels() }}
{{ alert_battery_levels() }}
{{ light_status() }}
2019-04-17 22:46:06 +00:00
{%- endmacro -%}
2019-12-20 15:32:28 +00:00
2020-02-05 23:28:38 +00:00
{{- cleanup(mother_of_all_macros()) -}}