WebThingsIO / philips-hue-adapter

WebThings Gateway Philips Hue Adapter
Mozilla Public License 2.0
21 stars 12 forks source link

Update only when necessary; Revert to HSV color space #11

Closed hobinjk closed 6 years ago

hobinjk commented 6 years ago

Mostly fixes interoperability issues with Hue app and other controllers.

Notably: the brightness (Y) of the CIE xyY color space calculation suggested by the Philips Hue API documentation appears to be incorrect. This may be a side effect of not constraining the xy coordinates to the bulb's color gamut. Until a more concerted effort can be made to figure out the root cause of the brightness drops, this PR reverts back to using the HSV color space.

andrenatal commented 6 years ago

@hobinjk I am seeing the error below when trying this PR. Maybe we also need to update color-light.js?

rendering new color light things.js:175:13
GET https://gateway.mozilla-iot.org/things/philips-hue-001788fffe2ce8ac-1 [HTTP/1.1 101 Switching Protocols 402ms] 
GET XHR https://gateway.mozilla-iot.org/things/philips-hue-001788fffe2ce8ac-1/properties/on [HTTP/1.1 500 Internal Server Error 150ms] 
GET https://gateway.mozilla-iot.org/images/back.png [HTTP/1.1 200 OK 0ms]
Error fetching on/off switch status SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data color-light.js:174:5
PUT XHR https://gateway.mozilla-iot.org/things/philips-hue-001788fffe2ce8ac-1/properties/color [HTTP/1.1 500 Internal Server Error 462ms]
PUT XHR https://gateway.mozilla-iot.org/things/philips-hue-001788fffe2ce8ac-1/properties/color [HTTP/1.1 500 Internal Server Error 462ms]
Status 500 trying to set color color-light.js:257:6

The way I did to update the addon was just pulling your changes mozilla-iot/gateway/build/addons/philips-hue-adapter on top of master and restarted the gateway. Is that the right way? When I do t this, I do not see the hue addon in the addons page anymore, and if I choose to enable it, it overwrites the PR branch with version 0.4.1:


Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   package.json
    modified:   philips-hue-adapter.js
hobinjk commented 6 years ago

What's in the Gateway's log? There's no need to update color-light.js

andrenatal commented 6 years ago

Maybe my gateway is old then? I am on commit 492f26a262a1834745cc6c4dbc7c1bb167a59c0f

andrenatal commented 6 years ago

I am getting:


2018-02-10 06:18:27.771 Error getting value for thingId: philips-hue-001788fffe2ce8ac-1 property: on
2018-02-10 06:18:27.772 getProperty: device: philips-hue-001788fffe2ce8ac-1 not found.

in the gateway log

hobinjk commented 6 years ago

That is pretty out-of-date but I don't think that should be causing any problems. It looks like something is preventing the philips-hue-adapter from running.

hobinjk commented 6 years ago

Usually the reason would be listed in the first few lines of the gateway's log

andrenatal commented 6 years ago

I tried to delete the bulbs and pair them again but it never finds them. They show up only if I install the addon again, but if I do that, it overwrites with 0.4.1

hobinjk commented 6 years ago

I think you'll need to either upgrade your gateway to master or regenerate the SHA256SUMS file by running sha256sum package.json ./*.js LICENSE > SHA256SUMS in the philips-hue-adapter directory (shasum -a 256 on a mac)

andrenatal commented 6 years ago

After updating the gateway everything's back to work!