snowdd1 / homebridge-knx

KNX platform shim for homebridge
https://github.com/nfarina/homebridge
GNU General Public License v2.0
97 stars 56 forks source link

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

Open migabc opened 3 years ago

migabc commented 3 years ago

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

snowdd1 commented 3 years ago

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.

migabc commented 3 years ago

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

snowdd1 commented 3 years ago

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.

migabc commented 3 years ago

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?

snowdd1 commented 3 years ago

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

migabc commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

giase82 commented 3 years ago

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

fred925 commented 3 years ago

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 homebridge-knx-easy@0.3.40. 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!!!

snowdd1 commented 3 years ago

@fred925 :

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

image

migabc commented 1 year ago

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