Sensor as_timestamp rendered invalid timestamp after upgrade to 2021.12

I want to display the date and time of an entity on my dashboard but since the last HA update this isn’t possible anymore. The state of my entity is unknown. I have several warnings in my log:

  • sensor.deurbel_laatste_beweging rendered invalid timestamp: 21-12-2021 09:47:34

This is my template:

deurbel_laatste_beweging:
  device_class: timestamp
  value_template: "{{ as_timestamp(states('input_datetime.doorbell_last_motion')) | timestamp_custom('%d-%m-%Y %H:%M:%S',0) }}"
  friendly_name: 'Laatste beweging'

Does someone knowns what I do wrong?

There were some changes around device_class: timestamp in 2021.12. You might want to investigate that.

That isn’t even a valid ISO8601 string.

Yes, I know about the changes around the device_class but I can’t figure out what I have to change to simply display the input sensor in this format: 21-12-2021 09:47:34

You have defined a timestamp sensor, which requires a date and time value in ISO8601 format, but you have not supplied it with a value in the required format. That’s why the message states:

sensor.deurbel_laatste_beweging rendered invalid timestamp: 21-12-2021 09:47:34

How you want the time to appear is different from what a timestamp sensor requires. If you remove device_class: timestamp then you can use whatever date and time format you want. However, the resulting cannot be used in a Time Trigger.

Thx, I removed the device_class: timestamp. This sensor is only for displaying a value,

Hi all, I have 3 sensors set up, 2 of them are fine, however 1 isn’t. I’ve removed device_class from all 3 but when I look at the Developer tools / States, the device_class is still there.

I have done several reboots and checked my customize.yaml and there is no mention of it.

Any ideas?

Thanks.

    sensors:
      leaf_next_update:
        friendly_name: 'Leaf Next Update'
        value_template: "{{ as_timestamp(state_attr('sensor.l333ond_range', 'next_update')) | timestamp_custom('%H:%M') }}"
        unique_id: "96786442132"
      leaf_last_attempt:
        friendly_name: 'Leaf Previous Attempt'
        value_template: "{{ as_timestamp(state_attr('sensor.l333ond_range', 'last_attempt')) | timestamp_custom('%H:%M') }}"
        unique_id: "21348946672"
      leaf_last_update:
        friendly_name: 'Leaf Last Update'
        value_template: "{{ as_timestamp(state_attr('sensor.l333ond_range', 'updated_on')) | timestamp_custom('%H:%M') }}"
        unique_id: "46346789212"