-
Notifications
You must be signed in to change notification settings - Fork 14
/
colorcoordinator.groovy
132 lines (118 loc) · 4.1 KB
/
colorcoordinator.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/**
* Color Coordinator
* Version 1.0.0 - 7/4/15
* By Michael Struck
*
* 1.0.0 - Initial release
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
* 2020 lgk port to hubitat
*/
definition(
name: "Color Coordinator",
namespace: "MichaelStruck",
author: "Michael Struck",
description: "Ties multiple colored lights to one specific light's settings",
category: "Convenience",
iconUrl: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/ColorCoordinator/CC.png",
iconX2Url: "https://raw.githubusercontent.com/MichaelStruck/SmartThings/master/Other-SmartApps/ColorCoordinator/[email protected]"
)
preferences {
page name: "mainPage"
}
def mainPage() {
dynamicPage(name: "mainPage", title: "", install: true, uninstall: true) {
section("Master Light") {
input "master", "capability.colorControl", title: "Colored Light"
}
section("Lights that follow the master settings") {
input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: false
}
section([mobileOnly:true], "Options") {
label(title: "Assign a name", required: false)
href "pageAbout", title: "About ${textAppName()}", description: "Tap to get application version, license and instructions"
}
}
}
page(name: "pageAbout", title: "About ${textAppName()}") {
section {
paragraph "${textVersion()}\n${textCopyright()}\n\n${textLicense()}\n"
}
section("Instructions") {
paragraph textHelp()
}
}
def installed() {
init()
}
def updated(){
unsubscribe()
init()
}
def init() {
subscribe(master, "switch", onOffHandler)
subscribe(master, "level", colorHandler)
subscribe(master, "hue", colorHandler)
subscribe(master, "saturation", colorHandler)
subscribe(master, "colorTemperature", tempHandler)
}
//-----------------------------------
def onOffHandler(evt){
if (master.currentValue("switch") == "on"){
slaves?.on()
}
else {
slaves?.off()
}
}
def colorHandler(evt) {
def dimLevel = master.currentValue("level")
def hueLevel = master.currentValue("hue")
def saturationLevel = master.currentValue("saturation")
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
slaves?.setColor(newValue)
}
def tempHandler(evt){
if (evt.value != "--") {
def tempLevel = master.currentValue("colorTemperature")
slaves?.setColorTemperature(tempLevel)
}
}
//Version/Copyright/Information/Help
private def textAppName() {
def text = "Color Coordinator"
}
private def textVersion() {
def text = "Version 1.0.0 (07/04/2015)"
}
private def textCopyright() {
def text = "Copyright © 2015 Michael Struck"
}
private def textLicense() {
def text =
"Licensed under the Apache License, Version 2.0 (the 'License'); "+
"you may not use this file except in compliance with the License. "+
"You may obtain a copy of the License at"+
"\n\n"+
" http://www.apache.org/licenses/LICENSE-2.0"+
"\n\n"+
"Unless required by applicable law or agreed to in writing, software "+
"distributed under the License is distributed on an 'AS IS' BASIS, "+
"WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. "+
"See the License for the specific language governing permissions and "+
"limitations under the License."
}
private def textHelp() {
def text =
"This application will allow you to control the settings of multiple colored lights with one control. " +
"Simply choose a master control light, and then choose the lights that will follow the settings of the master, "+
"including on/off conditions, hue, saturation, level and color temperature."
}