lukasroegner / homebridge-philips-hue-sync-box

Homebridge plugin for the Philips Hue Sync Box.
MIT License
55 stars 12 forks source link

[Feature Request] Support Multiple Sync Boxes #46

Open iangrieve opened 3 years ago

iangrieve commented 3 years ago

Thank you very much for this excellent Hue Sync Box integration plugin. I am up and running with the Hue Sync Accessories in Homekit for one Hue Sync box and my question is: Can I add a JSON entry with a different name to support a second Sync box on my network?

I initially tried it yesterday and made the mistake that my JSON file would have had the same Platform name for the second sync box. This of course didn't work and after removing the plugin, I was unable to successfully add the first box back on again. I started with a fresh image of Homebridge and am back in good shape with one sync box working in Homekit.

I can test it now with a second attempt but also wanted to ask if you have done this or if it is possible. I know there are a lot of behind the scene things going on and appreciate your insight in to the possibility of this working.

I have 2 Hue bridges so that the sync boxes are on separate bridges. Interested also if the solution is that 2 Hombridge devices would be recommended?

Thank You in advance

luigi-lauro commented 3 years ago

I think by creating 2 different platforms in the config and so loading the plugin twice in Homebridge it should be possible, shouldn't cause issues, but who knows? Don't have 2 boxes to try, you can try and let us know :-)

lukasroegner commented 3 years ago

There is a quite simple solution, which generally applies to plugins you want to run multiple instances of: you can set up multiple homebridge instances. For some users, this is also the preferred method for all Homebridge plugins, as crashing plugins don't affect other plugins. If I have time to in the future, I'll implement support for multiple Sync boxes right into the plugin. I'll mark this issue as feature request.

iangrieve commented 3 years ago

Thank you very much, Lukas. I did indeed figure out to add another instance. Interestingly, although configured the same way as the first instance, and the logs show that the sync box is added and all 3 accessories are set up/added, they don't show up in the home app when I try to add them using the homebridge pairing code. The accessory for power does show up and I was able to successfully configure the API so I've accomplished what I wanted to using the API and shortcuts for instance 2 and using HomeKit Scenes for instance 1.

MichelEhmen commented 2 years ago

Are there any updates? I am having the same issue. I am able to create another bridge for a second instance, which is already great. I can also see the main switch for the second sync box. But I can't see my HDMI TV switch for the second sync box. It's a weird behavior, because homebridge shows the second device.

lukasroegner commented 2 years ago

I have implemented support for multiple Philips Hue Sync Boxes. As this is a breaking change, I want to invite you to try out the latest version. Your feedback is appreciated, as I don't own multiple Sync Boxes.

To install this "beta" version, use the following command (it will install the version from the branch "multiple-sync-boxes"):

npm install -g "https://github.com/lukasroegner/homebridge-philips-hue-sync-box.git#multiple-sync-boxes"

Make sure that you change your configuration before restarting Homebridge, as all of the properties are now wrapped in an array of devices (see README in the branch "multiple-sync-boxes").

bwt615 commented 2 years ago

I can't get that to install on my pi homebridge. It says the directory is private.

lukasroegner commented 2 years ago

Any test results for the "beta" version? Does it work properly for those who have multiple Sync Boxes?

bwt615 commented 2 years ago

Any test results for the "beta" version? Does it work properly for those who have multiple Sync Boxes?

I wish I could test it but that repo didn't work for me!

lukasroegner commented 2 years ago

It says the directory is private.

This is a rather vague description of the issue you are having. Maybe you can provide more details on which OS you are using and the error message you are getting.

If I had to guess, I would assume that you have to install it with a different user.

bwt615 commented 2 years ago
Screen Shot 2022-04-12 at 12 41 12 PM

RaspberryPI Homekit - fails with and without sudo.

Any thoughts?

bwt615 commented 2 years ago

Got it installed. Removed and then reinstall worked fine after creating a usable global directory. Breaks homebridge for me though:

[14/04/2022, 19:22:39] TypeError: client.platform.log is not a function at Request._callback (/home/pi/.npm-global/lib/node_modules/homebridge-philips-hue-sync-box/src/philips-hue-sync-box-client.js:81:37) at self.callback (/home/pi/.npm-global/lib/node_modules/homebridge-philips-hue-sync-box/node_modules/request/request.js:185:22) at Request.emit (events.js:400:28) at Request.onRequestError (/home/pi/.npm-global/lib/node_modules/homebridge-philips-hue-sync-box/node_modules/request/request.js:877:8) at ClientRequest.emit (events.js:400:28) at TLSSocket.socketErrorListener (_http_client.js:475:9) at TLSSocket.emit (events.js:400:28) at emitErrorNT (internal/streams/destroy.js:106:8) at emitErrorCloseNT (internal/streams/destroy.js:74:3) at processTicksAndRejections (internal/process/task_queues.js:82:21)

My config:

    {
        "devices": [
            {
                "syncBoxIpAddress": "192.168.1.XXX",
                "syncBoxApiAccessToken": "XX",
                "baseAccessory": "switch",
                "tvAccessory": true,
                "tvAccessoryType": "tv",
                "tvAccessoryLightbulb": false,
                "modeTvAccessory": false,
                "modeTvAccessoryType": "tv",
                "modeTvAccessoryLightbulb": false,
                "intensityTvAccessory": false,
                "intensityTvAccessoryType": "TV",
                "intensityTvAccessoryLightbulb": false,
                "entertainmentTvAccessory": false,
                "entertainmentTvAccessoryType": "TV",
                "entertainmentTvAccessoryLightbulb": false
            },
            {
                "syncBoxIpAddress": "192.168.1.XXX",
                "syncBoxApiAccessToken": "XX",
                "baseAccessory": "switch",
                "tvAccessory": true,
                "tvAccessoryType": "tv",
                "tvAccessoryLightbulb": false,
                "modeTvAccessory": false,
                "modeTvAccessoryType": "tv",
                "modeTvAccessoryLightbulb": false,
                "intensityTvAccessory": false,
                "intensityTvAccessoryType": "TV",
                "intensityTvAccessoryLightbulb": false,
                "entertainmentTvAccessory": false,
                "entertainmentTvAccessoryType": "TV",
                "entertainmentTvAccessoryLightbulb": false
            }
        ],
        "platform": "PhilipsHueSyncBoxPlatform"
    }
bwt615 commented 2 years ago

@lukasroegner any update?

bwt615 commented 2 years ago

I got this working with child bridges. Question: can you add a serial parameter so we can differentiate between them? Name: works but isn't documented.

wondergit113 commented 2 years ago

I get this error with your multiple sync boxes fork

dding new accessory with kind SwitchAccessory. Error: Cannot add a bridged Accessory with the same UUID as another bridged Accessory: b4b0764a-b898-442a-8f44-6b300388e938 at Bridge.Accessory.addBridgedAccessory (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:594:15) at Bridge.Accessory.addBridgedAccessories (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:623:12) at BridgeService.handleRegisterPlatformAccessories (/usr/local/lib/node_modules/homebridge/src/bridgeService.ts:384:17) at HomebridgeAPI.emit (node:events:376:20) at HomebridgeAPI.registerPlatformAccessories (/usr/local/lib/node_modules/homebridge/src/api.ts:340:10) at new SyncBoxDevice (/usr/local/lib/node_modules/homebridge-philips-hue-sync-box/src/sync-box-device.js:165:18) at /usr/local/lib/node_modules/homebridge-philips-hue-sync-box/src/philips-hue-sync-box-platform.js:105:32

wondergit113 commented 2 years ago

here's my config:

{ "devices": [ { "syncBoxIpAddress": "192.168.4.92", "syncBoxApiAccessToken": "XXX", "baseAccessory": "switch", "tvAccessory": false, "tvAccessoryType": "TV", "tvAccessoryLightbulb": false, "modeTvAccessory": false, "modeTvAccessoryType": "TV", "modeTvAccessoryLightbulb": false, "intensityTvAccessory": false, "intensityTvAccessoryType": "TV", "intensityTvAccessoryLightbulb": false, "entertainmentTvAccessory": false, "entertainmentTvAccessoryType": "TV", "entertainmentTvAccessoryLightbulb": false }, { "syncBoxIpAddress": "192.168.4.203", "syncBoxApiAccessToken": "XXX", "baseAccessory": "switch", "tvAccessory": false, "tvAccessoryType": "TV", "tvAccessoryLightbulb": false, "modeTvAccessory": false, "modeTvAccessoryType": "TV", "modeTvAccessoryLightbulb": false, "intensityTvAccessory": false, "intensityTvAccessoryType": "TV", "intensityTvAccessoryLightbulb": false, "entertainmentTvAccessory": false, "entertainmentTvAccessoryType": "TV", "entertainmentTvAccessoryLightbulb": false } ], "_bridge": { "username": "0E:BF:48:98:CC:32", "port": 59450 }, "platform": "PhilipsHueSyncBoxPlatform" }

lukasroegner commented 1 year ago

@wondergit113 Please update the package and try again, I've included a fix for your issue.

bwt615 commented 1 year ago

it's now working great for me :)

bwt615 commented 1 year ago

Actually, getting crashing homebridge when i try to set intensity: TypeError: client.platform.log is not a function at Request._callback (/home/pi/.npm-global/lib/node_modules/homebridge-philips-hue-sync-box/src/philips-hue-sync-box-client.js:83:37) at Request.self.callback (/home/pi/.npm-global/lib/node_modules/homebridge-philips-hue-sync-box/node_modules/request/request.js:185:22) at Request.emit (node:events:527:28) at Request. (/home/pi/.npm-global/lib/node_modules/homebridge-philips-hue-sync-box/node_modules/request/request.js:1154:10) at Request.emit (node:events:527:28) at IncomingMessage. (/home/pi/.npm-global/lib/node_modules/homebridge-philips-hue-sync-box/node_modules/request/request.js:1076:12) at Object.onceWrapper (node:events:641:28) at IncomingMessage.emit (node:events:539:35) at endReadableNT (node:internal/streams/readable:1345:12) at processTicksAndRejections (node:internal/process/task_queues:83:21)

bwt615 commented 1 year ago

Another bug: crashes Homebridge repeatedly if not available