The problem
The new uptime device class doesn't seem to be creatable as a template sensor.
Both timestamp and uptime have the same rule defined in the dev docs:
Requires native_value to return a Python datetime.datetime object, with time zone information, or None.
However the template that works for a timestamp doesn't work for an uptime sensor.
E.g. a template of {{ now() }} is valid for timestamp class, but for uptime class it says:
Invalid datetime: None has uptime device class but provides state 2026-05-03 06:32:00.371103-07:00:<class 'str'> resulting in ''str' object has no attribute 'tzinfo''
(I can't actually find any template that is accepted)
What version of Home Assistant Core has the issue?
2026.5
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Template
Link to integration documentation on our website
https://www.home-assistant.io/integrations/template
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response
The problem
The new uptime device class doesn't seem to be creatable as a template sensor.
Both timestamp and uptime have the same rule defined in the dev docs:
However the template that works for a timestamp doesn't work for an uptime sensor.
E.g. a template of
{{ now() }}is valid for timestamp class, but for uptime class it says:(I can't actually find any template that is accepted)
What version of Home Assistant Core has the issue?
2026.5
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Template
Link to integration documentation on our website
https://www.home-assistant.io/integrations/template
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
No response