correl.github.io/_drafts/2018-03-13-hue-wake-up.html
2018-03-13 13:46:38 -04:00

329 lines
16 KiB
HTML

---
title: "How Does The Phillips Hue Wake-Up Feature Work?"
author: "Correl Roush"
---
<p>
I recently got myself a set of Phillips Hue White and Color Ambiance
lights. One of the features I was looking forward to in particular
(besides playing with all the color options) was setting a wake-up
alarm with the lights gradually brightening. This was pretty painless
to get set up using the phone app. I'm pretty happy with the result,
but there's certainly some things I wouldn't mind tweaking. For
example, the initial brightness of the bulbs (at the lowest setting)
still seems a bit bright, so I might want to delay the bedside lamps
and let the more distant lamp start fading in first. I also want to
see if I can fiddle it into transitioning between some colors to get
more of a sunrise effect (perhaps "rising" from the other side of the
room, with the light spreading towards the head of the bed).
</p>
<p>
Figuring out how the wake-up settings that the app installed on my
bridge seemed a good first step towards introducing my own
customizations.
</p>
<p>
Information on getting access to a Hue bridge to make REST API calls
to it can be found in the <a href="https://www.developers.meethue.com/documentation/getting-started">Hue API getting started guide</a>.
</p>
<div id="outline-container-org3991407" class="outline-2">
<h2 id="org3991407">My Wake-Up Settings</h2>
<div class="outline-text-2" id="text-org3991407">
<p>
My wake-up is scheduled for 7:00 to gradually brighten the lights with
a half-hour fade-in each weekday. I also toggled on the setting to
automatically turn the lights off at 9:00.
</p>
<div class="org-center">
<p>
<img src="/images/Screenshot_20180313-131855.png" alt="nil"/> <img src="/images/Screenshot_20180313-131858.png" alt="nil"/>
</p>
</div>
<p>
Wake up is kicked off at 6:30 with a schedule:
</p>
<div class="org-src-container">
<pre class="src src-http"><span style="color: #5fafd7;">GET</span> <span style="color: #ffd700;">http://bridge/api/${username}/schedules/1</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js">{
<span style="color: #ff4ea3;">"name"</span>: <span style="color: #ff4ea3;">"Wake up"</span>,
<span style="color: #ff4ea3;">"description"</span>: <span style="color: #ff4ea3;">"L_04_fidlv_start wake up"</span>,
<span style="color: #ff4ea3;">"command"</span>: {
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/api/oV5vUaXuBwEAA6sjnvqr8n6fBLlzWLjG4x4SIyD8/sensors/2/state"</span>,
<span style="color: #ff4ea3;">"body"</span>: {
<span style="color: #ff4ea3;">"flag"</span>: <span style="color: #5fafd7;">true</span>
},
<span style="color: #ff4ea3;">"method"</span>: <span style="color: #ff4ea3;">"PUT"</span>
},
<span style="color: #ff4ea3;">"localtime"</span>: <span style="color: #ff4ea3;">"W124/T06:30:00"</span>,
<span style="color: #ff4ea3;">"time"</span>: <span style="color: #ff4ea3;">"W124/T10:30:00"</span>,
<span style="color: #ff4ea3;">"created"</span>: <span style="color: #ff4ea3;">"2018-03-11T19:46:54"</span>,
<span style="color: #ff4ea3;">"status"</span>: <span style="color: #ff4ea3;">"enabled"</span>,
<span style="color: #ff4ea3;">"recycle"</span>: <span style="color: #5fafd7;">true</span>
}
</pre>
</div>
<p>
This schedule triggers a sensor:
</p>
<div class="org-src-container">
<pre class="src src-http"><span style="color: #5fafd7;">GET</span> <span style="color: #ffd700;">http://bridge/api/${username}/sensors/2</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js">{
<span style="color: #ff4ea3;">"state"</span>: {
<span style="color: #ff4ea3;">"flag"</span>: <span style="color: #5fafd7;">false</span>,
<span style="color: #ff4ea3;">"lastupdated"</span>: <span style="color: #ff4ea3;">"2018-03-13T13:00:00"</span>
},
<span style="color: #ff4ea3;">"config"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"reachable"</span>: <span style="color: #5fafd7;">true</span>
},
<span style="color: #ff4ea3;">"name"</span>: <span style="color: #ff4ea3;">"Sensor for wakeup"</span>,
<span style="color: #ff4ea3;">"type"</span>: <span style="color: #ff4ea3;">"CLIPGenericFlag"</span>,
<span style="color: #ff4ea3;">"modelid"</span>: <span style="color: #ff4ea3;">"WAKEUP"</span>,
<span style="color: #ff4ea3;">"manufacturername"</span>: <span style="color: #ff4ea3;">"oV5vUaXuBwEAA6sjnvqr8n6fBLlzWLjG"</span>,
<span style="color: #ff4ea3;">"swversion"</span>: <span style="color: #ff4ea3;">"A_1801260942"</span>,
<span style="color: #ff4ea3;">"uniqueid"</span>: <span style="color: #ff4ea3;">"L_04_fidlv"</span>,
<span style="color: #ff4ea3;">"recycle"</span>: <span style="color: #5fafd7;">true</span>
}
</pre>
</div>
<p>
A rule is triggered by this sensor updating:
</p>
<div class="org-src-container">
<pre class="src src-http"><span style="color: #5fafd7;">GET</span> <span style="color: #ffd700;">http://bridge/api/${username}/rules/1</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js">{
<span style="color: #ff4ea3;">"name"</span>: <span style="color: #ff4ea3;">"L_04_fidlv_Start"</span>,
<span style="color: #ff4ea3;">"owner"</span>: <span style="color: #ff4ea3;">"oV5vUaXuBwEAA6sjnvqr8n6fBLlzWLjG4x4SIyD8"</span>,
<span style="color: #ff4ea3;">"created"</span>: <span style="color: #ff4ea3;">"2018-03-11T19:46:51"</span>,
<span style="color: #ff4ea3;">"lasttriggered"</span>: <span style="color: #ff4ea3;">"2018-03-13T10:30:00"</span>,
<span style="color: #ff4ea3;">"timestriggered"</span>: 2,
<span style="color: #ff4ea3;">"status"</span>: <span style="color: #ff4ea3;">"enabled"</span>,
<span style="color: #ff4ea3;">"recycle"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"conditions"</span>: [
{
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/sensors/2/state/flag"</span>,
<span style="color: #ff4ea3;">"operator"</span>: <span style="color: #ff4ea3;">"eq"</span>,
<span style="color: #ff4ea3;">"value"</span>: <span style="color: #ff4ea3;">"true"</span>
}
],
<span style="color: #ff4ea3;">"actions"</span>: [
{
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/groups/1/action"</span>,
<span style="color: #ff4ea3;">"method"</span>: <span style="color: #ff4ea3;">"PUT"</span>,
<span style="color: #ff4ea3;">"body"</span>: {
<span style="color: #ff4ea3;">"scene"</span>: <span style="color: #ff4ea3;">"7GJer2-5ahGIqz6"</span>
}
},
{
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/schedules/2"</span>,
<span style="color: #ff4ea3;">"method"</span>: <span style="color: #ff4ea3;">"PUT"</span>,
<span style="color: #ff4ea3;">"body"</span>: {
<span style="color: #ff4ea3;">"status"</span>: <span style="color: #ff4ea3;">"enabled"</span>
}
}
]
}
</pre>
</div>
<p>
The bedroom group is set to the following scene, which turns on the
lights at minimum brightness:
</p>
<div class="org-src-container">
<pre class="src src-http"><span style="color: #5fafd7;">GET</span> <span style="color: #ffd700;">http://bridge/api/${username}/scenes/7GJer2-5ahGIqz6</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js">{
<span style="color: #ff4ea3;">"name"</span>: <span style="color: #ff4ea3;">"Wake Up init"</span>,
<span style="color: #ff4ea3;">"lights"</span>: [
<span style="color: #ff4ea3;">"2"</span>,
<span style="color: #ff4ea3;">"3"</span>,
<span style="color: #ff4ea3;">"5"</span>
],
<span style="color: #ff4ea3;">"owner"</span>: <span style="color: #ff4ea3;">"oV5vUaXuBwEAA6sjnvqr8n6fBLlzWLjG4x4SIyD8"</span>,
<span style="color: #ff4ea3;">"recycle"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"locked"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"appdata"</span>: {},
<span style="color: #ff4ea3;">"picture"</span>: <span style="color: #ff4ea3;">""</span>,
<span style="color: #ff4ea3;">"lastupdated"</span>: <span style="color: #ff4ea3;">"2018-03-11T19:46:50"</span>,
<span style="color: #ff4ea3;">"version"</span>: 2,
<span style="color: #ff4ea3;">"lightstates"</span>: {
<span style="color: #ff4ea3;">"2"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"bri"</span>: 1,
<span style="color: #ff4ea3;">"ct"</span>: 447
},
<span style="color: #ff4ea3;">"3"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"bri"</span>: 1,
<span style="color: #ff4ea3;">"ct"</span>: 447
},
<span style="color: #ff4ea3;">"5"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"bri"</span>: 1,
<span style="color: #ff4ea3;">"ct"</span>: 447
}
}
}
</pre>
</div>
<p>
Another schedule is enabled by the rule, which fires one minute after
its creation:
</p>
<div class="org-src-container">
<pre class="src src-http"><span style="color: #5fafd7;">GET</span> <span style="color: #ffd700;">http://bridge/api/${username}/schedules/2</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js">{
<span style="color: #ff4ea3;">"name"</span>: <span style="color: #ff4ea3;">"L_04_fidlv"</span>,
<span style="color: #ff4ea3;">"description"</span>: <span style="color: #ff4ea3;">"L_04_fidlv_trigger end scene"</span>,
<span style="color: #ff4ea3;">"command"</span>: {
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/api/oV5vUaXuBwEAA6sjnvqr8n6fBLlzWLjG4x4SIyD8/groups/0/action"</span>,
<span style="color: #ff4ea3;">"body"</span>: {
<span style="color: #ff4ea3;">"scene"</span>: <span style="color: #ff4ea3;">"gXdkB1um68N1sZL"</span>
},
<span style="color: #ff4ea3;">"method"</span>: <span style="color: #ff4ea3;">"PUT"</span>
},
<span style="color: #ff4ea3;">"localtime"</span>: <span style="color: #ff4ea3;">"PT00:01:00"</span>,
<span style="color: #ff4ea3;">"time"</span>: <span style="color: #ff4ea3;">"PT00:01:00"</span>,
<span style="color: #ff4ea3;">"created"</span>: <span style="color: #ff4ea3;">"2018-03-11T19:46:51"</span>,
<span style="color: #ff4ea3;">"status"</span>: <span style="color: #ff4ea3;">"disabled"</span>,
<span style="color: #ff4ea3;">"autodelete"</span>: <span style="color: #5fafd7;">false</span>,
<span style="color: #ff4ea3;">"starttime"</span>: <span style="color: #ff4ea3;">"2018-03-13T10:30:00"</span>,
<span style="color: #ff4ea3;">"recycle"</span>: <span style="color: #5fafd7;">true</span>
}
</pre>
</div>
<p>
That schedule sets another scene, which transitions the lights to full
brightness over the next 29 minutes (1740 seconds).
</p>
<div class="org-src-container">
<pre class="src src-http"><span style="color: #5fafd7;">GET</span> <span style="color: #ffd700;">http://bridge/api/${username}/scenes/gXdkB1um68N1sZL</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js">{
<span style="color: #ff4ea3;">"name"</span>: <span style="color: #ff4ea3;">"Wake Up end"</span>,
<span style="color: #ff4ea3;">"lights"</span>: [
<span style="color: #ff4ea3;">"2"</span>,
<span style="color: #ff4ea3;">"3"</span>,
<span style="color: #ff4ea3;">"5"</span>
],
<span style="color: #ff4ea3;">"owner"</span>: <span style="color: #ff4ea3;">"oV5vUaXuBwEAA6sjnvqr8n6fBLlzWLjG4x4SIyD8"</span>,
<span style="color: #ff4ea3;">"recycle"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"locked"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"appdata"</span>: {},
<span style="color: #ff4ea3;">"picture"</span>: <span style="color: #ff4ea3;">""</span>,
<span style="color: #ff4ea3;">"lastupdated"</span>: <span style="color: #ff4ea3;">"2018-03-11T19:46:51"</span>,
<span style="color: #ff4ea3;">"version"</span>: 2,
<span style="color: #ff4ea3;">"lightstates"</span>: {
<span style="color: #ff4ea3;">"2"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"bri"</span>: 254,
<span style="color: #ff4ea3;">"ct"</span>: 447,
<span style="color: #ff4ea3;">"transitiontime"</span>: 17400
},
<span style="color: #ff4ea3;">"3"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"bri"</span>: 254,
<span style="color: #ff4ea3;">"ct"</span>: 447,
<span style="color: #ff4ea3;">"transitiontime"</span>: 17400
},
<span style="color: #ff4ea3;">"5"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"bri"</span>: 254,
<span style="color: #ff4ea3;">"ct"</span>: 447,
<span style="color: #ff4ea3;">"transitiontime"</span>: 17400
}
}
}
</pre>
</div>
<p>
Finally, an additional rule takes care of turning the lights off and
the wake-up sensor at 9:00 (Two and a half hours after the initial
triggering of the sensor).
</p>
<div class="org-src-container">
<pre class="src src-http"><span style="color: #5fafd7;">GET</span> <span style="color: #ffd700;">http://bridge/api/${username}/rules/2</span>
</pre>
</div>
<div class="org-src-container">
<pre class="src src-js">{
<span style="color: #ff4ea3;">"name"</span>: <span style="color: #ff4ea3;">"Wake up 1.end"</span>,
<span style="color: #ff4ea3;">"owner"</span>: <span style="color: #ff4ea3;">"oV5vUaXuBwEAA6sjnvqr8n6fBLlzWLjG4x4SIyD8"</span>,
<span style="color: #ff4ea3;">"created"</span>: <span style="color: #ff4ea3;">"2018-03-11T19:46:51"</span>,
<span style="color: #ff4ea3;">"lasttriggered"</span>: <span style="color: #ff4ea3;">"2018-03-13T13:00:00"</span>,
<span style="color: #ff4ea3;">"timestriggered"</span>: 2,
<span style="color: #ff4ea3;">"status"</span>: <span style="color: #ff4ea3;">"enabled"</span>,
<span style="color: #ff4ea3;">"recycle"</span>: <span style="color: #5fafd7;">true</span>,
<span style="color: #ff4ea3;">"conditions"</span>: [
{
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/sensors/2/state/flag"</span>,
<span style="color: #ff4ea3;">"operator"</span>: <span style="color: #ff4ea3;">"eq"</span>,
<span style="color: #ff4ea3;">"value"</span>: <span style="color: #ff4ea3;">"true"</span>
},
{
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/sensors/2/state/flag"</span>,
<span style="color: #ff4ea3;">"operator"</span>: <span style="color: #ff4ea3;">"ddx"</span>,
<span style="color: #ff4ea3;">"value"</span>: <span style="color: #ff4ea3;">"PT02:30:00"</span>
}
],
<span style="color: #ff4ea3;">"actions"</span>: [
{
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/groups/2/action"</span>,
<span style="color: #ff4ea3;">"method"</span>: <span style="color: #ff4ea3;">"PUT"</span>,
<span style="color: #ff4ea3;">"body"</span>: {
<span style="color: #ff4ea3;">"on"</span>: <span style="color: #5fafd7;">false</span>
}
},
{
<span style="color: #ff4ea3;">"address"</span>: <span style="color: #ff4ea3;">"/sensors/2/state"</span>,
<span style="color: #ff4ea3;">"method"</span>: <span style="color: #ff4ea3;">"PUT"</span>,
<span style="color: #ff4ea3;">"body"</span>: {
<span style="color: #ff4ea3;">"flag"</span>: <span style="color: #5fafd7;">false</span>
}
}
]
}
</pre>
</div>
</div>
</div>