Skip to content

Commit 40bf47e

Browse files
committed
Merge pull request SmartThingsCommunity#107 from SmartThingsCommunity/master
Merge Master -> Staging
2 parents e1a9f2f + dc2ac4b commit 40bf47e

File tree

5 files changed

+226
-185
lines changed

5 files changed

+226
-185
lines changed

devicetypes/smartthings/hue-bridge.src/hue-bridge.groovy

+20-15
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,27 @@ metadata {
1515
// TODO: define status and reply messages here
1616
}
1717

18-
tiles {
18+
tiles(scale: 2) {
19+
multiAttributeTile(name:"rich-control"){
20+
tileAttribute ("", key: "PRIMARY_CONTROL") {
21+
attributeState "default", label: "Hue Bridge", action: "", icon: "st.Lighting.light99-hue", backgroundColor: "#F3C200"
22+
}
23+
tileAttribute ("serialNumber", key: "SECONDARY_CONTROL") {
24+
attributeState "default", label:'SN: ${currentValue}'
25+
}
26+
}
1927
standardTile("icon", "icon", width: 1, height: 1, canChangeIcon: false, inactiveLabel: true, canChangeBackground: false) {
2028
state "default", label: "Hue Bridge", action: "", icon: "st.Lighting.light99-hue", backgroundColor: "#FFFFFF"
2129
}
2230
valueTile("serialNumber", "device.serialNumber", decoration: "flat", height: 1, width: 2, inactiveLabel: false) {
2331
state "default", label:'SN: ${currentValue}'
2432
}
25-
valueTile("networkAddress", "device.networkAddress", decoration: "flat", height: 1, width: 2, inactiveLabel: false) {
33+
valueTile("networkAddress", "device.networkAddress", decoration: "flat", height: 2, width: 4, inactiveLabel: false) {
2634
state "default", label:'${currentValue}', height: 1, width: 2, inactiveLabel: false
2735
}
2836

2937
main (["icon"])
30-
details(["networkAddress","serialNumber"])
38+
details(["rich-control", "networkAddress"])
3139
}
3240
}
3341

@@ -36,40 +44,37 @@ def parse(description) {
3644
log.debug "Parsing '${description}'"
3745
def results = []
3846
def result = parent.parse(this, description)
39-
4047
if (result instanceof physicalgraph.device.HubAction){
4148
log.trace "HUE BRIDGE HubAction received -- DOES THIS EVER HAPPEN?"
4249
results << result
4350
} else if (description == "updated") {
4451
//do nothing
4552
log.trace "HUE BRIDGE was updated"
4653
} else {
47-
log.trace "HUE BRIDGE, OTHER"
4854
def map = description
4955
if (description instanceof String) {
5056
map = stringToMap(description)
5157
}
5258
if (map?.name && map?.value) {
5359
log.trace "HUE BRIDGE, GENERATING EVENT: $map.name: $map.value"
54-
results << createEvent(name: "${map?.name}", value: "${map?.value}")
55-
}
56-
else {
57-
log.trace "HUE BRIDGE, OTHER"
60+
results << createEvent(name: "${map.name}", value: "${map.value}")
61+
} else {
62+
log.trace "Parsing description"
5863
def msg = parseLanMessage(description)
5964
if (msg.body) {
6065
def contentType = msg.headers["Content-Type"]
6166
if (contentType?.contains("json")) {
6267
def bulbs = new groovy.json.JsonSlurper().parseText(msg.body)
6368
if (bulbs.state) {
64-
log.warn "NOT PROCESSED: $msg.body"
65-
}
66-
else {
67-
log.debug "HUE BRIDGE, GENERATING BULB LIST EVENT: $bulbs"
68-
sendEvent(name: "bulbList", value: device.hub.id, isStateChange: true, data: bulbs, displayed: false)
69+
log.info "Bridge response: $msg.body"
70+
} else {
71+
// Sending Bulbs List to parent"
72+
if (parent.state.inBulbDiscovery)
73+
log.info parent.bulbListHandler(device.hub.id, msg.body)
6974
}
7075
}
7176
else if (contentType?.contains("xml")) {
72-
log.debug "HUE BRIDGE, SWALLOWING BRIDGE DESCRIPTION RESPONSE -- BRIDGE ALREADY PRESENT"
77+
log.debug "HUE BRIDGE ALREADY PRESENT"
7378
}
7479
}
7580
}

devicetypes/smartthings/hue-bulb.src/hue-bulb.groovy

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/**
23
* Hue Bulb
34
*
@@ -49,7 +50,6 @@ metadata {
4950

5051
main(["switch"])
5152
details(["switch", "levelSliderControl", "rgbSelector", "refresh", "reset"])
52-
5353
}
5454

5555
// parse events into attributes
@@ -68,13 +68,13 @@ def parse(description) {
6868
}
6969

7070
// handle commands
71-
def on(transition = "4") {
72-
log.trace parent.on(this,transition)
71+
def on() {
72+
log.trace parent.on(this)
7373
sendEvent(name: "switch", value: "on")
7474
}
7575

76-
def off(transition = "4") {
77-
log.trace parent.off(this,transition)
76+
def off() {
77+
log.trace parent.off(this)
7878
sendEvent(name: "switch", value: "off")
7979
}
8080

@@ -107,9 +107,9 @@ def setHue(percent) {
107107
sendEvent(name: "hue", value: percent)
108108
}
109109

110-
def setColor(value,alert = "none",transition = 4) {
110+
def setColor(value) {
111111
log.debug "setColor: ${value}, $this"
112-
parent.setColor(this, value, alert, transition)
112+
parent.setColor(this, value)
113113
if (value.hue) { sendEvent(name: "hue", value: value.hue)}
114114
if (value.saturation) { sendEvent(name: "saturation", value: value.saturation)}
115115
if (value.hex) { sendEvent(name: "color", value: value.hex)}

devicetypes/smartthings/hue-lux-bulb.src/hue-lux-bulb.groovy

+34-17
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,41 @@ metadata {
1919
simulator {
2020
// TODO: define status and reply messages here
2121
}
22+
23+
tiles(scale: 2) {
24+
multiAttributeTile(name:"rich-control", type: "lighting", canChangeIcon: true){
25+
tileAttribute ("device.switch", key: "PRIMARY_CONTROL") {
26+
attributeState "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
27+
attributeState "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
28+
attributeState "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
29+
attributeState "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
30+
}
31+
tileAttribute ("device.level", key: "SLIDER_CONTROL") {
32+
attributeState "level", action:"switch level.setLevel", range:"(0..100)"
33+
}
34+
tileAttribute ("device.level", key: "SECONDARY_CONTROL") {
35+
attributeState "level", label: 'Level ${currentValue}%'
36+
}
37+
}
38+
39+
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
40+
state "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
41+
state "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
42+
state "turningOn", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821", nextState:"turningOff"
43+
state "turningOff", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff", nextState:"turningOn"
44+
}
45+
46+
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, range:"(0..100)") {
47+
state "level", action:"switch level.setLevel"
48+
}
49+
50+
standardTile("refresh", "device.switch", inactiveLabel: false, height: 2, width: 2, decoration: "flat") {
51+
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
52+
}
2253

23-
standardTile("switch", "device.switch", width: 2, height: 2, canChangeIcon: true) {
24-
state "on", label:'${name}', action:"switch.off", icon:"st.lights.philips.hue-single", backgroundColor:"#79b821"
25-
state "off", label:'${name}', action:"switch.on", icon:"st.lights.philips.hue-single", backgroundColor:"#ffffff"
26-
}
27-
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
28-
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
29-
}
30-
controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 2, inactiveLabel: false, range:"(0..100)") {
31-
state "level", action:"switch level.setLevel"
32-
}
33-
valueTile("level", "device.level", inactiveLabel: false, decoration: "flat") {
34-
state "level", label: 'Level ${currentValue}%'
35-
}
36-
37-
main(["switch"])
38-
details(["switch", "levelSliderControl", "refresh"])
39-
54+
main(["switch"])
55+
details(["rich-control", "refresh"])
56+
}
4057
}
4158

4259
// parse events into attributes

0 commit comments

Comments
 (0)