Automation - Use variables in the action section

I tried to setup a check automation, if my zigbee device is still reporting action/values, or if it lost the connection.
Therefore I tried to build an automation which looks like the code below, but it returns me an data error message.:
" Message malformed: required key not provided @ data[‘action’] "
Is it possible to use variables within an automation?
THX for the help :slight_smile:

description: |-
  Trigger Time 
  0900
  1200
  1500
  1800
  2100
  2400
  0300
mode: single
trigger:
  - platform: time
    at: "09:00:00"
  - platform: time
    at: "12:00:00"
  - platform: time
    at: "15:00:00"
  - platform: time
    at: "18:00:00"
  - platform: time
    at: "21:00:00"
  - platform: time
    at: "00:00:00"
  - platform: time
    at: "03:00:00"
condition: []
action:
  - alias:
    variables:
      actualtemp: {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat', 'temperature')|float }}
  - service: climate.set_temperature
      data:
        temperature: >-
          {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat',
          'temperature')|float + 0.5 }}
      target:
        device_id: ba56c38bd877e0f30ac8219f1489f504
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - if:
      - condition: template
        value_template: "{{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat', 'temperature')|float == actualtemp }}"
    then:
      - service: notify.marceltelegram
        data:
          message: Zigbee Thermostat Error
          title: "*Warning*"
    else:
      - service: climate.set_temperature
        data:
          temperature: >-
            {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat',
            'temperature')|float - 0.5 }}
        target:
          device_id: ba56c38bd877e0f30ac8219f1489f504

Maybe because your “alias” is empty ?

  - alias: "save actual temperature"
    variables:
      actualtemp: {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat', 'temperature')|float }}

@browetd you were right, my fault I didn’t read carefully here. Thank you.

Functional automation.:

alias: Zigbee Connection Trigger
description: >-
  Trigger Time 
  0900
  1200
  1500
  1800
  2100
  2400
  0300
trigger:
  - platform: time
    at: "09:00:00"
  - platform: time
    at: "12:00:00"
  - platform: time
    at: "15:00:00"
  - platform: time
    at: "18:00:00"
  - platform: time
    at: "21:00:00"
  - platform: time
    at: "00:00:00"
  - platform: time
    at: "03:00:00"
condition: []
action:
  - alias: getactualtemp
    variables:
      actualtemp: >-
        {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat',
        'temperature')|float}}
  - service: climate.set_temperature
    data:
      temperature: >-
        {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat',
        'temperature')|float + 0.5 }}
    target:
      device_id: ba56c38bd877e0f30ac8219f1489f504
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - if:
      - condition: template
        value_template: >-
          {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat',
          'temperature')|float == actualtemp }}
    then:
      - service: notify.marceltelegram
        data:
          message: Zigbee Thermostat Error
          title: "*Warning*"
    else:
      - service: climate.set_temperature
        data:
          temperature: >-
            {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat',
            'temperature')|float - 0.5 }}
        target:
          device_id: ba56c38bd877e0f30ac8219f1489f504
mode: single