Automation to Delay Homekit Start - Not Working

I recently set the homekit component to not autostart when HA starts/restarts so that everything can initialize first. Following the docs here, I set up an automation to run homekit.start 3 minutes after homeassistant.start event fires. However, Homekit won’t autostart and I have to manually call the homekit.start service to get it up. Disclosure: while I’m not new to code and programming, this is my 3rd automation on the HA platform.

Here’s my automation from automations.yaml:

- id: '1547628292756'
  alias: Start Homekit
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - delay:
      minutes: 3
  - service: homekit.start

Any help would be greatly appreciated.

Looks correct to me. If you look at that automation on the States page, is its state on? Also, what is the value of its last_triggered attribute?

I also have an automation to delay the start of HomeKit. However, my version is indented differently.

Mine:

- alias: 'Start HomeKit'
  hide_entity: true
  trigger:
    - platform: homeassistant
      event: start
  action:
    - delay: 00:00:05
    - service: homekit.start

Yours:

- id: '1547628292756'
  alias: Start Homekit
  trigger:
  - event: start
    platform: homeassistant
  condition: []
  action:
  - delay:
      minutes: 3
  - service: homekit.start

@123, AFAIK those indentation differences are insignificant. Both are equivalent. Except for the delay…

@chipriley, I think delays can be entered that way, but I don’t know that I’ve ever checked. If the automation is on, and it’s still not working, try changing the delay line to:

  - delay: '00:03:00'

or even

  - delay: 180

But I really don’t think that’s it. I suspect it’s just been turned off somehow. A lot of people seem to be having that issue all of a sudden.

The documentation suggests one can specify the delay value on a separate line (using milliseconds, seconds, minutes, hours, or days).

If both indenting and minutes are valid then it must be that other thing (that you mentioned) that seems to be plaguing many users who recently upgraded: automations are disabled. :frowning:

{
  "last_triggered": null,
  "id": "1547628292756",
  "friendly_name": "Start Homekit"
}

State: off

Looks like it’s the ‘other thing’, namely disabled automations.

I believe the required magic is to add initial_state: true to the automation and restart Home Assistant.

Alternately, go to the dev-service page, select automation.turn_on, leave the entity field blank, and click Call Service. Restart HA and see if HomeKit support starts after a 3 minute delay.

Do these automations, when you restart Home Assistant, force all the homekit items back to the “room” where the bridge exists? I believe I have a similar delay, but on every HA restart I have to reassign all my devices to favourites and rooms.

Shouldn’t have to set the initial state. All you should have to do is turn it back on. And the easiest way to do that is to find it on the States page, click the box with the arrow in it to the left of it, and in the dialog that pops up, click the toggle.

I sure hope whatever seems to be disabling people’s automations is a one time thing, and the state is remember through restarts after that. If not, then there’s a big problem that needs fixing.

Now I feel like an idiot. Never thought to just “turn it on”. Not sure what happened but my other automations were set to on. Worked like a champ. Thanks @pnbruckner!

Thanks! I’m beginning to understand that, although the complaints may sound the same (automations have stopped after upgrading to 0.84/0.85), the reason for the failure differs and is based on the version.

In 0.84 there was a breaking change in how data was stored to have it survive a restart (persist states from one session to another). The byproduct of this modification was that on the initial startup after an upgrade, Home Assistant didn’t know an automation’s previous state so it defaulted to ‘off’. The general solution offered was to use one of the two fixes I described in my previous post.

In 0.85, I don’t know what’s causing the issue but automations are disabled. The solution is as simple as you’ve described, just turn them back on via the States page.

Having similar issues. I can’t find a service homekit.start. Am I doing something wrong?

Do you have homekit defined in configuration.yaml?

homekit:
  auto_start: false

Yes. I followed the whole tutorial

That’s odd. I definitely see homekit.start on the Services page.

I suggest restarting Home Assistant and then checking the system log for any warnings or errors when Home Assistant attempts to initialize the Homekit component.

Look for any log entries containing [pyhap.accessory_driver]

Hi I have the same request.

Every time I reload HA I lose all my Homekit settings and have to rename them and place them in the correct room in Homekit. I’ve read somewhere that this is because homekit is sending info for items that is not available/loaded yet in HA. so the solution is indeed a delayed start after restart. But I cant find anywhere how to prevent autostart for homekit integration and start it with a couple of minutes delay. Hope someone can give a detailed step by step plan how to do this.

Thanks

This automation to delay start to HomeKit apple doesn’t work anymore with update of Home Assistant, now to work it needs to add to configuration yaml this:

homekit:
autostart:
- delay: 00:00:30