100 lines
4.0 KiB
YAML
100 lines
4.0 KiB
YAML
>
|
|
{% macro weather_update() -%}
|
|
Outside temperature is {{ states('sensor.dark_sky_apparent_temperature') | round(0) }} degrees.
|
|
{%- endmacro -%}
|
|
|
|
{%- macro uv_levels() -%}
|
|
{%- 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 -%}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro USPS() -%}
|
|
{%- if states('sensor.usps_mail') | int > 0 -%}
|
|
USPS is going to deliver {{ states('sensor.usps_mail') }} mails today.
|
|
{%- endif -%}
|
|
{%- 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_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 -%}
|
|
{%- 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.home') == "armed_away" or states('alarm_control_panel.home') == "armed_home" else "UNSECURED!" -}}
|
|
. Your Home Away Status is set to {{ states('input_boolean.home_mode_away') |upper }}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro single_car_garage_door_status() -%}
|
|
{%- if states('binary_sensor.door_window_sensor_158d0004248d5b') |lower == "on" -%}
|
|
{{ states.binary_sensor.door_window_sensor_158d0004248d5b.attributes.friendly_name }} is OPEN!
|
|
{%- endif -%}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro two_car_garage_door_status() -%}
|
|
{% if states('binary_sensor.door_window_sensor_158d0004231f7b') |lower == "on" %}
|
|
{{ states.binary_sensor.door_window_sensor_158d0004231f7b.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() -%}
|
|
{%- 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 -%}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro plural(name) -%}
|
|
{{- "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 %}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro light_switch_status() -%}
|
|
{% for item in states if item.domain =="light" or item.domain == "switch" -%}
|
|
{%- if item.state == "on" and not item.entity_id.endswith('led') and not item.attributes.friendly_name.endswith('LED') -%}
|
|
{%- set friendly_name = item.attributes.friendly_name -%}
|
|
{{ item.domain }} {{ friendly_name }} {{ 'are' if plural(friendly_name) == "true" else 'is' }} ON.
|
|
{% endif %}
|
|
{%- endfor -%}
|
|
{%- endmacro -%}
|
|
|
|
{%- macro mother_of_all_macros() -%}
|
|
{{ alarm_status() }}
|
|
{{ garage_status() }}
|
|
{{ weather_update() }}
|
|
{{ humidity_status() }}
|
|
{{ uv_levels() }}
|
|
{{ light_switch_status() }}
|
|
{%- endmacro -%}
|
|
|
|
{{- cleanup(mother_of_all_macros()) -}}
|