Hey there,
I have chores that I keep track of with input numbers. There’s a threshold (30) that once they reach that, I need to do them. Examples are changing the HVAC filters, etc. Each one increments by 1 if it needs to be done once a month or 0.5 for example if I need to do it every 2 months.
The following template spits out the chores I need to do.
I want to have it organized better where each chore is on a newline. I’m sure this is something simple, but when I do this, and this template basically writes to a text helper that I show on a Dashboard, it’s all wonky and there’s a lot of weird spacing. I’m sure I’m missing something.
Thanks!
>
{%- macro get_chores() -%}
{% set allChores = states.input_number | selectattr('entity_id', 'search', 'chore_') | list %}
{% set data = namespace(pastDueChores = []) %}
{% for chore in allChores %}
{% set currentChoreValue = states(chore.entity_id) | float %}
{% if currentChoreValue > states('input_number.chores_threshold') | float %}
{% set data.pastDueChores = (data.pastDueChores + [chore]) %}
{% endif %}
{% endfor %}
{% for chore in data.pastDueChores %}
{{ (chore.name | capitalize) ~ '.' }}
{% endfor %}
{%- endmacro -%}
{%- macro cleanup(data) -%}
{{ data.split("\n") | join("\n") }}
{%- endmacro -%}
{%- macro mother_of_all_macros() -%}
{% if is_state('binary_sensor.outstanding_chores', 'on') %}
{{ get_chores() }}
{% else %}
No pending maintenance
{% endif %}
{%- endmacro -%}
{{ cleanup(mother_of_all_macros()) }}