ilcato / homebridge-Fibaro-HC2

Homebridge plugin for Fibaro Home Center 2 (and Home Center Lite ...)
Apache License 2.0
66 stars 27 forks source link

Changes to virtual devices not updated #35

Closed NookyDo closed 7 years ago

NookyDo commented 7 years ago

Hi together,

I am using homebridge on Raspberry 3 B and together with the Fibaro HC2 Plugin.

It all works great. All devices (sensors etc) are added and included perfectly. In example virtuall devices with multiple buttons are included as single devices (one for each button / function) which is fine.

But: If i change an devlice (for example if i add a button / funktion to a virtual device) there seems to be no chance to get this into homebridge and Apple Home app.

It does not show up as new device. Maybe the reason is, that an existing device is not / never checked again after it has been added once?

Or is there a trick how to do that?

thank you / regards

ilcato commented 7 years ago

delete accessories folder and restart homebridge

NookyDo commented 7 years ago

does this delete all accessories? So all configurations and maybe scenes are gone that I already made in the home app?

ilcato commented 7 years ago

No, the folder is only a cache.

NookyDo commented 7 years ago

I tried that - but now in the App (Apple Home App) all devices are gone - everything is empty now - what can I do?

NookyDo commented 7 years ago

problem seems to be that homebridge does not start anymore now.. it stopps at:

[2016-10-11 11:07:51] Loading 0 accessories... Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐
│ xxxxxx
└────────────┘

Plugin - DidFinishLaunching [2016-10-11 11:07:51] [FibaroHC2] Fetching Fibaro Home Center rooms ... events.js:141 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE :::51826 at Object.exports._errnoException (util.js:907:11) at exports._exceptionWithHostPort (util.js:930:20) at Server._listen2 (net.js:1250:14) at listen (net.js:1286:10)

ilcato commented 7 years ago

You have another instance of homebridge running (EADDRINUSE: Address in use). Stop it and relaunch homebridge.

NookyDo commented 7 years ago

ok understand - that this is not the reason for the empty app..

because I restarted the rasperry several times (and so also the homebridge) and the app (and the accessory folder) now stays empty

Du you have an idea?

NookyDo commented 7 years ago

oh stopp - now it was filled and everything is back again - somehow it needed to start 3 times..

But all configurations are gone now.. All devices are in "standardroom" now and not anymore in the configured rooms.. and all scenes of the homekit app are also gone..

ilcato commented 7 years ago

for importing the rooms and the association with devices use the iOs app: ilcato toolkit on the App Store.

NookyDo commented 7 years ago

ok but als the scenes that I had defined within the Appe Home app - they are gone now since I deleted the accessories folder?

NookyDo commented 7 years ago

..and if so (if they are gone now and I have to redefine them again) - what is the best solution for next time when i change something to a virtual device? To get these changes into the homekit? Is there a better solution than deleting the accessory folder which also destroys the whole room setup and deletes all homekit scenes?

ilcato commented 7 years ago

Deleting the accessories folder should not destry the room setup and homekit scenes. Try it again please.

ilcato commented 7 years ago

with a simple scenario

NookyDo commented 7 years ago

it somehow seems to be a problem in combination with the IOS10 native HOME app.. the scenes are lost there. I also added a new button to an existing virtual device - even with deleting the accessories folder and restarting, it does not show up in the Home app

But in other Apps like "Eve" the news buttos does show up correctly - and also the lost scenes are still available there.. but not in the Apple Home app.. strange.. any idea?

There should not be any difference between the devices and scenes shown in different apps - right?

The new button of the virtual device shows up in EVE but does not show up in HOME and also does not show up in your Ilcato Toolkit

ilcato commented 7 years ago

Are you on iOs 10.0.1?

NookyDo commented 7 years ago

No - on 10.0.2

ilcato commented 7 years ago

I'm on 10.0.1 and it works as expected.

NookyDo commented 7 years ago

have you tried to:

Can you reproduce that?

regards

ilcato commented 7 years ago

will test tonight

NookyDo commented 7 years ago

Found out something more which might help you to debug all this - this seems to be the issue why the homeKit Scenes (created in the Apps) show in some apps and in some not:

Your process of deleting the Accessory-Folder seems to create new IDs for each device on HomeKit / App Side (or maybe even in the Bridge / Plugin?)

Thats why the App Scenes are still there (existing), but no more actions (device + action) is linked to them. The scenes are now empty without function.

And these empty scenes semm to be handeled different from different apps. The App "eve" still shows them and you can assign new actions to them. But the Appe HOME app seems to not show empty scenes anymore - thats why I was not able to find them there.. After using "Eve" to asign devices with actions again to the old scenes, they do appear in apple HOME again.

So this explains why scenes disapear in the own app but not in the other app.

But question still is: why do all devices get new IDs or do get unlinked from scenes and rooms when the Accessories Folder was deleted?

And isn't there a better way to get changes of virtual devices into the homebridge? Like scanning all devices for changes on homebridge startup - so after changes, it is enough to restart homebridge? And to make sure devices are not updated by deleting the old once and creating new once but updating the existing once so they do not get unlinked from the rooms and scenes..

hope to help you somehow with my explanations - great work with that plugin!! regards

ilcato commented 7 years ago

Found a bug in the plugin. It should find new or modified accessory only by restarting homebridge. No need to delete accessories folder. It is correct that removing accessories folders new id are generated for existing accessories with all the implication that you described. Will try to fix the bug asap.

ilcato commented 7 years ago

@NookyDo, I think I have fixed the bug and complete the mechanism that allows to automatically update adding, removing and modifying accessories from HC2 without corrupting homekit database. Do you mind testing the new version ? It's here. Thanks

NookyDo commented 7 years ago

@ilcato OK no problem - what exactly do I have to do to do the update?

Download the index.js and replace it in the raspery and reboot? Or anything else? Can you please write what and where (path) I exactly have to do / replace? Just to be sure to do nothing wrong :)

ilcato commented 7 years ago

Yes, replace the file and restart homebridge. The path is: /usr/lib/node_modules/homebridge-fibaro-hc2 or /usr/local/lib/node_modules/homebridge-fibaro-hc2

NookyDo commented 7 years ago

Hi @ilcato bringing in new devices and update during reboot works fine if the devices are new.. great!

But it still seems as if updated devices are nor recognised.

So if we create a new virtual device (i.e. with botton "open" and button "close") it shows up in HOME after reboot. Thats perfect.

But if I edit this device in fibaro and add a third button "TEST" and reboot the raspberry, the button "TEST" does not show up.

Can you please test this?

ilcato commented 7 years ago

I tried it and it works for me by killing the iOs app and restarting it.

NookyDo commented 7 years ago

Now on the second trial it does not work at all - even after several reboots.. I added an "slider" to a virtual device.. All devices show "no connection" - seems as if homebridge is not running anymore.. is there an errorlog I can use to see whats wrong? Can you please post the whole command to show / view that errorlog?

ilcato commented 7 years ago

The error log position depends on how do you run homebridge. Are you starting automatically at boot time ?

NookyDo commented 7 years ago

yes I do..

ilcato commented 7 years ago

So you specify where the error log is in the startup script. Normally it's in the .homebridge folder

ilcato commented 7 years ago

I retried the use case you mentioned and it works.

ilcato commented 7 years ago

Were you able to find the log?

NookyDo commented 7 years ago

Hi @ilcato sorry for the late replay..

It was some work to get the starting script working with a defined errorlog.. my first script was without error output..

So this is the error I always get now during startup:

* WARNING * The program 'node' uses the Apple Bonjour compatibility layer of Avahi. * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node * WARNING * The program 'node' called 'DNSServiceRegister()' which is not supported (or only supported partially) in the Apple Bonjour com$ * WARNING * Please fix your application to use the native API of Avahi! * WARNING * For more information see http://0pointer.de/avahi-compat?s=libdns_sd&e=node&f=DNSServiceRegister /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:222 throw new Error("Cannot add a bridged Accessory with the same UUID as another bridged Accessory: " + existing.UUID); ^

Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: 15c8d453-9bec-466a-907d-65be0a881cb1 at Bridge.Accessory.addBridgedAccessory (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:222:13) at Server._configCachedPlatformAccessories (/usr/local/lib/node_modules/homebridge/lib/server.js:345:18) at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:80:8) at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10) at Object. (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10)

ilcato commented 7 years ago

It seems a problem with the "migration" of the old accessory cache. Can you test on a clean base?

NookyDo commented 7 years ago

@ilcato if I now delete the accessories cache it throws the following error:

[2016-10-24 17:20:21] Loading 1 platforms... [2016-10-24 17:20:21] [FibaroHC2] Initializing FibaroHC2 platform... [2016-10-24 17:20:22] Loading 0 accessories... Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐
│ xxxxxxxxxxxxxxxxx │
└────────────┘

Plugin - DidFinishLaunching events.js:141 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE :::51826 at Object.exports._errnoException (util.js:907:11) at exports._exceptionWithHostPort (util.js:930:20)

ilcato commented 7 years ago

You have homebridge already running: EADDRINUSE You need to kill it before running it again.

NookyDo commented 7 years ago

OK after a complete re-installation (uninstall and install of your plugin - copying the new index) I gut it running again..

But update of devices does still not work..

If I add a new button on an existing and integrated virtual device, it does not show up after rebooting the raspberry..

ilcato commented 7 years ago

I made this test:

How do you start homebridge? Which version of node.js do you have? Which version of homebridge do you have?