feature-requests icon indicating copy to clipboard operation
feature-requests copied to clipboard

Add Datetime Sensor Component

Open freundTech opened this issue 6 months ago • 2 comments

Describe the problem you have/What new integration you would like ESPHome currently provides no datetime sensor component and a corresponding template component. A datetime sensor component could be used to send date and datetimes to Home Assistant where they could then be used in automations. In Home Assistant this would be represented by a sensor with a datetime value.

Please describe your use case for this integration and alternatives you've tried:

Home Assistant sensors can have str, int, float, date, datetime and Decimal values. str values are provided by the ESPHome text sensor component. float values are provided by the sensor component. For most usecases int and decimal also be represented by sensor components, however there is currently no ESPHome component to represent data and datetime valued sensors.

ESPHome does have a datetime compoment, however that corresponds to a Home Assistant Datetime Entity, not a Sensor with datetime value. The difference is that a Datetime Entity can be set by the user while a sensor only provides values to the user.

Additional context

Home Assistant Sensor documentatoin: https://developers.home-assistant.io/docs/core/entity/sensor ESPHome Datetime compoment: https://esphome.io/components/datetime/

freundTech avatar Jul 03 '25 21:07 freundTech

Yes 🚀 , that would be very useful, for example, for data like the last boot time. Is there currently a workaround for such sensors?

tjay avatar Oct 17 '25 11:10 tjay

Yes. I found a workaround after making this issue:

You can use a text sensor with device_class: "timestamp" (datetime) or device_class: "date" (date only) and set the text to a ISO 8601 formatted datetime string. HomeAssistant will parse that string again and display it as a datetime.

freundTech avatar Oct 17 '25 12:10 freundTech