-
Notifications
You must be signed in to change notification settings - Fork 6
/
Fibaro_RGBW_Group_Controller.groovy
204 lines (164 loc) · 4.92 KB
/
Fibaro_RGBW_Group_Controller.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/**
* Fibaro_RGBW_Multi_Control.groovy
* Fibaro RGBW Group Controller
*
* Author: [email protected]
* Date: 2015-04-27
*/
/**
*
* Use this program with a virtual Fibaro as the master for best results.
*
* This app lets the user control multiple Fibaro RGBW devices via a single
* Virtual Fibaro RGBW device.
*
******************************************************************************
* Changes
******************************************************************************
*
******************************************************************************
*/
// Automatically generated. Make future change here.
definition(
name: "Fibaro RGBW Group Controller",
namespace: "Sticks18",
author: "[email protected]",
description: "Follows the Virtual Fibaro RGBW",
category: "My Apps",
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png"
)
preferences {
section("When this...") {
input "master", "capability.colorControl",
multiple: false,
title: "Master Virtual Fibaro...",
required: true
}
section("And these Fibaro RGBW will follow...") {
input "slaves", "capability.colorControl",
multiple: true,
title: "Slave Fibaro RGBWs...",
required: true
}
}
def installed()
{
subscribe(master, "switch.on", switchOnHandler)
subscribe(master, "switch.off", switchOffHandler)
subscribe(master, "switch.setLevel", switchSetLevelHandler)
subscribe(master, "level", switchSetLevelHandler)
subscribe(master, "switch", switchSetLevelHandler)
subscribe(master, "adjustedColor", switchAdjustedColorHandler)
subscribe(master, "presetColor", switchPresetColorHandler)
subscribe(master, "whiteLevel", switchWhiteLevelHandler)
}
def updated()
{
unsubscribe()
subscribe(master, "switch.on", switchOnHandler)
subscribe(master, "switch.off", switchOffHandler)
subscribe(master, "switch.setLevel", switchSetLevelHandler)
subscribe(master, "level", switchSetLevelHandler)
subscribe(master, "switch", switchSetLevelHandler)
subscribe(master, "adjustedColor", switchAdjustedColorHandler)
subscribe(master, "presetColor", switchPresetColorHandler)
subscribe(master, "whiteLevel", switchWhiteLevelHandler)
log.info "subscribed to all of masters' events"
}
def switchSetLevelHandler(evt)
{
if ((evt.value == "on") || (evt.value == "off" ))
return
def level = evt.value.toFloat()
level = level.toInteger()
log.info "switchSetLevelHandler Event: ${level}"
slaves?.setLevel(level)
}
def switchWhiteLevelHandler(evt)
{
def level = evt.value.toFloat()
level = level.toInteger()
log.info "switchWhiteLevelHandler Event: ${level}"
slaves?.setWhiteLevel(level)
}
def switchAdjustedColorHandler(evt)
{
log.info "switchAdjustedColorHandler Event: ${evt.value}"
def colorMap = evt.value.replace("\"","")
colorMap = colorMap.replace("{","")
colorMap = colorMap.replace("}","")
log.debug "Color Map: ${colorMap}"
def map = [:]
colorMap.split(",").each {param ->
def nameAndValue = param.split(":")
map[nameAndValue[0]] = nameAndValue[1]
}
slaves?.setAdjustedColor(map)
}
def switchPresetColorHandler(evt)
{
log.info "switchPresetColorHandler Event: ${evt.value}"
switch(evt.value) {
case "Soft White":
slaves?.softwhite()
break
case "Daylight":
slaves?.daylight()
break
case "Warm White":
slaves?.warmwhite()
break
case "Red":
slaves?.red()
break
case "Green":
slaves?.green()
break
case "Blue":
slaves?.blue()
break
case "Cyan":
slaves?.cyan()
break
case "Magenta":
slaves?.magenta()
break
case "Orange":
slaves?.orange()
break
case "Purple":
slaves?.purple()
break
case "Yellow":
slaves?.yellow()
break
case "White":
slaves?.white()
break
case "Fireplace":
slaves?.fireplace()
break
case "Storm":
slaves?.storm()
break
case "Deep Fade":
slaves?.deepfade()
break
case "Lite Fade":
slaves?.litefade()
break
case "Police":
slaves?.police()
break
}
}
def switchOffHandler(evt) {
log.info "switchoffHandler Event: ${evt.value}"
slaves?.off()
}
def switchOnHandler(evt) {
log.info "switchOnHandler Event: ${evt.value}"
def dimmerValue = masters.latestValue("level") //can be turned on by setting the level
slaves?.on()
}