Display countdown to a set date

Hi all,
I am trying to figure out how to get my esp32 to display the days/month until a certain day.
Basically I want it to say something like “4 Month and 3 Days until Florida vacation” or “We are getting married in 219 Days”

I have been trying different things with templates in HA to write the remaining time in a datetime helper that I would then display, but did not get anywhere.
I am hoping that someone that is more familiar with templates and things can help me.

Thank you,


You can achieve this reasonably easy by using the epoch time. You can even countdown the hours, minutes and seconds if you wanted.

thank you for the hint to use epoch. I finally got it to work.
I had the esp32 deactivated in HA, so it never go the correct time… Once I figured that out, it was fairly easy to set up.
I even managed to use helpers in HA to set the goal date and text for the display.

  - platform: homeassistant
    name: "Reasons"
    id: reason
    entity_id: input_select.countdown_reason
    internal: true

  - platform: homeassistant
    id: goal_date
    entity_id: input_datetime.countdown_days
    attribute: timestamp
    internal: true

And then it’s only a few lines for the display:

      long daysleft = ((id(goal_date).state - (id(ha_time).now().timestamp))/60/60/24);
      it.printf(0, 0,"%ld Days until", (daysleft) );
      it.printf(0, 1,id(reason).state.c_str());