How to use the sunset and sunrise data
I see that the Hue API provides fields in the "Daylight" sensor for geo location and sunrise / sunset offset.
Specifically:
lat
long
sunriseoffset
sunsetoffset
The API currently posted does not provide any information that I could learn about how sunrise / sunset can be used.
If I use the update sensor API to set the latitude and longitude, will the sunrise / sunset attenuations be auto-populated with data and can I query it to adjust my lighting schedule accordingly? I want to do for example. "every day, light at sunset + 20 minutes."
I was going to implement the required algorithm myself, but in light of these fields, I need?
While testing I have updated the latitude and longitude in the sensor configuration, here is the dump of the result of the sensor request after the update:
{
"state": {
"daylight":false,
"lastupdated":"2014-11-06T19:19:31"
},
"config": {
"on":true,
"long":"1.5333W",
"lat":"56.2442N",
"sunriseoffset":30,
"sunsetoffset":-30
},
"name":"Daylight",
"type":"Daylight",
"modelid":"PHDL00",
"manufacturername":"Philips",
"swvversion":"1.0"
}
You can see the latitude and longitude values ββthat I have set (they are "none" by default).
It is now clear that the sunrise and sunset offsets are not calculated values. Instead, they are used to tune when the sensor value shifts from daylight to non-daylight, or vice versa - for example, daylight becomes a true "sunrise offset" minutes after sunrise.
Does the bridge know the sunrise and sunset times for a given geographic location?
If so, can I reliably query this sensor for daylight or non-daylight based on sunrise and sunset?
source to share
Below is a description of the daylight sensor on the Supported Sensors page , a description of the sensors on Sensors , and you need Rules to use the sensors effectively.
The daylight sensor will set the status value daylight
to true
when there is daylight and false
when not, of course taking into account the offset (in minutes) specified in the sensor configuration.
To change the configuration of the daylight sensor, use PUT
on /api/<username>/sensors/1/config
with the following body:
{
"long": "1.5333W",
"lat": "56.2442N",
"sunriseoffset": 30,
"sunsetoffset": -30
}
This means the status value daylight
will change up to false
30 minutes before sunset and true
30 minutes after sunrise, where the sunset / sunrise time is calculated based on long
(longitude) and lat
(latitude).
In order, for example, to turn on the light at sunset, you need to specify a rule with the condition that the value daylight
must be equal false
.
Use POST
on /api/<username>/rules
with the following body:
{
"name": "Daylight rule",
"conditions": [
{
"address": "/sensors/1/state/daylight",
"operator": "eq",
"value": "false"
}
],
"actions": [
{
"address": "/groups/0/action",
"method": "PUT",
"body": { "on":true, "bri":254 }
}
]
}
If the condition of the rule is that the state value daylight
must be eq
(equal to) the value false
.
source to share