4 * Copyright 2014 SmartThings
6 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7 * in compliance with the License. You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
12 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
13 * for the specific language governing permissions and limitations under the License.
17 name: "Mini Hue Controller",
18 namespace: "smartthings",
19 author: "SmartThings",
20 description: "Control one or more Hue bulbs using an Aeon MiniMote.",
21 category: "SmartThings Labs",
22 iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
23 iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
24 iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
28 section("Control these lights") {
29 input "bulbs", "capability.colorControl", title: "Hue light bulbs", multiple: true
31 section("Using this controller") {
32 input "controller", "capability.button", title: "Aeon minimote"
37 log.debug "Installed with settings: ${settings}"
43 log.debug "Updated with settings: ${settings}"
49 subscribe controller, "button", buttonHandler
52 def buttonHandler(evt) {
53 switch(evt.jsonData?.buttonNumber) {
55 if (evt.value == "held") {
64 if (evt.value == "held") {
65 def color = [name:"Soft White", hue: 23, saturation: 56]
66 bulbs.setColor(hue: color.hue, saturation: color.saturation)
74 if (evt.value == "held") {
88 private toggleState() {
89 if (currentSwitchState == "on") {
100 def level = Math.min(currentSwitchLevel + 10, 100)
101 log.debug "level = $level"
102 bulbs.setLevel(level)
105 private levelDown() {
106 def level = Math.max(currentSwitchLevel - 10, 10)
107 log.debug "level = $level"
108 bulbs.setLevel(level)
111 private changeColor() {
114 [name:"Soft White", hue: 23, saturation: 56],
115 [name:"Daylight", hue: 53, saturation: 91],
116 [name:"White", hue: 52, saturation: 19],
117 [name:"Warm White", hue: 20, saturation: 80],
118 [name:"Blue", hue: 70, saturation: 100],
119 [name:"Green", hue: 39, saturation: 100],
120 [name:"Yellow", hue: 25, saturation: 100],
121 [name:"Orange", hue: 10, saturation: 100],
122 [name:"Purple", hue: 75, saturation: 100],
123 [name:"Pink", hue: 83, saturation: 100],
124 [name:"Red", hue: 100, saturation: 100]
127 final maxIndex = colors.size() - 1
129 if (state.colorIndex < maxIndex) {
130 state.colorIndex = state.colorIndex + 1
136 def color = colors[state.colorIndex]
137 bulbs.setColor(hue: color.hue, saturation: color.saturation)
140 private getCurrentSwitchState() {
144 if (it.currentValue("switch") == "on") {
151 on > off ? "on" : "off"
154 private getCurrentSwitchLevel() {
157 level = Math.max(it.currentValue("level")?.toInteger() ?: 0, level)