How do I move Homekit data to a new install?

Mainly for corrupt sd card reasons I’m rebuilding my Hassio instance on a fresh card. I’ve copied all my config / yaml files across and things are back working in Home Assistant. For a number of specific devices I had them setup using Homekit, and they no longer work. I am prompted to use a new code when I open Home Assistant.

Is it possible to move my old Homekit config across to the new install - and if so how do I do that? Thanks in advance. My guess is it might be to do with the .homekit.state file, but I suspect there are others?

It’s the .homekit.state file. To move it, you would need to do the following:

  • Stop the new Home Assistant instance
  • Copy the old .homekit.state file into your config folder. You might need to replace the current one if you’ve already started the new HA instance at least once.
  • Start the new HA instance
  • Your accessories should work now

Thanks but unfortunately that didn’t seem to work for me :frowning:

The .homekit.state file only has a Mac address, config version, paired clients and a private and public key - does that sound right?

Also, every time I restart Home Assistant I get prompted to enter a different Homekit code (I haven’t linked any to iOS on this new install as holding out for getting my old setup back).

I haven’t tested it yet, but those information should be enough for the HomeKit component. Mainly the mac address, paired clients and the keys.

It’s really important to replace the file once HA is fully stopped otherwise it certainly won’t work. Also check your backup file -> paried_clients to be sure the value isn’t empty. If you replace it correctly, you shouldn’t be prompted with a new HomeKit code.

Thanks. Interestingly the paired clients bit was empty…very strange, but then I am rebuilding because of a corrupt/dieing sd card on the old machine. I will see if I can fire it up and get it working again.

I’m using hassio but logged in via SSH, stopped it using terminal command, then used samba to copy across, then used terminal command to start home assistant again. Is that the way to do it - if not any advice appreciated.

The workflow for copying should work.

An empty paired clients part usually means that the file was copied while the new Home Assistant instance was already running. Make sure to fully stop it first. Also check your original file if it list anything under paired clients.

Thanks. When I can get into the old install the file doesn’t have any paired clients. I suspect this might be because I had to boot it on another Pi, so the Mac address might have changed. Or because the card is corrupt.

I think the way forward for me is just to re-setup the devices in iOS, using my new install, and then get my backup procedures in a better process!

1 Like

I’m also trying to move HomeKit devices / pairing data. In my case, I’m migrating a VM from ESXi to Proxmox. I have multiple .state and .aids files for HomeKit in .config.

Since I’m migrating the entire VM and all its data, is there something about these files that might change and lose the HomeKit pairings when starting up in a new environment?