sqmk / Phue

Philips Hue client for PHP
Other
203 stars 45 forks source link

active property not found in Phue\Scene #102

Closed marcusklaas closed 8 years ago

marcusklaas commented 8 years ago

Ran the following snippet from the README on php 5.4:

foreach ($client->getScenes() as $scene) {
    echo "\t", "#{$scene->getId()} - {$scene->getName()}", "\n",
        "\t\t", "Light Ids: ", implode(', ', $scene->getLightIds()), "\n",
        "\t\t", "Is active: ", $scene->isActive() ? 'Yes' : 'No', "\n";
}

and got the notices

Notice: Undefined property: stdClass::$active in /var/www/vendor/sqmk/phue/library/Phue/Scene.php on line 89
marcusklaas commented 8 years ago

I've checked that I'm on the latest master, by the way.

marcusklaas commented 8 years ago

It seems active is a property of an anonymous object stored in the scene object. Why'd you choose for that solution instead of making active a property of the scene object?

sqmk commented 8 years ago

Most of the interface for the main objects uses get/is prefixed accessors. Keeping the original attribute names from the bridge in a separate object within the main models makes it easier to pass back to the bridge without mapping/translations.

The active field is now deprecated/removed from scenes on latest bridge versions. My node.js client supports the latest bridge versions (https://github.com/sqmk/huejay/blob/master/lib/Model/Scene.js) and doesn't appear to allow modifying/retrieving the active field, so we should be safe to remove isActive completely from Scene management in Phue.

sqmk commented 8 years ago

Assuming you have an account on the Hue Developer Program, "active" is no longer available in v1.11 of the bridge api: http://www.developers.meethue.com/documentation/scenes-api

Definitely safe to remove from Phue. You are welcome to submit the changes to remove any methods/tests for that field, or I can get to it in the evening.

marcusklaas commented 8 years ago

Thanks for the quick reply! Some other functionality seems broken too, such as setting a light's brightness etc.

I'm just playing around with this though, not sure I can contribute... Would you recommend switching to your node client?

edit: huejay seems super dope, definitely switching!

sqmk commented 8 years ago

Awesome. I would definitely switch. I've been trying to abandon most of my PHP projects in favor of JS. As a result, Phue hasn't been getting any love and is a bit behind on the API. I'll correct any immediate issues (like this one) that get reported.

If I had more time, I'd release Phue v2 to follow the interface for the node.js lib.

sqmk commented 8 years ago

This fix is going in with v1.6.0.