[RELEASE] HubConnect - Share Devices across Multiple Hubs (no longer SmartThings!)

Just so everyone else knows. It looks like setting up HSM send and receive for all of my hubs is what was causing my server hub to lockup. I turned off the sharing of HSM status and no lockups for 20+ hours.

everything was working great until this most recent update. not sure what happened. i’m getting a lot of this in my homebridge logs:

[5/18/2019, 6:01:28 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:29 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:30 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:31 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:32 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:33 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:34 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:35 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:36 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:37 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:38 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:39 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:40 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:41 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97
[5/18/2019, 6:01:42 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 97

Can you get me all of the output from Homebridge when it starts up? This way I can tell more and see what is going on

well.... i went nuclear. I disabled and created a new instance. I seem to have control over things. I don't know how quickly to expect new devices to show up in homekit, but I seem to have to still reboot homebridge to get things to come up. I did come across this error in the start up process:

[5/18/2019, 6:17:55 PM] Homebridge is running on port 51827.
[5/18/2019, 6:17:55 PM] [Hubitat hhh:0.2.1] latest version on npmjs is 0.2.1
[5/18/2019, 6:17:55 PM] [Hubitat hhh:0.2.1] your version of the plugin is up2date
[5/18/2019, 6:17:56 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 18                                                                  
[5/18/2019, 6:17:57 PM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 18                                                                  
[5/18/2019, 6:17:57 PM] [Hubitat hhh:0.2.1] { InternalError
    at /usr/local/lib/node_modules/homebridge-hubitat-hubconnect/index.js:168:49
    at process._tickCallback (internal/process/next_tick.js:68:7)
  errorCode: 0,
  name: 'InternalError',
  additionalArguments: [ '' ],
  message: '',
  lastHttpRequest:
   { hostname: '192.168.20.22',
     port: 80,
     path: '/apps/api/322/devices/get',
     method: 'GET',
     headers:
      { Authorization: 'Bearer ea42db3f-5e41-425d-98ce-b8f699f12104' } } }
[5/18/2019, 6:17:57 PM] [Hubitat hhh:0.2.1] Going to exit here to not destroy your room assignments.                                                                            
-U /homebridge -P /homebridge/node_modules -C
[5/18/2019, 6:18:00 PM] Loaded config.json with 0 accessories and 2 platforms.
[5/18/2019, 6:18:00 PM] ---

After you recreated the HubConnect instance, did you copy the new server key to your config.json. It changes and I see in that log output that your request to HubConnect is failing

Here is what I would do right now:

  1. Stop Homebridge
  2. Delete HubConnect server instance app
  3. Delete HubConnect Remote Hub Device
  4. Create new HubConnect server instance
  5. copy new server connection key and put it in you config.json
  6. Start Homebridge

That is a fully clean new start

yes, i copied the new key to the config.json. I assume that would be required for things to work at all. after a restart the devices appear in my homekit app and I seem to be able to control them.

That’s progress! Let me know if you have any more issues.

I think things are working (other than putting 97 devices back in their rooms). but this error does pop up on hubitat with the logging turned on:

`[app:322](http://192.168.20.22/logs#app322)2019-05-18 21:29:37.175 [error](http://192.168.20.22/installedapp/configure/322)org.apache.http.conn.HttpHostConnectException: Connect to 0.0.0.0:20009 [/0.0.0.0] failed: Connection refused (Connection refused) on line 888 (updated)`

that error only pops up after I hit done on the app. everything seems to be working though.

Try to set the parameter “local_ip” in you config.json to the IP address of your Homebridge. There was another use with the same problem and that fixed it. I am going to fix it in the code tomorrow.

I have control, but it isn’t updating when the lights are turned off and on by other means. And motion sensors and contact sensors aren’t updating. Logs all look empty.

If I take that literally, that you clicked On, for every HSM option in HubConnect, I think that just might be an infinite loop.

As I mentioned, I don't actually USE HSM (or modes) but I have them setup so that I can test and verify. Because of that, I cannot dispute that my setup could be so poor, that I am not seeing any bugs. However, here's what I have :slight_smile:

HSM is installed on 'coordinator' which I think is not where it wants to be. I think it probably needs to be closer to the action' by residing on a radio-active hub... a Remote. But I do have it enabled to send to one of the Remote hubs... so OK, it's backwards, but strictly for finding bugs, it's probably OK. My setup is 'unidirectional.' I will, for a specific set of tests, enable it to be sent to SmartThings.

This works without crashing.

For Homebridge...

Configuration of cached accessories not done, wait for a bit... 97
Configuration of cached accessories not done, wait for a bit... 97
Configuration of cached accessories not done, wait for a bit... 97
Configuration of cached accessories not done, wait for a bit... 97

(for a very long time) is normal, for me too. 97 = your count of devices sent to Homebridge, I'm showing 55. After 2-3 minutes it continues startup and everything is well.

I think when I tried messing with the local_ip it messed up my cache or something. Homebridge crashed afterward due to a json error. I removed my additions and it started back up, but now things aren’t updating.

edit: getting this error in my homebridge logs:

[5/19/2019, 5:38:59 AM] Homebridge is running on port 51827.
[5/19/2019, 5:38:59 AM] [Hubitat hhh:0.2.1] latest version on npmjs is 0.2.1
[5/19/2019, 5:38:59 AM] [Hubitat hhh:0.2.1] your version of the plugin is up2date
[5/19/2019, 5:38:59 AM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 99
[5/19/2019, 5:39:00 AM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 99
[5/19/2019, 5:39:01 AM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 99
[5/19/2019, 5:39:02 AM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 99
[5/19/2019, 5:39:03 AM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 99
[5/19/2019, 5:39:04 AM] [Hubitat hhh:0.2.1] Configuration of cached accessories not done, wait for a bit... 99
[5/19/2019, 5:39:05 AM] [Hubitat hhh:0.2.1] { InternalError
    at /usr/local/lib/node_modules/homebridge-hubitat-hubconnect/index.js:168:49
    at process._tickCallback (internal/process/next_tick.js:68:7)
  errorCode: 0,
  name: 'InternalError',
  additionalArguments: [ '' ],
  message: '',
  lastHttpRequest:
   { hostname: '192.168.20.22',
     port: 80,
     path: '/apps/api/322/devices/get',
     method: 'GET',
     headers:
      { Authorization: 'Bearer ea42db3f-5e41-425d-98ce-b8f699f12104' } } }
[5/19/2019, 5:39:05 AM] [Hubitat hhh:0.2.1] Going to exit here to not destroy your room assignments.
-U /homebridge -P /homebridge/node_modules -C
[5/19/2019, 5:39:07 AM] Loaded config.json with 0 accessories and 2 platforms.
[5/19/2019, 5:39:07 AM] ---

Ok, I just published a new plugin that corrects the whole 0.0.0.0 thing and improved a few of the log messages to help us get through this. Adding the "local_ip" setting can't mess with the cache. Homebridge will just quit even if the format in the config is wrong and the cache has no idea of that IP address. There must have been something else.

Please use the new version and see if that elevates your problems.

Yes I clicked On for every HSM option. They are all off now. :slight_smile:

Hmmm. after like 6 restarts, things seem to be working again. I do get this error after I hit done in the hubconnect app, but the devices seem to be responding in like they should in homekit.

`[app:322](http://192.168.20.22/logs#app322)2019-05-19 09:55:52.882 [error](http://192.168.20.22/installedapp/configure/322)Unable to create the Hub monitoring device: java.lang.IllegalArgumentException: A device with the same device network ID exists, Please use a different DNI. Support Data: [id: "hub-192.168.1.20", name: "HubConnect Hub", label: "Homebridge 2"]`

there's a clue within:

Unable to create the Hub monitoring device
A device with the same device network ID exists, Please use a different DNI

For every Hub Instance on the server, there's a Device using the HubConnect Remote Hub Driver. HubConnect believes a new one needs to be created but one already exists. You'll probably want to follow @dan.t 's advice:

I literally just did that. And just got through putting 99 devices back into their respective rooms and then something. happened and it started throwing this error again.

edit: also, like I said, it seems to be functioning normally.

OK, I ran into that same problem regarding the duplicate DNI.

I don't know how I did it, but I know exactly what's wrong. I cannot reproduce it but clearly it is possible to get it confused.

@csteele @srwhite

Any chance to check my post above, I can't figure out how to get any devices to show on the Custom Drivers list when selecting devices as mentioned above on this post: [RELEASE] HubConnect - Share Devices across Multiple Hubs (even SmartThings!)

Also, found my ceiling fan wasn't showing at all on the Groups app, could setlevel be added to the driver for fans? I added it manually and now I was able to select my ceiling fans as a dimmer would show.