2019-12-20 15:32:28 +00:00
|
|
|
>
|
2022-11-30 02:12:30 +00:00
|
|
|
{% 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 %}
|
2019-12-20 15:32:28 +00:00
|
|
|
|
2022-11-30 02:12:30 +00:00
|
|
|
{% 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 %}
|
2019-12-20 15:32:28 +00:00
|
|
|
|
2022-11-30 02:12:30 +00:00
|
|
|
{% macro alarm_status() -%}
|
|
|
|
Your home security is set to: {{ states('alarm_control_panel.home') | upper }}
|
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-09-28 01:29:23 +00:00
|
|
|
{%- if states('binary_sensor.door_window_sensor_158d0004248d5b') |lower == "on" -%}
|
|
|
|
{{ states.binary_sensor.door_window_sensor_158d0004248d5b.attributes.friendly_name }} is OPEN!
|
2020-02-05 23:28:38 +00:00
|
|
|
{%- endif -%}
|
2019-04-17 22:46:06 +00:00
|
|
|
{%- endmacro -%}
|
|
|
|
|
|
|
|
{%- macro two_car_garage_door_status() -%}
|
2020-09-28 01:29:23 +00:00
|
|
|
{% if states('binary_sensor.door_window_sensor_158d0004231f7b') |lower == "on" %}
|
|
|
|
{{ states.binary_sensor.door_window_sensor_158d0004231f7b.attributes.friendly_name }} is OPEN!
|
2020-02-05 23:28:38 +00:00
|
|
|
{% 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
|
|
|
|
2021-08-31 02:07:33 +00:00
|
|
|
{%- macro light_switch_status() -%}
|
|
|
|
{% for item in states if item.domain =="light" or item.domain == "switch" -%}
|
2022-11-30 00:50:52 +00:00
|
|
|
{%- if item.state == "on" and not item.entity_id.endswith('led') and not item.attributes.friendly_name.endswith('LED') -%}
|
2021-08-31 02:07:33 +00:00
|
|
|
{%- set friendly_name = item.attributes.friendly_name -%}
|
2022-11-30 00:50:52 +00:00
|
|
|
{{ item.domain }} {{ friendly_name }} {{ 'are' if plural(friendly_name) == "true" else 'is' }} ON.
|
2020-02-05 23:28:38 +00:00
|
|
|
{% endif %}
|
|
|
|
{%- endfor -%}
|
2019-04-17 22:46:06 +00:00
|
|
|
{%- endmacro -%}
|
2019-12-20 15:32:28 +00:00
|
|
|
|
2022-11-30 02:12:30 +00:00
|
|
|
{% macro mother_of_all_macros() -%}
|
2020-02-05 23:28:38 +00:00
|
|
|
{{ alarm_status() }}
|
2022-11-30 02:12:30 +00:00
|
|
|
{{ door_status() }}
|
|
|
|
{{ motion_sensor_status() }}
|
2020-02-05 23:28:38 +00:00
|
|
|
{{ garage_status() }}
|
2021-08-31 02:07:33 +00:00
|
|
|
{{ light_switch_status() }}
|
2019-04-17 22:46:06 +00:00
|
|
|
{%- endmacro -%}
|
2019-12-20 15:32:28 +00:00
|
|
|
|
2022-11-30 02:12:30 +00:00
|
|
|
{{- cleanup(mother_of_all_macros()) -}}
|