Help in automation and arrays

Hello @petro and all.
I’ve decided to use your approach. Your group is created on startup and it’s easy to query the result from the template tab, with this:

{% set ns = namespace(entities = []) %}
{% for e in expand('group.linkquality') %}
  {% if (now() - e.last_updated).seconds > 14400 %}
    {% set ns.entities = ns.entities + [ e.name ~ ' last updated ' ~ relative_time(e.last_updated) ] %}
  {% endif %}
{% endfor %}
{% if ns.entities | length > 0 %}
  {% set message =  "Attention" + ns.entities | join(', ')  %}
{% else %}
  {% set message = "All Okay" %}
{% endif %}
{{ message }}

Now I’ve installed the scheduler (Scheduler card/custom component) to use it i.e. once a week to test the status and send me a message in case there are sensors not updated, with this:

service: notify.xefilbot
data:
  title: '*Update Status*'
  message: '{{ message }}'

I know the scheduler accept as trigger a script, so I would like to put the check above and the action above into a script that should be executed one a week.

Could you (or someone else) help me to put all that together? (check for uptime and send to telegram bot)

Thanks to all!!

Simon