Startup time monitoring for Home Assistant

Sometimes you may need to measure the exact time required by Home Assistant to start. This can be especially useful for low-performance Raspberry Pi boards. There is a very good custom component for this made by AlexxIT who is well known as the author of Xiaomi Gateway 3 and SonoffLan components.

We will use another tiny component made by him named StartTime. It does one thing and does it well: makes a sensor that keeps the exact startup time in seconds captured during the last restart of Home Assistant. As it said one can use it to debug their Raspberry Pi configuration or just monitor startup time and send an alert when startup time exceeds some threshold.

The component can be installed manually by copying the folder from the author’s repository into the custom_components folder of your Home Assistant instance or it can be installed via HACS addon manager.

Open Integrations section of HACS page and click EXPLORE & ADD REPOSITORIES. Type Start to find and install “Start Time” component.

The installation process requires a reboot of your Home Assistant instance. Once it is done, you will need to add a single string into your configuration.yaml file and restart your Home Assistant again:

1
start_time:

When the component is installed, you may discover a new sensor in the Developer Tools section of your Home Assistant instance.

Besides total startup time, the sensor also contains loading time for every component in your system in the attributes section. Though, you shouldn’t be expected that disabling a component will significantly reduce Home Assistant startup time since the components are loaded simultaneously.

The only exception here if a component loading time is very close to Home Assistant startup time. In this case, the component can be that bottleneck that delays the whole startup process.

Let’s try to utilize it in our setup. On my Intel© NUC8i3BEH it roughly takes 24 seconds to start Home Assistant right now. I am going to add a simple automation rule to send a notification when startup time exceeds 30 seconds so that I can immediately find out what is the reason for delay:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
alias: Slow startup alert
description: ''
trigger:
  - platform: homeassistant
    event: start
condition:
  - condition: numeric_state
    entity_id: sensor.start_time
    above: '30'
action:
  - service: notify.my_telegram
    data:
      message: 'Startup time is slower than usual: {{states("sensor.start_time")}} sec.'
mode: single

That’s it, as soon as Home Assistant startup time is increased we’ll get a notification about it.

updatedupdated2021-03-162021-03-16
Our coments are powered by remark42, self-hosted, privacy-focused open source comment engine, which doesn't spy on users.

Since we know nothing about you, consider subscribing to the comments' Telegram channel to keep track of comments on this site.