The ability to classify a date device class sensor entity for relative time formatting in the front end similar to how is possible for the timestamp device class would be useful for sensors that provide a date instead of a timestamp.
Currently I’ve have to create a few template sensors to convert entities with a date device class into timestamps to achieve a relative time display in the UI.
- sensor:
- name: 'Nest Protect Downstairs Replace'
unique_id: nest_protect_downstairs_replace
icon: mdi:calendar-account-outline
device_class: timestamp
state: >
{% set time = states('sensor.nest_protect_downstairs_replace_by') %}
{% if time != none and is_state('input_boolean.startup_pending','off') %}
{{ time|as_datetime|as_local }}
{% else %} {{ none }}
{% endif %}