I am working on an app that uses the Philips Hue SDK. I want to perform an action if after sunset. It looks like there is a sensor on the bridge that can return true or false if the user is currently under daylight.
I'm finding the documentation is a little lacking in this area, or at least I'm not finding it. I've found http://www.developers.meethue.com/documentation/supported-sensors but it gives no information about how to use it. The only other thing I've found is http://www.developers.meethue.com/documentation/java-sdk-getting-started#usingSensors which just says how to find new sensors. I don't want all sensors, I just want to access the daylight sensor and just do a check is it daylight and if not do something.
Thanks for any help you can provide.
1 Answers
Answers 1
You can accomplish this by setting the JSON values appropriately on the bridge. Here is how to do it using the debug/clip.html tool on the bridge. You could use one of the Hue API's to perform these operations also, but using the debug tool is very easy.
First, PUT (update) the Daylight sensor config with your own long and lat. These values are for Omaha, NE. The offsets can be positive or negative to make the state change earlier or later than the true sunrise/sunset time.
/api/<username>/sensors/1/config { "long": "96.0419W", "lat": "41.2647N", "sunriseoffset": 0, "sunsetoffset": 0 }
If you get it right, the state/daylight
value should change accordingly.
Now, POST (create) a rule that will fire based on the daylight state:
/api/<username>/rules { "name": "Turn lights off at sunrise", "conditions": [ { "address": "/sensors/1/state/daylight", "operator": "eq", "value": "true" } ], "actions": [ { "address": "/groups/0/action", "method": "PUT", "body": { "on": false } } ] }
This rule will turn all lights (group 0) off WHEN the sensor's state/daylight
value is true
. You could add a second rule to turn lights on at sunset.
0 comments:
Post a Comment