mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-18 13:20:53 +00:00
Compare commits
5 Commits
MSA-1570-1
...
PROD_2016.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6beb8bb50c | ||
|
|
3675332b75 | ||
|
|
7431346187 | ||
|
|
6aa0ff97b3 | ||
|
|
44088d626a |
@@ -84,18 +84,20 @@ def refresh() {
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "in configure()"
|
log.debug "in configure()"
|
||||||
configureHealthCheck()
|
return configureHealthCheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
def configureHealthCheck() {
|
def configureHealthCheck() {
|
||||||
Integer hcIntervalMinutes = 12
|
Integer hcIntervalMinutes = 12
|
||||||
refresh()
|
|
||||||
sendEvent(name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: hcIntervalMinutes * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
|
return refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
log.debug "in updated()"
|
log.debug "in updated()"
|
||||||
configureHealthCheck()
|
// updated() doesn't have it's return value processed as hub commands, so we have to send them explicitly
|
||||||
|
def cmds = configureHealthCheck()
|
||||||
|
cmds.each{ sendHubCommand(new physicalgraph.device.HubAction(it)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
def ping() {
|
def ping() {
|
||||||
|
|||||||
@@ -381,38 +381,28 @@ def updateDevices() {
|
|||||||
selectors.add("${device.id}")
|
selectors.add("${device.id}")
|
||||||
if (!childDevice) {
|
if (!childDevice) {
|
||||||
// log.info("Adding device ${device.id}: ${device.product}")
|
// log.info("Adding device ${device.id}: ${device.product}")
|
||||||
def data = [
|
|
||||||
label: device.label,
|
|
||||||
level: Math.round((device.brightness ?: 1) * 100),
|
|
||||||
switch: device.power,
|
|
||||||
colorTemperature: device.color.kelvin
|
|
||||||
]
|
|
||||||
if (device.product.capabilities.has_color) {
|
if (device.product.capabilities.has_color) {
|
||||||
data["color"] = colorUtil.hslToHex((device.color.hue / 3.6) as int, (device.color.saturation * 100) as int)
|
childDevice = addChildDevice(app.namespace, "LIFX Color Bulb", device.id, null, ["label": device.label, "completedSetup": true])
|
||||||
data["hue"] = device.color.hue / 3.6
|
|
||||||
data["saturation"] = device.color.saturation * 100
|
|
||||||
childDevice = addChildDevice(app.namespace, "LIFX Color Bulb", device.id, null, data)
|
|
||||||
} else {
|
} else {
|
||||||
childDevice = addChildDevice(app.namespace, "LIFX White Bulb", device.id, null, data)
|
childDevice = addChildDevice(app.namespace, "LIFX White Bulb", device.id, null, ["label": device.label, "completedSetup": true])
|
||||||
}
|
}
|
||||||
childDevice?.completedSetup = true
|
|
||||||
} else {
|
|
||||||
if (device.product.capabilities.has_color) {
|
|
||||||
sendEvent(name: "color", value: colorUtil.hslToHex((device.color.hue / 3.6) as int, (device.color.saturation * 100) as int))
|
|
||||||
sendEvent(name: "hue", value: device.color.hue / 3.6)
|
|
||||||
sendEvent(name: "saturation", value: device.color.saturation * 100)
|
|
||||||
}
|
|
||||||
childDevice.sendEvent(name: "label", value: device.label)
|
|
||||||
childDevice.sendEvent(name: "level", value: Math.round((device.brightness ?: 1) * 100))
|
|
||||||
childDevice.sendEvent(name: "switch.setLevel", value: Math.round((device.brightness ?: 1) * 100))
|
|
||||||
childDevice.sendEvent(name: "switch", value: device.power)
|
|
||||||
childDevice.sendEvent(name: "colorTemperature", value: device.color.kelvin)
|
|
||||||
childDevice.sendEvent(name: "model", value: device.product.name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (device.product.capabilities.has_color) {
|
||||||
|
childDevice.sendEvent(name: "color", value: colorUtil.hslToHex((device.color.hue / 3.6) as int, (device.color.saturation * 100) as int))
|
||||||
|
childDevice.sendEvent(name: "hue", value: device.color.hue / 3.6)
|
||||||
|
childDevice.sendEvent(name: "saturation", value: device.color.saturation * 100)
|
||||||
|
}
|
||||||
|
childDevice.sendEvent(name: "label", value: device.label)
|
||||||
|
childDevice.sendEvent(name: "level", value: Math.round((device.brightness ?: 1) * 100))
|
||||||
|
childDevice.sendEvent(name: "switch.setLevel", value: Math.round((device.brightness ?: 1) * 100))
|
||||||
|
childDevice.sendEvent(name: "switch", value: device.power)
|
||||||
|
childDevice.sendEvent(name: "colorTemperature", value: device.color.kelvin)
|
||||||
|
childDevice.sendEvent(name: "model", value: device.product.name)
|
||||||
|
|
||||||
if (state.devices[device.id] == null) {
|
if (state.devices[device.id] == null) {
|
||||||
// State missing, add it and set it to opposite status as current status to provoke event below
|
// State missing, add it and set it to opposite status as current status to provoke event below
|
||||||
state.devices[device.id] = [online : !device.connected]
|
state.devices[device.id] = [online: !device.connected]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!state.devices[device.id]?.online && device.connected) {
|
if (!state.devices[device.id]?.online && device.connected) {
|
||||||
|
|||||||
Reference in New Issue
Block a user