homebridge-knx icon indicating copy to clipboard operation
homebridge-knx copied to clipboard

How to preserve Homekit Scenes, Automations, Rooms and Associations for knx accessories

Open migabc opened this issue 4 years ago • 12 comments

Is there an easy way to preserve my Homekit configuration (scenes, automations, rooms, associations, etc) for my knx accessories?

Every time I try to upgrade this plugin and something goes wrong (for whatever reason) even if I later rollback the plugin, along with all the knx_config.json, persist and accessories files I still end up losing all my Homekit scenes, automations, rooms and associations related to these knx devices

A a simple backup and restore of files (or even the whole image) will not preserve my Homekit configs

This quite frustrating as I have spent several hours tweeking all my Homekit configs :-(

This problem only only happens with this homebridge-knx plugin This does not happen with my other homebridge plugins

migabc avatar Nov 06 '20 21:11 migabc

It should. The knx_config.json file gets modified during runtime (first start), so you need to backup that one after the first start, otherwise all devices get new IDs after the restore.

snowdd1 avatar Nov 11 '20 16:11 snowdd1

Nope. It doesn't. Please see what I wrote above:

ven if I later rollback the plugin, along with all the knx_config.json, persist and accessories files I still end up losing all my Homekit scenes, automations, rooms and associations related to these knx devices

A a simple backup and restore of files (or even restoring the whole image) will not restore my lost/removed Homekit configs caused by homebridge-knx failed to start up properly

migabc avatar Nov 11 '20 20:11 migabc

That is strange though. I just moved my whole homebridge instance to a raspberry without loosing anything, even with a new IP address and hardware address on the new hardware. The homebridge instance was immediately recognized by HomeKit.

snowdd1 avatar Nov 11 '20 21:11 snowdd1

Yes, that's true. But if for some reason the knx plugin does not get registered when homebridge starts up, all the knx accessories, scenes, automations, etc will be completely wiped out from Homekit

Even if you rollback (recover your initial config), you will only recover the knx accessories themselves (which will now stay in the default room) - all your previous configurations (Rooms, scenes, automations, etc) related to those accessories will be completely lost

Is there some way of backing up/restoring your Homekit config?

migabc avatar Nov 12 '20 08:11 migabc

That is right and can't be changed AFAIK. Because that is HomeKit clearing its database in the iCloud.

snowdd1 avatar Nov 12 '20 08:11 snowdd1

This problem happend to me when I tried to upgrade homebridge to the lastest version 1.0.6 (needed for someother plugin) - However, this latest version of homebridge (in fact any version >= 1.0) does not support the knx plugin - so it just started up without registering the knx plugin

So, boom - all my 200+ knx accessories were lost Damn :-(

migabc avatar Nov 12 '20 08:11 migabc

P.S: You should put a note stating not to upgrade to latest homebridge version (or at least the necessary configs updates before doing so)

migabc avatar Nov 12 '20 08:11 migabc

Anyway, so there's no way of backing up/restoring the HomeKit database in the iCloud? It would be good if we could do some sort of TimeMachine to get things back to the way they were, say "Yessterday" I'm sure I'm not the only one having this issue

migabc avatar Nov 12 '20 08:11 migabc

I am using the “Controller for Home” App, which allows to backup and restore to some extent. It is not flawless but works for most of the things and can safe some work when restoring... https://apps.apple.com/de/app/controller-for-homekit/id1198176727?l=en

//Christof

giase82 avatar Nov 13 '20 06:11 giase82

ref. migabc's comment Nov 12, 2020 "However, this latest version of homebridge (in fact any version >= 1.0) does not support the knx plugin "

I'm using homebridge v. 1.0.7 and have been struggling with the knx plugin [email protected]. I can see in the homebridge log that the plugin is loaded, however I can not see any reference to the knx_config.json containing a simple device; "ServiceType": "Lightbulb". No accessories appear in homebridge, also when inspecting the knx_config.json after "first start" i see no UID added. (knxd is working; I can switch on/off the "Lightbulb"from command line w. knxtool)

What is the latest homebridge version to support knx plugin, and which knx plugin should be used?

OK, fake news :-), it works with the above versions....

I found the solution, when adding platform in homebridge.config, from: https://github.com/snowdd1/homebridge-knx/issues/163 As I have understood it, it has been a bit back and forth weather changing homebridge.config was required or not in the newer versions, and when trying i listed an additional "platform" section, instead of adding the knx platform to the existing platform section......

Anyway, thanks a lot the first Accessory is in place and working like a charm!!!

fred925 avatar Jan 07 '21 09:01 fred925

@fred925 :

Sorry I cannot support any forks like homebridge-knx-easy. You might:

  • talk to @mariomaurer to create pull requests with his improvements
  • revert to the original

image

snowdd1 avatar Jan 11 '21 08:01 snowdd1

This happens because if homebridge starts without registering the homebridge-knx plugin it will remove all knx accessories from the cachedAccessories file

I found a workaorund. To prevent this you need to remove the write access on the root user for this file:

sudo find / -name cachedAccessories
sudo chmod 444 /var/lib/homebridge/accessories/cachedAccessories

So now whenever an upgrade (example nodejs, etc) is done on the system that prevents homebridge from registering homebridge-knx, the homebridge when starting up will not remove the knx accessories from cachedAccessories and this way we have enough time to troubleshoot the issue and eventually rollback that upgrade that prevented the homebridge-knx plugin from registering without losing all our knx accessories

Note: Whenever you need to reconfigure/update either the config.json or knx_config.json you must re-enable write access on that file by:

sudo chmod 644 /var/lib/homebridge/accessories/cachedAccessories

After that the config.json or knx_config.json will get modified during runtime (only during the first start after the config change), so after that first start after you modified your config, you can then remove the write access on the cachedAccessories file again

migabc avatar Dec 04 '22 09:12 migabc