Set Variable in Automation

After Update to HA 2026.4.2 Variables in Automation not set.
HA OS is up to date!

In Automation i have set up Variables:

alias: Variablen setzen
variables:
  latest: "{{ state_attr('sensor.garmin_connect_last_activities','last_activities')[0]  }}"
  typekey: "{{ latest.activityType }}"
  id: "{{ latest.activityId }}"
  km: "{{ latest.distance }}"
  hrs: "{{ latest.duration }}"
  kcal: "{{ latest.calories }}"

next Step i write the Variables in input Text (only to Show result)

Type: {{ typekey }} 
ID: {{ id }} 
km: {{ ((km  | float(0)) /1000) | round(2) }} 
hrs: {{ ((hrs | float(0)) /60 /60) | round(2)}} 
kcal: {{ kcal }}

Result is nothing!

Now i test the same with Template:

{% set latest = state_attr('sensor.garmin_connect_last_activities', 'last_activities')[0] %}
{% set typekey = latest.activityType %}
{% set id = latest.activityId %}
{% set km = latest.distance %}
{% set hrs = latest.duration %}
{% set kcal = latest.calories %}

{{ typekey }}
{{ id }}
{{ ((km  | float(0)) /1000) | round(2) }}
{{ ((hrs | float(0)) /60 /60) | round(2)}}
{{ kcal }}

Result is correct:

Anyone a Idea what is the Problem?

Every Month the same, after HA Update I’m any hours work on Fixing in HA, it’s not Funny!

Are you sure the state of the sensor was not unknown or something at the time?

The sensor query is performed at the same time; the automation runs without producing a result, while the template returns a result

That sounds as an issue.

There may be something else going on, so sharing the parts of your automation that leads to this may be important to get better clues.

Also if you are trying to read variables like that from the Template Developer Tools I don’t think works, only the set method as that is all jinja there.

I’ve gone back to version 2026.03.x.

I just don’t feel like spending hours every month getting HA up and running again after an update.

It’s just getting really annoying.

If you want help, please post your full automation as YAML. What is the trigger for the automation?

The thing that jumps out to me as a first potential issue is the use of id as a variable, which is already a keyword associated with the automation. Don’t see why that would change in the latest release though.