Templating in script, passing variable

Hi,

Since a while, I am trying to solve a problem with my script. I believe I am just missing the correct syntax. I would appreciate your help.
The point is I want to monitor the time since zigbee device last reported link quality status. If time exceeds the value send a notification. I have a bunch of devices and I try to avoid creating separated automation entry for each of them.

automation.yaml

  - alias: "Notification - Zigbee sensor not reported status in 1 hour"
    trigger:
      platform: time_pattern
      minutes: "/1"
    condition: []
    action:
      - service: script.zigbee_linkquality

script.yaml

zigbee_linkquality:
  alias: check zigbee linkquality
  sequence:
    - data_template:
        entity_id: "{{ expand('group.zigbee_linkquality') }}"
      service: script.zigbee_linkquality_check

zigbee_linkquality_check:
  alias: check zigbee linkquality last update time
  sequence:
    - condition: template
      value_template: "{{ (as_timestamp(now())-as_timestamp(states.entity_id.last_updated)) > 3600}}"
    - data_template:
        entity_id: "{{ entity_id }}"
      service: notify.notifications_apps_and_emails
      data:
        title: "Zigbee device not reporting"
        message: "{{ ((as_timestamp(now())-as_timestamp(states.entity_id.last_updated)) /60) | int }} minutes since last report of {{ states.entity_id.attributes.friendly_name }}"

groups.yaml

zigbee_linkquality:
  name: Zigbee linkquality
  entities:
    - sensor.0x00158d0aaaaaaaaa_linkquality
    - sensor.0x00158d0bbbbbbbbb_linkquality
    - sensor.0x00158d0ccccccccc_linkquality