Template-Sensor with time differences

I have a template sensor create which calculates the age of a device in days (which is used in another sensor). Since summer time the value is wrong from midnight to 1:00 o’clock.
How would I get correct values for summer time and for normal time? - Just changing the +01:00 to +02:00 would work, but needs to be adjusted again when normal time starts.
That’s what I tried:

        # age: >-
        #   {{ (now() - as_datetime('2022-12-06 00:00:00+01:00')).days }}
        age: >-
          {{ (now() - (as_datetime('2022-12-06 00:00:00') | as_local)).days }}
{{ (as_timestamp(utcnow()) - as_timestamp('2022-12-06 00:00:00')) / (24*60*60) }}
1 Like

Tried just with utcnow, assuming, that as_datetime with zero offset would be equivalent to utc time, but that still does not go.

{{ (utcnow() - as_datetime('2022-12-06 00:00:00+00:00')).days }}

Now I try your suggestion.
Figured out, that I my bug wasn’t the number of days, but in the template sensor using that value.