To set it as a variable in the developer tools. Something like this, but I don’t know how to do it
{% set value =
New HACS Updates - {{now().strftime('%-d %b, %H:%M') ~ "\n"}} {%- for rep in
state_attr('sensor.hacs','repositories') -%}
- {{rep.display_name }}
{{ " "}}Current: {{rep.installed_version }}
{{ " "}}Latest: {{rep.available_version }}
{{ "\n" }}
{%- endfor -%} {{"\n"}}------{{"\n"}}
%}
I want that “value” to have all that text, but not as text like I putted there, of course… The result of all those “operations”. Any idea how to achieve this as well?
@Troon With the information from both issues, which you already helped me, I have done something different with the initial issue and I made it even better, here is the example, to see what I did:
{% set ns = namespace(value="New HACS Updates - " ~ now().strftime('%-d %b, %H:%M') ~ "\n") %}
{% for rep in state_attr('sensor.hacs','repositories') %}
{% set ns.value = ns.value + "\n - " ~ rep.display_name %}
{% set ns.value = ns.value + "\n Current: " ~ rep.installed_version %}
{% set ns.value = ns.value + "\n Latest: " ~ rep.available_version %}
{% set ns.value = ns.value + "\n" %}
{% endfor %}
{% set ns.value = ns.value + "\n--------------------------------\n\n" %}
{% set ns.value = ns.value + "\n--------------------------------\n\n" %}
{% set ns.value = ns.value + "\n--------------------------------\n\n" %}
{% set ns.value = ns.value + "\n--------------------------------\n\n" %}
{% set text = ns.value.split('\n--------------------------------\n\n') %}
{{ (text[:6]) | join("\n--------------------------------\n\n") }}
Sooo… as you already figured out, with this, If I will get more than 5 similar notifications, I can only show 5 of them and I will still have the “--------” at “the end”, if I have more than 1 notification, as you wanted me to help me in the first place.