Getting Home Assistant uptime in minutes
My Home Assistant installation sends out several "device normal" notifications right after startup. I wanted to avoid being bombarded with useless notifications so I needed to filter out these events. The most obvious condition can be Home Assistant uptime. Basically: send a device status notification only 1-2 minutes after startup. Here is how to do it.
Adding "Uptime" device
- Go to Settings
- Select Devices & Services
- Press ADD INTEGRATION (bottom right blue button)
- Type "uptime" and add the integration with default settings
You should have an uptime entity (under Devices & Services, Entities). The problem is that the uptime is a timestamp with the date and time so you can't directly compare it to a number.
Getting uptime in minutes
Add this code to your
1 2 3 4 5 6 7 8
After restarting Home Assistant you should have an "Ha uptime minutes" entity that can be compared to numerical values and used as a condition in automations.
I release the code into public domain.