How does the date type work?

I’m trying to add a “last calibrated” date to my ESPHome device, which ideally is populated from the ESPHome side (a hardcoded date that I change when I calibrate the device) and readonly in Home Assistant.

Yes, I could make a text sensor, but where’s the fun in that. (And I was hoping that when it’s a proper date I can build some automations around it.)

It is important that I have a way to say “never”.

I added this to my ESPHome YAML:

datetime:
  - platform: template
    type: date
    name: Last calibration
    optimistic: true

But no entity appeared in Home Assistant. Maybe because it has no value yet? How do I set one, preferably one that shows up as “unknown” or “never” or something like that?

Your yaml works fine - have you added the device to HA in the ESPHome integration?

I use MQTT and all the other entities of the device are discovered, but not the date template one.

Maybe a discovery issue? Try logging an issue on GitHub. They’ll let you know quick enough if it’s not a bug. :smile:

EDIT: do you need to remove then add the device for MQTT discovery to run again? I generally use the API so I’m unsure…