-
Notifications
You must be signed in to change notification settings - Fork 40
Description
There is an Error shown for (as I suspect) inactive devices.
Error message (edited):
ERROR: catched exception Notice: Undefined property: stdClass::$hue ["Message: Notice: Undefined property: stdClass::$hue\nStack Trace:
#0 vendor/sqmk/phue/library/Phue/Light.php(268): Symfony\Component\Debug\ErrorHandler->handleError(8, 'Undefined prope...', '/Users/xxx/...', 268, Array)\n
#1 src/SomeClass: Phue\Light->getHue()\n
Location:
sqmk/phue/library/Phue/Light.php(268)
public function getHue()
{
return $this->attributes->state->hue;
}
While debugging, the following properties are shown (correct scenario) :
$this = {Phue\Light} [3]
id = 1
attributes = {stdClass} [7]
state = {stdClass} [10]
on = false
bri = 143
hue = 0
sat = 0
effect = "none"
xy = {array} [2]
ct = 370
alert = "none"
colormode = "xy"
reachable = false
type = "someString"
name = "someString"
modelid = "someString"
manufacturername = "Philips"
uniqueid = "someId"
swversion = "someversion"
swconfigid = "someConfigId"
productid = "someProductId"
client = {Phue\Client} [3]
So hue = 0 is a proper object with a proper value.
Incorrect scenario (inactive hue device):
$this = {Phue\Light} [3]
id = 7
attributes = {stdClass} [9]
state = {stdClass} [6]
on = false
bri = 127
ct = 370
alert = "none"
colormode = "ct"
reachable = false
type = "someString"
name = "someString"
modelid = "someString"
manufacturername = "Philips"
uniqueid = "someId"
swversion = "someversion"
swconfigid = "someConfigId"
productid = "someProductId"
client = {Phue\Client} [3]
The object hue is missing here, I guess because of the inactive device, and the error message above is caused.
maybe you could edit this function a bit, so the returned value will be an int or null
public function getHue()
{
$hue = $this->attributes->state->hue;
return (isset($hue)) ? $hue : null;
}
or maybe just return "0" ?