70 lines
2.6 KiB
YAML
70 lines
2.6 KiB
YAML
>
|
|
{% macro door_status() -%}
|
|
{%- for x in states if x.domain == 'binary_sensor' and 'door_window_sensor' in x.entity_id and x.state == "on" %}
|
|
{{ x.name }} is open.
|
|
{%- endfor %}
|
|
{%- endmacro %}
|
|
|
|
{% macro motion_sensor_status() -%}
|
|
{% for x in states if x.domain == 'binary_sensor' and 'motion_sensor' in x.entity_id and x.state == "on" %}
|
|
{{ x.name }} motion detected
|
|
{%- endfor %}
|
|
{%- endmacro %}
|
|
|
|
{% macro alarm_status() -%}
|
|
Your home security is set to: {{ states('alarm_control_panel.home') | 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() }}
|
|
{{ door_status() }}
|
|
{{ motion_sensor_status() }}
|
|
{{ garage_status() }}
|
|
{{ light_switch_status() }}
|
|
{%- endmacro -%}
|
|
|
|
{{- cleanup(mother_of_all_macros()) -}} |