Create a “Days Until” Sensor in Home Assistant

by Danny
0 comment

READING TIME: 5 MINUTES

In this guide, I’m going to show you how to create a Home Assistant “countdown to date” sensor. This sensor can be used in automations or displayed in a Lovelace card and will show you how many days until a certain event.

This a great visual way to keep track of important dates. Sure, you could use the Google Calendar integration to display them in a calendar, or even install Atomic Calendar Revive (like I did for my Birthday Reminder Lovelace card) to display all upcoming events.

But, I wanted a simple way to display just 1 important event. A card that can be added to any dashboard and show a running count of how many days are left until the event is here.


What is a Days Until sensor used for?

A days until, or countdown sensor, will show you the amount of days, weeks, months, etc until a certain event occurs.

I’ve spent a decent amount of time looking for a simple way to accomplish this. I’ve found guides for creating template sensors, python scripts, installing custom countdown components, but all of those were far too time-consuming and most required you to edit your configuration.yaml to add new events. Although I’m no stranger to adding these types of things, I wanted something quick and easy that can be edited from the UI.

Luckily, I stumbled across this awesome HACS addon called Anniversaries that works perfectly. The name is sort of misleading, but it can be used for any important event.

If you are looking to do the same, let’s get started!


Install Anniversaries Integration via HACS

Click HACS from your Home Assistant sidebar. Click the Integrations tab and search for Anniversaries to install all the necessary configuration files.

Once installed, go to Configuration > Integrations > Add Integration. Search for Anniversaries.

For this example, I’m going to add my wedding anniversary date (since I’ve already added Christmas and Halloween)


Setting Up Your First Event Countdown

After clicking the Anniversaries integration, it’s pretty self-explanatory.

Add a friendly name, the date, the unit of measurement (the sensor will always return Days). The one thing I’d recommend changing is the Entity id_prefix.

Change it something like holiday_, birthday_, or leaving the default anniversary_ prefix, otherwise your sensors will look like this:

If you accidentally created your sensor like I did for Christmas, there’s no way to edit it afterwards. You’ll have to delete that integration and recreate it. There’s nothing really wrong a entity ID like that, it just doesn’t make a lot of sense. So, I just wanted to warn you in advance.

After you click Submit, you’ll be brought to another screen where you can change the icons.


Adding Additional Events to Countdown

After adding 1 event you’d like to start tracking, you can start adding more the exact same way.

Configuration > Integrations > Add Integration > search for Anniversaries.

Do this for as many events as you want! On your Integrations tab, they will all show up here:


Add Sensors to Lovelace

Since these get added as basic sensors, you can add them however you’d like. In my opinion, a default Entity card or Picture Entity card work really well for these.

If you have kids, you could also add all of their birthdays to a Glance card like this:


Wrapping Up

I think this is a fantastic and easy way to display the remaining days until an important event. It works for one-time events, recurring events, but it also works as a simple reminder or task-tracking mechanism. Although anniversaries are implied that they are once-a-year events, you can definitely use this for things like:

  • Vehicle maintenance – Oil changes, tire rotation
  • Party reminders
  • Coworker anniversary reminder
  • Replacing air filters
  • Days until payday / bill reminder
  • Taking out the trash (although, the Garbage Collection Card is pretty amazing)

And much more! Once you hit your target date, just edit the date in the integration and it’ll restart the countdown to the next time you want to be reminded to do something. I personally use this for birthdays, anniversaries, big holidays, and added it to my Home Assistant Chore Tracker to countdown the number of days until my daughter earns her allowance.


Smart Home Product Finder

What hub do you currently use?


SmartThings

Home Assistant

Hubitat

Step 1 of 3

What product are you looking to add?


Lights

Locks

Thermostats

Cameras

Garage Door Opener

Switches

Sensors

Motion, Door & Window, Leak

Smart Plugs

Buttons

Step 2 of 3

What protocol?


Z-Wave

Zigbee

Wifi

Step 3 of 3

Retake quiz? Click here!

My Favorite Home Assistant Devices

Below are some of the Home Assistant-compatible devices I personally use in my home. I highly recommend each of them.

The full list of all Home Assistant compatible & recommended devices I use can be found on my Equipment List page.

0 comment

You may also like

Leave a Comment