lukasroegner / homebridge-philips-hue-sync-box

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

Improved documentation? #43

Closed Calorion closed 2 years ago

Calorion commented 3 years ago

This is my first Homebridge plugin; indeed it’s the reason I installed Homebridge. Unfortunately I’m having some difficulties parsing the instructions.

First, when the Readme says

Make an HTTP POST request to https:///api/v1/registrations The body of the request has to be JSON: { "appName": "homebridge", "appSecret”: "MDAwMTExMDAwMTExMDAwMTExMDAwMTExMDAwMTExMDA=", "instanceName": "homebridge" }

does that mean doing something like

curl -H "Content-Type: application/json" -X POST -d '{"appName": "homebridge", "appSecret":"MDAwMTExMDAwMTExMDAwMTExMDAwMTExMDAwMTExMDA=", "instanceName": "homebridge"}' https://<SYNC-BOX-IP>/api/v1/registrations?

If so, could that be added to the readme?

Second, am I supposed to paste the code in the Configuration section into the the “JSON Config” section of the "Homebridge Philips Hue Sync Box” plugin in the Homebridge UI? If so, again, could that be added to the readme?

Thanks!

luigi-lauro commented 3 years ago

Ciao,

Yes, indeed the documentation is not very clear/through.

You have to make a POST request with a specific JSON payload in the request. For doing that you will need a command-line tool, like CURL in unix shells.

What I did was (content-type is not strictly needed): curl --insecure -d "{ \"appName\": \"homebridge\", \"appSecret\": \"MDAwMTExMDAwMTExMDAwMTExMDAwMTExMDAwMTExMDA=\", \"instanceName\": \"homebridge\" }" https://192.168.4.30/api/v1/registrations

This worked perfectly, it gave the first time the invalid state, then after I was able to press and release the button on the box fast enough to make it stay WHITE and not go red (it took 5+ tries, it's too fast to wait for it to do it and then react, you have to preemptively "guess" the timing with a few tries), and then I did the same command again and got the accessToken string to put in the plugin configuration in Homebridge config UI.

The accessToken needs to be put in the "syncBoxApiAccessToken" configuration option of the Homebridge JSON, but you can also use the wonderful Configuration UI plugin and with that you have a nice plugin configuration menu to set the "Access Token" property in a more user-friendly way (as well as all other options).

My configuration (accessToken removed for security reasons);

       {
            "syncBoxIpAddress": "192.168.4.30",
            "syncBoxApiAccessToken": _REMOVED_,
            "defaultOnMode": "lastSyncMode",
            "defaultOffMode": "passthrough",
            "tvAccessory": false,
            "tvAccessoryType": "TV",
            "modeTvAccessory": true,
            "modeTvAccessoryType": "settopbox",
            "intensityTvAccessory": true,
            "intensityTvAccessoryType": "settopbox",
            "isApiEnabled": false,
            "_bridge": {
                "username": "0E:45:86:2D:61:35",
                "port": 35979
            },
            "platform": "PhilipsHueSyncBoxPlatform"
        },
luigi-lauro commented 3 years ago

Did it work in the end?

Calorion commented 3 years ago

Yes, I had it working shortly after I posted this.

Calorion commented 3 years ago

My question was and is whether the documentation could include (something like) my example.