mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-15 21:03:23 +00:00
Compare commits
67 Commits
PROD_2016.
...
PROD_2016.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd7c6b90d5 | ||
|
|
f5bd580c9e | ||
|
|
d5329dbde3 | ||
|
|
48818cfb06 | ||
|
|
079919260b | ||
|
|
570922e2ac | ||
|
|
53ed9b4d2b | ||
|
|
7149a81c85 | ||
|
|
fb0caa6446 | ||
|
|
3d05d42cb8 | ||
|
|
0f70362e0a | ||
|
|
bc817f8530 | ||
|
|
01b8399893 | ||
|
|
60c2006bfc | ||
|
|
1e4f1223e7 | ||
|
|
6862785d6c | ||
|
|
1858c280a5 | ||
|
|
6b7d0968f6 | ||
|
|
e8101630a3 | ||
|
|
f5ba78b221 | ||
|
|
1e54b93b0c | ||
|
|
bac37f9ca2 | ||
|
|
f0ecb65c09 | ||
|
|
1c0ddd2571 | ||
|
|
b7e0cbda09 | ||
|
|
f80e094bd9 | ||
|
|
ce9ac624d0 | ||
|
|
f3f5cc42c9 | ||
|
|
313fe8b734 | ||
|
|
0d693386d1 | ||
|
|
d1aee1e874 | ||
|
|
3528e7da51 | ||
|
|
5c2e06c98d | ||
|
|
26df619b4f | ||
|
|
af2ea04442 | ||
|
|
383f72580a | ||
|
|
090a306939 | ||
|
|
d0a16c10b2 | ||
|
|
faa65f204d | ||
|
|
bacd335991 | ||
|
|
740e5e096c | ||
|
|
aac2f9b177 | ||
|
|
048eb77e64 | ||
|
|
dadec937fa | ||
|
|
78aa6691c4 | ||
|
|
315918dc6f | ||
|
|
276f7d3b43 | ||
|
|
ce12ad5013 | ||
|
|
beed783d19 | ||
|
|
7f347638d5 | ||
|
|
1f8ce734e7 | ||
|
|
17bf040c7e | ||
|
|
f1c3f5942b | ||
|
|
212c9c4179 | ||
|
|
4898006e4e | ||
|
|
d3eb7f756f | ||
|
|
b95ba37364 | ||
|
|
87f8755faf | ||
|
|
555a9f5ab4 | ||
|
|
0744384dbf | ||
|
|
97e0e9d0f8 | ||
|
|
655e756b1b | ||
|
|
7ce7ad86bd | ||
|
|
24c64608a9 | ||
|
|
dbc2a1e45c | ||
|
|
92cc8afdf7 | ||
|
|
e545842f7c |
@@ -274,6 +274,7 @@ private Map makeTemperatureResult(value) {
|
|||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: "" + value,
|
value: "" + value,
|
||||||
descriptionText: "${linkText} is ${value}°${temperatureScale}",
|
descriptionText: "${linkText} is ${value}°${temperatureScale}",
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,8 @@ private Map getTemperatureResult(value) {
|
|||||||
return [
|
return [
|
||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText
|
descriptionText: descriptionText,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ metadata {
|
|||||||
|
|
||||||
command "everywhereJoin"
|
command "everywhereJoin"
|
||||||
command "everywhereLeave"
|
command "everywhereLeave"
|
||||||
|
|
||||||
|
command "forceOff"
|
||||||
|
command "forceOn"
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -64,9 +67,9 @@ metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
standardTile("switch", "device.switch", width: 1, height: 1, canChangeIcon: true) {
|
standardTile("switch", "device.switch", width: 1, height: 1, canChangeIcon: true) {
|
||||||
state "on", label: '${name}', action: "switch.off", icon: "st.Electronics.electronics16", backgroundColor: "#79b821", nextState:"turningOff"
|
state "on", label: '${name}', action: "forceOff", icon: "st.Electronics.electronics16", backgroundColor: "#79b821", nextState:"turningOff"
|
||||||
state "turningOff", label:'TURNING OFF', icon:"st.Electronics.electronics16", backgroundColor:"#ffffff"
|
state "turningOff", label:'TURNING OFF', icon:"st.Electronics.electronics16", backgroundColor:"#ffffff"
|
||||||
state "off", label: '${name}', action: "switch.on", icon: "st.Electronics.electronics16", backgroundColor: "#ffffff", nextState:"turningOn"
|
state "off", label: '${name}', action: "forceOn", icon: "st.Electronics.electronics16", backgroundColor: "#ffffff", nextState:"turningOn"
|
||||||
state "turningOn", label:'TURNING ON', icon:"st.Electronics.electronics16", backgroundColor:"#79b821"
|
state "turningOn", label:'TURNING ON', icon:"st.Electronics.electronics16", backgroundColor:"#79b821"
|
||||||
}
|
}
|
||||||
valueTile("1", "device.station1", decoration: "flat", canChangeIcon: false) {
|
valueTile("1", "device.station1", decoration: "flat", canChangeIcon: false) {
|
||||||
@@ -140,8 +143,22 @@ metadata {
|
|||||||
* one place.
|
* one place.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
def off() { onAction("off") }
|
def off() {
|
||||||
def on() { onAction("on") }
|
if (device.currentState("switch")?.value == "on") {
|
||||||
|
onAction("off")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def forceOff() {
|
||||||
|
onAction("off")
|
||||||
|
}
|
||||||
|
def on() {
|
||||||
|
if (device.currentState("switch")?.value == "off") {
|
||||||
|
onAction("on")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
def forceOn() {
|
||||||
|
onAction("on")
|
||||||
|
}
|
||||||
def volup() { onAction("volup") }
|
def volup() { onAction("volup") }
|
||||||
def voldown() { onAction("voldown") }
|
def voldown() { onAction("voldown") }
|
||||||
def preset1() { onAction("1") }
|
def preset1() { onAction("1") }
|
||||||
@@ -240,11 +257,11 @@ def onAction(String user, data=null) {
|
|||||||
def actions = null
|
def actions = null
|
||||||
switch (user) {
|
switch (user) {
|
||||||
case "on":
|
case "on":
|
||||||
actions = boseSetPowerState(true)
|
boseSetPowerState(true)
|
||||||
break
|
break
|
||||||
case "off":
|
case "off":
|
||||||
boseSetNowPlaying(null, "STANDBY")
|
boseSetNowPlaying(null, "STANDBY")
|
||||||
actions = boseSetPowerState(false)
|
boseSetPowerState(false)
|
||||||
break
|
break
|
||||||
case "volume":
|
case "volume":
|
||||||
actions = boseSetVolume(data)
|
actions = boseSetVolume(data)
|
||||||
|
|||||||
@@ -89,14 +89,17 @@ def parse(String description) {
|
|||||||
log.debug "TEMP"
|
log.debug "TEMP"
|
||||||
map.name = "temperature"
|
map.name = "temperature"
|
||||||
map.value = getTemperature(descMap.value)
|
map.value = getTemperature(descMap.value)
|
||||||
|
map.unit = temperatureScale
|
||||||
} else if (descMap.cluster == "0201" && descMap.attrId == "0011") {
|
} else if (descMap.cluster == "0201" && descMap.attrId == "0011") {
|
||||||
log.debug "COOLING SETPOINT"
|
log.debug "COOLING SETPOINT"
|
||||||
map.name = "coolingSetpoint"
|
map.name = "coolingSetpoint"
|
||||||
map.value = getTemperature(descMap.value)
|
map.value = getTemperature(descMap.value)
|
||||||
|
map.unit = temperatureScale
|
||||||
} else if (descMap.cluster == "0201" && descMap.attrId == "0012") {
|
} else if (descMap.cluster == "0201" && descMap.attrId == "0012") {
|
||||||
log.debug "HEATING SETPOINT"
|
log.debug "HEATING SETPOINT"
|
||||||
map.name = "heatingSetpoint"
|
map.name = "heatingSetpoint"
|
||||||
map.value = getTemperature(descMap.value)
|
map.value = getTemperature(descMap.value)
|
||||||
|
map.unit = temperatureScale
|
||||||
} else if (descMap.cluster == "0201" && descMap.attrId == "001c") {
|
} else if (descMap.cluster == "0201" && descMap.attrId == "001c") {
|
||||||
log.debug "MODE"
|
log.debug "MODE"
|
||||||
map.name = "thermostatMode"
|
map.name = "thermostatMode"
|
||||||
@@ -169,7 +172,7 @@ def setHeatingSetpoint(degrees) {
|
|||||||
|
|
||||||
def degreesInteger = Math.round(degrees)
|
def degreesInteger = Math.round(degrees)
|
||||||
log.debug "setHeatingSetpoint({$degreesInteger} ${temperatureScale})"
|
log.debug "setHeatingSetpoint({$degreesInteger} ${temperatureScale})"
|
||||||
sendEvent("name": "heatingSetpoint", "value": degreesInteger)
|
sendEvent("name": "heatingSetpoint", "value": degreesInteger, "unit": temperatureScale)
|
||||||
|
|
||||||
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
||||||
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x12 0x29 {" + hex(celsius * 100) + "}"
|
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x12 0x29 {" + hex(celsius * 100) + "}"
|
||||||
@@ -180,7 +183,7 @@ def setCoolingSetpoint(degrees) {
|
|||||||
if (degrees != null) {
|
if (degrees != null) {
|
||||||
def degreesInteger = Math.round(degrees)
|
def degreesInteger = Math.round(degrees)
|
||||||
log.debug "setCoolingSetpoint({$degreesInteger} ${temperatureScale})"
|
log.debug "setCoolingSetpoint({$degreesInteger} ${temperatureScale})"
|
||||||
sendEvent("name": "coolingSetpoint", "value": degreesInteger)
|
sendEvent("name": "coolingSetpoint", "value": degreesInteger, "unit": temperatureScale)
|
||||||
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
||||||
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x11 0x29 {" + hex(celsius * 100) + "}"
|
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x11 0x29 {" + hex(celsius * 100) + "}"
|
||||||
}
|
}
|
||||||
|
|||||||
2
devicetypes/smartthings/cree-bulb.src/.st-ignore
Normal file
2
devicetypes/smartthings/cree-bulb.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
36
devicetypes/smartthings/cree-bulb.src/README.md
Normal file
36
devicetypes/smartthings/cree-bulb.src/README.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# Connected Cree LED Bulb
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Connected Cree LED Bulb](https://support.smartthings.com/hc/en-us/articles/204258280-Cree-Connected-LED-Bulb)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Actuator** - represents that a Device has commands
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Polling** - represents that poll() can be implemented for the device
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Switch** - can detect state (possible values: on/off)
|
||||||
|
* **Switch Level** - represents current light level, usually 0-100 in percent
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C6 Connected Cree LED Bulb with maxReportTime of 10 min.
|
||||||
|
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||||
|
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||||
|
Check-in interval = 2*10 = 20 min
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the device is out of range.
|
||||||
|
Pairing needs to be tried again by placing the device closer to the hub.
|
||||||
|
Instructions related to pairing, resetting and removing the device from SmartThings can be found in the following link:
|
||||||
|
* [Cree Connected LED Bulb Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/204258280-Cree-Connected-LED-Bulb)
|
||||||
@@ -67,12 +67,6 @@ def parse(String description) {
|
|||||||
def resultMap = zigbee.getEvent(description)
|
def resultMap = zigbee.getEvent(description)
|
||||||
if (resultMap) {
|
if (resultMap) {
|
||||||
sendEvent(resultMap)
|
sendEvent(resultMap)
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.debug "DID NOT PARSE MESSAGE for description : $description"
|
log.debug "DID NOT PARSE MESSAGE for description : $description"
|
||||||
@@ -96,15 +90,7 @@ def setLevel(value) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.levelRefresh()
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.levelRefresh()
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -117,6 +103,8 @@ def poll() {
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Reporting and Bindings."
|
log.debug "Configuring Reporting and Bindings."
|
||||||
sendEvent(name: "checkInterval", value: 1200, displayed: false, data: [protocol: "zigbee"])
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
|
// minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,11 +152,11 @@ def generateEvent(Map results) {
|
|||||||
sendValue = location.temperatureScale == "C"? roundC(sendValue) : sendValue
|
sendValue = location.temperatureScale == "C"? roundC(sendValue) : sendValue
|
||||||
isChange = isTemperatureStateChange(device, name, value.toString())
|
isChange = isTemperatureStateChange(device, name, value.toString())
|
||||||
isDisplayed = isChange
|
isDisplayed = isChange
|
||||||
event << [value: sendValue, isStateChange: isChange, displayed: isDisplayed]
|
event << [value: sendValue, unit: temperatureScale, isStateChange: isChange, displayed: isDisplayed]
|
||||||
} else if (name=="maxCoolingSetpoint" || name=="minCoolingSetpoint" || name=="maxHeatingSetpoint" || name=="minHeatingSetpoint") {
|
} else if (name=="maxCoolingSetpoint" || name=="minCoolingSetpoint" || name=="maxHeatingSetpoint" || name=="minHeatingSetpoint") {
|
||||||
def sendValue = convertTemperatureIfNeeded(value.toDouble(), "F", 1) //API return temperature value in F
|
def sendValue = convertTemperatureIfNeeded(value.toDouble(), "F", 1) //API return temperature value in F
|
||||||
sendValue = location.temperatureScale == "C"? roundC(sendValue) : sendValue
|
sendValue = location.temperatureScale == "C"? roundC(sendValue) : sendValue
|
||||||
event << [value: sendValue, displayed: false]
|
event << [value: sendValue, unit: temperatureScale, displayed: false]
|
||||||
} else if (name=="heatMode" || name=="coolMode" || name=="autoMode" || name=="auxHeatMode"){
|
} else if (name=="heatMode" || name=="coolMode" || name=="autoMode" || name=="auxHeatMode"){
|
||||||
isChange = isStateChange(device, name, value.toString())
|
isChange = isStateChange(device, name, value.toString())
|
||||||
event << [value: value.toString(), isStateChange: isChange, displayed: false]
|
event << [value: value.toString(), isStateChange: isChange, displayed: false]
|
||||||
@@ -234,9 +234,9 @@ void setHeatingSetpoint(setpoint) {
|
|||||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||||
|
|
||||||
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
||||||
if (parent.setHold(this, heatingValue, coolingValue, deviceId, sendHoldType)) {
|
if (parent.setHold(heatingValue, coolingValue, deviceId, sendHoldType)) {
|
||||||
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint)
|
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
|
||||||
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint)
|
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
|
||||||
log.debug "Done setHeatingSetpoint> coolingSetpoint: ${coolingSetpoint}, heatingSetpoint: ${heatingSetpoint}"
|
log.debug "Done setHeatingSetpoint> coolingSetpoint: ${coolingSetpoint}, heatingSetpoint: ${heatingSetpoint}"
|
||||||
generateSetpointEvent()
|
generateSetpointEvent()
|
||||||
generateStatusEvent()
|
generateStatusEvent()
|
||||||
@@ -271,9 +271,9 @@ void setCoolingSetpoint(setpoint) {
|
|||||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||||
|
|
||||||
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
||||||
if (parent.setHold(this, heatingValue, coolingValue, deviceId, sendHoldType)) {
|
if (parent.setHold(heatingValue, coolingValue, deviceId, sendHoldType)) {
|
||||||
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint)
|
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
|
||||||
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint)
|
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
|
||||||
log.debug "Done setCoolingSetpoint>> coolingSetpoint = ${coolingSetpoint}, heatingSetpoint = ${heatingSetpoint}"
|
log.debug "Done setCoolingSetpoint>> coolingSetpoint = ${coolingSetpoint}, heatingSetpoint = ${heatingSetpoint}"
|
||||||
generateSetpointEvent()
|
generateSetpointEvent()
|
||||||
generateStatusEvent()
|
generateStatusEvent()
|
||||||
@@ -287,14 +287,14 @@ void resumeProgram() {
|
|||||||
log.debug "resumeProgram() is called"
|
log.debug "resumeProgram() is called"
|
||||||
sendEvent("name":"thermostatStatus", "value":"resuming schedule", "description":statusText, displayed: false)
|
sendEvent("name":"thermostatStatus", "value":"resuming schedule", "description":statusText, displayed: false)
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
if (parent.resumeProgram(this, deviceId)) {
|
if (parent.resumeProgram(deviceId)) {
|
||||||
sendEvent("name":"thermostatStatus", "value":"setpoint is updating", "description":statusText, displayed: false)
|
sendEvent("name":"thermostatStatus", "value":"setpoint is updating", "description":statusText, displayed: false)
|
||||||
runIn(5, "poll")
|
runIn(5, "poll")
|
||||||
log.debug "resumeProgram() is done"
|
log.debug "resumeProgram() is done"
|
||||||
sendEvent("name":"resumeProgram", "value":"resume", descriptionText: "resumeProgram is done", displayed: false, isStateChange: true)
|
sendEvent("name":"resumeProgram", "value":"resume", descriptionText: "resumeProgram is done", displayed: false, isStateChange: true)
|
||||||
} else {
|
} else {
|
||||||
sendEvent("name":"thermostatStatus", "value":"failed resume click refresh", "description":statusText, displayed: false)
|
sendEvent("name":"thermostatStatus", "value":"failed resume click refresh", "description":statusText, displayed: false)
|
||||||
log.error "Error resumeProgram() check parent.resumeProgram(this, deviceId)"
|
log.error "Error resumeProgram() check parent.resumeProgram(deviceId)"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -406,7 +406,7 @@ def generateOperatingStateEvent(operatingState) {
|
|||||||
def off() {
|
def off() {
|
||||||
log.debug "off"
|
log.debug "off"
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
if (parent.setMode (this,"off", deviceId))
|
if (parent.setMode ("off", deviceId))
|
||||||
generateModeEvent("off")
|
generateModeEvent("off")
|
||||||
else {
|
else {
|
||||||
log.debug "Error setting new mode."
|
log.debug "Error setting new mode."
|
||||||
@@ -420,7 +420,7 @@ def off() {
|
|||||||
def heat() {
|
def heat() {
|
||||||
log.debug "heat"
|
log.debug "heat"
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
if (parent.setMode (this,"heat", deviceId))
|
if (parent.setMode ("heat", deviceId))
|
||||||
generateModeEvent("heat")
|
generateModeEvent("heat")
|
||||||
else {
|
else {
|
||||||
log.debug "Error setting new mode."
|
log.debug "Error setting new mode."
|
||||||
@@ -438,7 +438,7 @@ def emergencyHeat() {
|
|||||||
def auxHeatOnly() {
|
def auxHeatOnly() {
|
||||||
log.debug "auxHeatOnly"
|
log.debug "auxHeatOnly"
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
if (parent.setMode (this,"auxHeatOnly", deviceId))
|
if (parent.setMode ("auxHeatOnly", deviceId))
|
||||||
generateModeEvent("auxHeatOnly")
|
generateModeEvent("auxHeatOnly")
|
||||||
else {
|
else {
|
||||||
log.debug "Error setting new mode."
|
log.debug "Error setting new mode."
|
||||||
@@ -452,7 +452,7 @@ def auxHeatOnly() {
|
|||||||
def cool() {
|
def cool() {
|
||||||
log.debug "cool"
|
log.debug "cool"
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
if (parent.setMode (this,"cool", deviceId))
|
if (parent.setMode ("cool", deviceId))
|
||||||
generateModeEvent("cool")
|
generateModeEvent("cool")
|
||||||
else {
|
else {
|
||||||
log.debug "Error setting new mode."
|
log.debug "Error setting new mode."
|
||||||
@@ -466,7 +466,7 @@ def cool() {
|
|||||||
def auto() {
|
def auto() {
|
||||||
log.debug "auto"
|
log.debug "auto"
|
||||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||||
if (parent.setMode (this,"auto", deviceId))
|
if (parent.setMode ("auto", deviceId))
|
||||||
generateModeEvent("auto")
|
generateModeEvent("auto")
|
||||||
else {
|
else {
|
||||||
log.debug "Error setting new mode."
|
log.debug "Error setting new mode."
|
||||||
@@ -489,7 +489,7 @@ def fanOn() {
|
|||||||
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
||||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||||
|
|
||||||
if (parent.setFanMode(this, heatingValue, coolingValue, deviceId, sendHoldType, fanMode)) {
|
if (parent.setFanMode(heatingValue, coolingValue, deviceId, sendHoldType, fanMode)) {
|
||||||
generateFanModeEvent(fanMode)
|
generateFanModeEvent(fanMode)
|
||||||
} else {
|
} else {
|
||||||
log.debug "Error setting new mode."
|
log.debug "Error setting new mode."
|
||||||
@@ -510,7 +510,7 @@ def fanAuto() {
|
|||||||
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
||||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||||
|
|
||||||
if (parent.setFanMode(this, heatingValue, coolingValue, deviceId, sendHoldType, fanMode)) {
|
if (parent.setFanMode(heatingValue, coolingValue, deviceId, sendHoldType, fanMode)) {
|
||||||
generateFanModeEvent(fanMode)
|
generateFanModeEvent(fanMode)
|
||||||
} else {
|
} else {
|
||||||
log.debug "Error setting new mode."
|
log.debug "Error setting new mode."
|
||||||
@@ -556,12 +556,12 @@ def generateSetpointEvent() {
|
|||||||
|
|
||||||
if (mode == "heat") {
|
if (mode == "heat") {
|
||||||
|
|
||||||
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint )
|
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (mode == "cool") {
|
else if (mode == "cool") {
|
||||||
|
|
||||||
sendEvent("name":"thermostatSetpoint", "value":coolingSetpoint)
|
sendEvent("name":"thermostatSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
|
||||||
|
|
||||||
} else if (mode == "auto") {
|
} else if (mode == "auto") {
|
||||||
|
|
||||||
@@ -573,7 +573,7 @@ def generateSetpointEvent() {
|
|||||||
|
|
||||||
} else if (mode == "auxHeatOnly") {
|
} else if (mode == "auxHeatOnly") {
|
||||||
|
|
||||||
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint)
|
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ void raiseSetpoint() {
|
|||||||
targetvalue = maxCoolingSetpoint
|
targetvalue = maxCoolingSetpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEvent("name":"thermostatSetpoint", "value":targetvalue, displayed: false)
|
sendEvent("name":"thermostatSetpoint", "value":targetvalue, "unit":location.temperatureScale, displayed: false)
|
||||||
log.info "In mode $mode raiseSetpoint() to $targetvalue"
|
log.info "In mode $mode raiseSetpoint() to $targetvalue"
|
||||||
|
|
||||||
runIn(3, "alterSetpoint", [data: [value:targetvalue], overwrite: true]) //when user click button this runIn will be overwrite
|
runIn(3, "alterSetpoint", [data: [value:targetvalue], overwrite: true]) //when user click button this runIn will be overwrite
|
||||||
@@ -644,7 +644,7 @@ void lowerSetpoint() {
|
|||||||
targetvalue = minCoolingSetpoint
|
targetvalue = minCoolingSetpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
sendEvent("name":"thermostatSetpoint", "value":targetvalue, displayed: false)
|
sendEvent("name":"thermostatSetpoint", "value":targetvalue, "unit":location.temperatureScale, displayed: false)
|
||||||
log.info "In mode $mode lowerSetpoint() to $targetvalue"
|
log.info "In mode $mode lowerSetpoint() to $targetvalue"
|
||||||
|
|
||||||
runIn(3, "alterSetpoint", [data: [value:targetvalue], overwrite: true]) //when user click button this runIn will be overwrite
|
runIn(3, "alterSetpoint", [data: [value:targetvalue], overwrite: true]) //when user click button this runIn will be overwrite
|
||||||
@@ -690,10 +690,10 @@ void alterSetpoint(temp) {
|
|||||||
def coolingValue = location.temperatureScale == "C"? convertCtoF(targetCoolingSetpoint) : targetCoolingSetpoint
|
def coolingValue = location.temperatureScale == "C"? convertCtoF(targetCoolingSetpoint) : targetCoolingSetpoint
|
||||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(targetHeatingSetpoint) : targetHeatingSetpoint
|
def heatingValue = location.temperatureScale == "C"? convertCtoF(targetHeatingSetpoint) : targetHeatingSetpoint
|
||||||
|
|
||||||
if (parent.setHold(this, heatingValue, coolingValue, deviceId, sendHoldType)) {
|
if (parent.setHold(heatingValue, coolingValue, deviceId, sendHoldType)) {
|
||||||
sendEvent("name": "thermostatSetpoint", "value": temp.value, displayed: false)
|
sendEvent("name": "thermostatSetpoint", "value": temp.value, displayed: false)
|
||||||
sendEvent("name": "heatingSetpoint", "value": targetHeatingSetpoint)
|
sendEvent("name": "heatingSetpoint", "value": targetHeatingSetpoint, "unit": location.temperatureScale)
|
||||||
sendEvent("name": "coolingSetpoint", "value": targetCoolingSetpoint)
|
sendEvent("name": "coolingSetpoint", "value": targetCoolingSetpoint, "unit": location.temperatureScale)
|
||||||
log.debug "alterSetpoint in mode $mode succeed change setpoint to= ${temp.value}"
|
log.debug "alterSetpoint in mode $mode succeed change setpoint to= ${temp.value}"
|
||||||
} else {
|
} else {
|
||||||
log.error "Error alterSetpoint()"
|
log.error "Error alterSetpoint()"
|
||||||
|
|||||||
@@ -682,7 +682,7 @@ def setHeatingSetpoint(degrees) {
|
|||||||
def temperatureScale = getTemperatureScale()
|
def temperatureScale = getTemperatureScale()
|
||||||
|
|
||||||
def degreesInteger = degrees as Integer
|
def degreesInteger = degrees as Integer
|
||||||
sendEvent("name":"heatingSetpoint", "value":degreesInteger)
|
sendEvent("name":"heatingSetpoint", "value":degreesInteger, "unit":temperatureScale)
|
||||||
|
|
||||||
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
||||||
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x12 0x29 {" + hex(celsius*100) + "}"
|
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x12 0x29 {" + hex(celsius*100) + "}"
|
||||||
@@ -691,7 +691,7 @@ def setHeatingSetpoint(degrees) {
|
|||||||
|
|
||||||
def setCoolingSetpoint(degrees) {
|
def setCoolingSetpoint(degrees) {
|
||||||
def degreesInteger = degrees as Integer
|
def degreesInteger = degrees as Integer
|
||||||
sendEvent("name":"coolingSetpoint", "value":degreesInteger)
|
sendEvent("name":"coolingSetpoint", "value":degreesInteger, "unit":temperatureScale)
|
||||||
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
|
||||||
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x11 0x29 {" + hex(celsius*100) + "}"
|
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x11 0x29 {" + hex(celsius*100) + "}"
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ metadata {
|
|||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
command "setAdjustedColor"
|
command "setAdjustedColor"
|
||||||
command "reset"
|
command "reset"
|
||||||
@@ -55,6 +56,10 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void installed() {
|
||||||
|
sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false)
|
||||||
|
}
|
||||||
|
|
||||||
// parse events into attributes
|
// parse events into attributes
|
||||||
def parse(description) {
|
def parse(description) {
|
||||||
log.debug "parse() - $description"
|
log.debug "parse() - $description"
|
||||||
@@ -166,3 +171,7 @@ def verifyPercent(percent) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def ping() {
|
||||||
|
log.debug "${parent.ping(this)}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ def parse(description) {
|
|||||||
log.trace "HUE BRIDGE, GENERATING EVENT: $map.name: $map.value"
|
log.trace "HUE BRIDGE, GENERATING EVENT: $map.name: $map.value"
|
||||||
results << createEvent(name: "${map.name}", value: "${map.value}")
|
results << createEvent(name: "${map.name}", value: "${map.value}")
|
||||||
} else {
|
} else {
|
||||||
log.trace "Parsing description"
|
log.trace "Parsing description"
|
||||||
def msg = parseLanMessage(description)
|
def msg = parseLanMessage(description)
|
||||||
if (msg.body) {
|
if (msg.body) {
|
||||||
def contentType = msg.headers["Content-Type"]
|
def contentType = msg.headers["Content-Type"]
|
||||||
@@ -72,13 +72,13 @@ def parse(description) {
|
|||||||
log.info "Bridge response: $msg.body"
|
log.info "Bridge response: $msg.body"
|
||||||
} else {
|
} else {
|
||||||
// Sending Bulbs List to parent"
|
// Sending Bulbs List to parent"
|
||||||
if (parent.state.inBulbDiscovery)
|
if (parent.isInBulbDiscovery())
|
||||||
log.info parent.bulbListHandler(device.hub.id, msg.body)
|
log.info parent.bulbListHandler(device.hub.id, msg.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (contentType?.contains("xml")) {
|
else if (contentType?.contains("xml")) {
|
||||||
log.debug "HUE BRIDGE ALREADY PRESENT"
|
log.debug "HUE BRIDGE ALREADY PRESENT"
|
||||||
parent.hubVerification(device.hub.id, msg.body)
|
parent.hubVerification(device.hub.id, msg.body)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ metadata {
|
|||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
command "setAdjustedColor"
|
command "setAdjustedColor"
|
||||||
command "reset"
|
command "reset"
|
||||||
@@ -64,6 +65,10 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void installed() {
|
||||||
|
sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false)
|
||||||
|
}
|
||||||
|
|
||||||
// parse events into attributes
|
// parse events into attributes
|
||||||
def parse(description) {
|
def parse(description) {
|
||||||
log.debug "parse() - $description"
|
log.debug "parse() - $description"
|
||||||
@@ -182,3 +187,7 @@ def verifyPercent(percent) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def ping() {
|
||||||
|
log.trace "${parent.ping(this)}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ metadata {
|
|||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
command "refresh"
|
command "refresh"
|
||||||
}
|
}
|
||||||
@@ -48,6 +49,10 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void installed() {
|
||||||
|
sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false)
|
||||||
|
}
|
||||||
|
|
||||||
// parse events into attributes
|
// parse events into attributes
|
||||||
def parse(description) {
|
def parse(description) {
|
||||||
log.debug "parse() - $description"
|
log.debug "parse() - $description"
|
||||||
@@ -87,3 +92,7 @@ void refresh() {
|
|||||||
log.debug "Executing 'refresh'"
|
log.debug "Executing 'refresh'"
|
||||||
parent.manualRefresh()
|
parent.manualRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def ping() {
|
||||||
|
log.debug "${parent.ping(this)}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ metadata {
|
|||||||
capability "Color Temperature"
|
capability "Color Temperature"
|
||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
command "refresh"
|
command "refresh"
|
||||||
}
|
}
|
||||||
@@ -53,6 +54,10 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void installed() {
|
||||||
|
sendEvent(name: "checkInterval", value: 60 * 15, data: [protocol: "lan"], displayed: false)
|
||||||
|
}
|
||||||
|
|
||||||
// parse events into attributes
|
// parse events into attributes
|
||||||
def parse(description) {
|
def parse(description) {
|
||||||
log.debug "parse() - $description"
|
log.debug "parse() - $description"
|
||||||
@@ -101,3 +106,7 @@ void refresh() {
|
|||||||
log.debug "Executing 'refresh'"
|
log.debug "Executing 'refresh'"
|
||||||
parent.manualRefresh()
|
parent.manualRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def ping() {
|
||||||
|
log.debug "${parent.ping(this)}"
|
||||||
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ def parse(String description) {
|
|||||||
|
|
||||||
if (descMap.cluster == "0300") {
|
if (descMap.cluster == "0300") {
|
||||||
if(descMap.attrId == "0000"){ //Hue Attribute
|
if(descMap.attrId == "0000"){ //Hue Attribute
|
||||||
def hueValue = Math.round(convertHexToInt(descMap.value) / 255 * 360)
|
def hueValue = Math.round(convertHexToInt(descMap.value) / 255 * 100)
|
||||||
log.debug "Hue value returned is $hueValue"
|
log.debug "Hue value returned is $hueValue"
|
||||||
sendEvent(name: "hue", value: hueValue, displayed:false)
|
sendEvent(name: "hue", value: hueValue, displayed:false)
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ def setLevel(value) {
|
|||||||
|
|
||||||
//input Hue Integer values; returns color name for saturation 100%
|
//input Hue Integer values; returns color name for saturation 100%
|
||||||
private getColorName(hueValue){
|
private getColorName(hueValue){
|
||||||
if(hueValue>360 || hueValue<0)
|
if(hueValue>100 || hueValue<0)
|
||||||
return
|
return
|
||||||
|
|
||||||
hueValue = Math.round(hueValue / 100 * 360)
|
hueValue = Math.round(hueValue / 100 * 360)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Osram Flex RGBW Light Strip
|
Osram Flex RGBW Light Strip
|
||||||
|
|
||||||
Osram bulbs have a firmware issue causing it to forget its dimming level when turned off (via commands). Handling
|
Osram bulbs have a firmware issue causing it to forget its dimming level when turned off (via commands). Handling
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "OSRAM LIGHTIFY LED Flexible Strip RGBW", namespace: "smartthings", author: "SmartThings") {
|
definition (name: "OSRAM LIGHTIFY LED Flexible Strip RGBW", namespace: "smartthings", author: "SmartThings") {
|
||||||
|
|
||||||
capability "Color Temperature"
|
capability "Color Temperature"
|
||||||
capability "Actuator"
|
capability "Actuator"
|
||||||
capability "Switch"
|
capability "Switch"
|
||||||
@@ -18,7 +18,7 @@ metadata {
|
|||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Color Control"
|
capability "Color Control"
|
||||||
|
|
||||||
attribute "colorName", "string"
|
attribute "colorName", "string"
|
||||||
|
|
||||||
command "setAdjustedColor"
|
command "setAdjustedColor"
|
||||||
@@ -49,7 +49,7 @@ metadata {
|
|||||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
|
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
|
||||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||||
}
|
}
|
||||||
|
|
||||||
controlTile("colorTempSliderControl", "device.colorTemperature", "slider", height: 1, width: 2, inactiveLabel: false, range:"(2700..6500)") {
|
controlTile("colorTempSliderControl", "device.colorTemperature", "slider", height: 1, width: 2, inactiveLabel: false, range:"(2700..6500)") {
|
||||||
state "colorTemperature", action:"color temperature.setColorTemperature"
|
state "colorTemperature", action:"color temperature.setColorTemperature"
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ def parse(String description) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(descMap.attrId == "0000"){ //Hue Attribute
|
else if(descMap.attrId == "0000"){ //Hue Attribute
|
||||||
def hueValue = Math.round(convertHexToInt(descMap.value) / 255 * 360)
|
def hueValue = Math.round(convertHexToInt(descMap.value) / 255 * 100)
|
||||||
log.debug "Hue value returned is $hueValue"
|
log.debug "Hue value returned is $hueValue"
|
||||||
sendEvent(name: "hue", value: hueValue, displayed:false)
|
sendEvent(name: "hue", value: hueValue, displayed:false)
|
||||||
}
|
}
|
||||||
@@ -274,7 +274,7 @@ private getGenericName(value){
|
|||||||
|
|
||||||
//input Hue Integer values; returns color name for saturation 100%
|
//input Hue Integer values; returns color name for saturation 100%
|
||||||
private getColorName(hueValue){
|
private getColorName(hueValue){
|
||||||
if(hueValue>360 || hueValue<0)
|
if(hueValue>100 || hueValue<0)
|
||||||
return
|
return
|
||||||
|
|
||||||
hueValue = Math.round(hueValue / 100 * 360)
|
hueValue = Math.round(hueValue / 100 * 360)
|
||||||
@@ -449,7 +449,7 @@ def setColor(value){
|
|||||||
def level = hex(value.level * 255 / 100)
|
def level = hex(value.level * 255 / 100)
|
||||||
cmd << zigbeeSetLevel(level)
|
cmd << zigbeeSetLevel(level)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.switch == "off") {
|
if (value.switch == "off") {
|
||||||
cmd << "delay 150"
|
cmd << "delay 150"
|
||||||
cmd << off()
|
cmd << off()
|
||||||
|
|||||||
2
devicetypes/smartthings/smartpower-outlet.src/.st-ignore
Normal file
2
devicetypes/smartthings/smartpower-outlet.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
38
devicetypes/smartthings/smartpower-outlet.src/README.md
Normal file
38
devicetypes/smartthings/smartpower-outlet.src/README.md
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# SmartPower Outlet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartPower Outlet](https://shop.smartthings.com/#!/products/smartpower-outlet)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Actuator** - represents that a Device has commands
|
||||||
|
* **Switch** - can detect state (possible values: on/off)
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Power Meter** - detects power meter for device in either w or kw.
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
* **Sensor** - detects sensor events
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C1 smart power outlet with maxReportTime of 10 min.
|
||||||
|
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||||
|
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||||
|
Check-in interval = 2*10 = 20 min
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the device is out of range.
|
||||||
|
Pairing needs to be tried again by placing the device closer to the hub.
|
||||||
|
Instructions related to pairing, resetting and removing the device from SmartThings can be found in the following links
|
||||||
|
for the different models:
|
||||||
|
* [SmartPower Outlet Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/201084854-SmartPower-Outlet)
|
||||||
|
* [Samsung SmartThings Outlet Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/205957620)
|
||||||
@@ -101,12 +101,6 @@ def parse(String description) {
|
|||||||
else {
|
else {
|
||||||
def descriptionText = finalResult.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off'
|
def descriptionText = finalResult.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off'
|
||||||
sendEvent(name: finalResult.type, value: finalResult.value, descriptionText: descriptionText, translatable: true)
|
sendEvent(name: finalResult.type, value: finalResult.value, descriptionText: descriptionText, translatable: true)
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -126,15 +120,7 @@ def on() {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.onOffRefresh()
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.onOffRefresh()
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -142,8 +128,10 @@ def refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
sendEvent(name: "checkInterval", value: 1200, displayed: false, data: [protocol: "zigbee"])
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
zigbee.onOffConfig() + powerConfig() + refresh()
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
|
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
zigbee.onOffConfig(0, 300) + powerConfig() + refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
//power config for devices with min reporting interval as 1 seconds and reporting interval if no activity as 10min (600s)
|
//power config for devices with min reporting interval as 1 seconds and reporting interval if no activity as 10min (600s)
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Smartsense Moisture Sensor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartThings Moisture Sensor](https://shop.smartthings.com/#!/products/samsung-smartthings-water-leak-sensor)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
* [Battery](#battery-specification)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Temperature Measurement** - defines device measures current temperature
|
||||||
|
* **Water Sensor** - can detect presence of water (dry or wet)
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C2 moisture sensor with maxReportTime of 1 hr.
|
||||||
|
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||||
|
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||||
|
Check-in interval = 2*60 = 120 min
|
||||||
|
|
||||||
|
## Battery Specification
|
||||||
|
|
||||||
|
One CR2 3V battery required.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the sensor doesn't pair when trying from the SmartThings mobile app, it is possible that the sensor is out of range.
|
||||||
|
Pairing needs to be tried again by placing the sensor closer to the hub.
|
||||||
|
Instructions related to pairing, resetting and removing the different sensors from SmartThings can be found in the following links
|
||||||
|
for the different models:
|
||||||
|
* [SmartSense Moisture Sensor Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/202847044-SmartSense-Moisture-Sensor)
|
||||||
|
* [Samsung SmartThings Water Leak Sensor Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/205957630)
|
||||||
|
Other troubleshooting tips are listed as follows:
|
||||||
|
* [Troubleshooting: Samsung SmartThings Water Leak Sensor won’t pair after removing pull-tab](https://support.smartthings.com/hc/en-us/articles/204966616-Troubleshooting-Samsung-SmartThings-device-won-t-pair-after-removing-pull-tab)
|
||||||
@@ -101,13 +101,6 @@ def parse(String description) {
|
|||||||
map = parseIasMessage(description)
|
map = parseIasMessage(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
|
|
||||||
log.debug "Parse returned $map"
|
log.debug "Parse returned $map"
|
||||||
def result = map ? createEvent(map) : null
|
def result = map ? createEvent(map) : null
|
||||||
|
|
||||||
@@ -233,6 +226,8 @@ private Map getBatteryResult(rawValue) {
|
|||||||
def maxVolts = 3.0
|
def maxVolts = 3.0
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
def roundedPct = Math.round(pct * 100)
|
def roundedPct = Math.round(pct * 100)
|
||||||
|
if (roundedPct <= 0)
|
||||||
|
roundedPct = 1
|
||||||
result.value = Math.min(100, roundedPct)
|
result.value = Math.min(100, roundedPct)
|
||||||
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
||||||
}
|
}
|
||||||
@@ -259,7 +254,8 @@ private Map getTemperatureResult(value) {
|
|||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText,
|
descriptionText: descriptionText,
|
||||||
translatable: true
|
translatable: true,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,15 +278,7 @@ private Map getMoistureResult(value) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -304,23 +292,19 @@ def refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
|
|
||||||
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
||||||
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
||||||
def configCmds = [
|
def enrollCmds = [
|
||||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 1 {${device.zigbeeId}} {}", "delay 500",
|
|
||||||
"zcl global send-me-a-report 1 0x20 0x20 30 21600 {01}", //checkin time 6 hrs
|
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 0x402 {${device.zigbeeId}} {}", "delay 500",
|
|
||||||
"zcl global send-me-a-report 0x402 0 0x29 30 3600 {6400}",
|
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500"
|
|
||||||
]
|
]
|
||||||
return configCmds + refresh() // send refresh cmds as part of config
|
|
||||||
|
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
// battery minReport 30 seconds, maxReportTime 6 hrs by default
|
||||||
|
return enrollCmds + zigbee.batteryConfig() + zigbee.temperatureConfig(30, 300) + refresh() // send refresh cmds as part of config
|
||||||
}
|
}
|
||||||
|
|
||||||
def enrollResponse() {
|
def enrollResponse() {
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ Works with:
|
|||||||
## Table of contents
|
## Table of contents
|
||||||
|
|
||||||
* [Capabilities](#capabilities)
|
* [Capabilities](#capabilities)
|
||||||
* [Health]($health)
|
* [Health](#device-health)
|
||||||
|
* [Battery](#battery-specification)
|
||||||
|
|
||||||
## Capabilities
|
## Capabilities
|
||||||
|
|
||||||
@@ -21,10 +22,24 @@ Works with:
|
|||||||
|
|
||||||
## Device Health
|
## Device Health
|
||||||
|
|
||||||
A Category C2 motion sensor that has 120min check-in interval
|
A Category C2 motion sensor with maxReportTime of 1 hr.
|
||||||
|
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||||
|
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||||
|
Check-in interval = 2*60 = 120 min
|
||||||
|
|
||||||
|
## Battery Specification
|
||||||
|
|
||||||
|
One CR2477 (for Samsung SmartThings Motion Sensor) / CR123A (SmartSense Motion Sensor) 3V battery is required.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the sensor is out of range.
|
||||||
|
Pairing needs to be tried again by placing the sensor closer to the hub.
|
||||||
|
Instructions related to pairing, resetting and removing the different motion sensors from SmartThings can be found in the following links
|
||||||
|
for the different models:
|
||||||
|
* [SmartSense Motion Sensor (original model) Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/200903280-SmartSense-Motion-Sensor-original-model-)
|
||||||
|
* [SmartSense Motion Sensor (2014 model) Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/203077520-SmartSense-Motion-Sensor-2014-model-)
|
||||||
|
* [Samsung SmartThings Motion Sensor (2015 model) Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/205957580-Samsung-SmartThings-Motion-Sensor-2015-model-)
|
||||||
|
Other troubleshooting tips are listed as follows:
|
||||||
|
* [Troubleshooting: Samsung SmartThings Motion Sensor is stuck showing "Motion Detected" or "No Motion"](https://support.smartthings.com/hc/en-us/articles/200961130-Troubleshooting-Samsung-SmartThings-Motion-Sensor-is-stuck-showing-Motion-Detected-or-No-Motion-)
|
||||||
|
* [Troubleshooting: Samsung SmartThings Motion Sensor won’t pair after removing pull-tab](https://support.smartthings.com/hc/en-us/articles/204966616-Troubleshooting-Samsung-SmartThings-device-won-t-pair-after-removing-pull-tab)
|
||||||
|
|||||||
@@ -105,13 +105,6 @@ def parse(String description) {
|
|||||||
map = parseIasMessage(description)
|
map = parseIasMessage(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
|
|
||||||
log.debug "Parse returned $map"
|
log.debug "Parse returned $map"
|
||||||
def result = map ? createEvent(map) : null
|
def result = map ? createEvent(map) : null
|
||||||
|
|
||||||
@@ -248,6 +241,8 @@ private Map getBatteryResult(rawValue) {
|
|||||||
def maxVolts = 3.0
|
def maxVolts = 3.0
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
def roundedPct = Math.round(pct * 100)
|
def roundedPct = Math.round(pct * 100)
|
||||||
|
if (roundedPct <= 0)
|
||||||
|
roundedPct = 1
|
||||||
result.value = Math.min(100, roundedPct)
|
result.value = Math.min(100, roundedPct)
|
||||||
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
||||||
}
|
}
|
||||||
@@ -274,7 +269,8 @@ private Map getTemperatureResult(value) {
|
|||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText,
|
descriptionText: descriptionText,
|
||||||
translatable: true
|
translatable: true,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,15 +289,7 @@ private Map getMotionResult(value) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -315,24 +303,19 @@ def refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
|
|
||||||
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
||||||
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
||||||
|
|
||||||
def configCmds = [
|
def enrollCmds = [
|
||||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 1 {${device.zigbeeId}} {}", "delay 200",
|
|
||||||
"zcl global send-me-a-report 1 0x20 0x20 30 21600 {01}", //checkin time 6 hrs
|
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
|
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 0x402 {${device.zigbeeId}} {}", "delay 200",
|
|
||||||
"zcl global send-me-a-report 0x402 0 0x29 300 3600 {6400}",
|
|
||||||
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500"
|
|
||||||
]
|
]
|
||||||
return configCmds + refresh() // send refresh cmds as part of config
|
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
// battery minReport 30 seconds, maxReportTime 6 hrs by default
|
||||||
|
return enrollCmds + zigbee.batteryConfig() + zigbee.temperatureConfig(30, 300) + refresh() // send refresh cmds as part of config
|
||||||
}
|
}
|
||||||
|
|
||||||
def enrollResponse() {
|
def enrollResponse() {
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ private Map parseCustomMessage(String description) {
|
|||||||
|
|
||||||
private Map parseIasMessage(String description) {
|
private Map parseIasMessage(String description) {
|
||||||
ZoneStatus zs = zigbee.parseZoneStatus(description)
|
ZoneStatus zs = zigbee.parseZoneStatus(description)
|
||||||
return zs.isAlarm1Set() ? getMotionResult('active') : getMotionResult('inactive')
|
return (zs.isAlarm1Set() || zs.isAlarm2Set()) ? getMotionResult('active') : getMotionResult('inactive')
|
||||||
}
|
}
|
||||||
|
|
||||||
def getTemperature(value) {
|
def getTemperature(value) {
|
||||||
@@ -206,6 +206,8 @@ private Map getBatteryResult(rawValue) {
|
|||||||
def maxVolts = 3.0
|
def maxVolts = 3.0
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
def roundedPct = Math.round(pct * 100)
|
def roundedPct = Math.round(pct * 100)
|
||||||
|
if (roundedPct <= 0)
|
||||||
|
roundedPct = 1
|
||||||
result.value = Math.min(100, roundedPct)
|
result.value = Math.min(100, roundedPct)
|
||||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||||
}
|
}
|
||||||
@@ -226,7 +228,8 @@ private Map getTemperatureResult(value) {
|
|||||||
return [
|
return [
|
||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText
|
descriptionText: descriptionText,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Smartsense Multi Sensor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartThings Multi Sensor](https://shop.smartthings.com/#!/products/smartsense-multi)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
* [Battery](#battery-specification)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Three Axis** - monitors the state of a single axis
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Sensor** - detects sensor events
|
||||||
|
* **Contact Sensor** - can detect contact (possible values: open,closed)
|
||||||
|
* **Acceleration Sensor** - allows for acceleration detection.
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Temperature Measurement** - defines device measures current temperature
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C2 multi sensor with maxReportTime of 1 hr.
|
||||||
|
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||||
|
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||||
|
Check-in interval = 2*60 = 120 min
|
||||||
|
|
||||||
|
## Battery Specification
|
||||||
|
|
||||||
|
One CR2450 (for Samsung SmartThings Multipurpose Sensor) battery / Two AAAA (for SmartSense Multi Sensor) batteries required.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the sensor doesn't pair when trying from the SmartThings mobile app, it is possible that the sensor is out of range.
|
||||||
|
Pairing needs to be tried again by placing the sensor closer to the hub.
|
||||||
|
Other troubleshooting tips are listed as follows:
|
||||||
|
* [Troubleshooting: Samsung SmartThings Multipurpose Sensor is stuck on "open" or "closed"](https://support.smartthings.com/hc/en-us/articles/200955940-Troubleshooting-Samsung-SmartThings-Multipurpose-Sensor-is-stuck-on-open-or-closed-)
|
||||||
|
* [Troubleshooting: Temperature reading for the Samsung SmartThings Multipurpose Sensor is off](https://support.smartthings.com/hc/en-us/articles/200756845-Troubleshooting-Temperature-reading-for-the-Samsung-SmartThings-Multipurpose-Sensor-is-off)
|
||||||
|
* [Troubleshooting: Samsung SmartThings Multipurpose Sensor won’t pair after removing pull-tab](https://support.smartthings.com/hc/en-us/articles/204966616-Troubleshooting-Samsung-SmartThings-device-won-t-pair-after-removing-pull-tab)
|
||||||
@@ -127,13 +127,6 @@ def parse(String description) {
|
|||||||
map = parseIasMessage(description)
|
map = parseIasMessage(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
|
|
||||||
def result = map ? createEvent(map) : null
|
def result = map ? createEvent(map) : null
|
||||||
|
|
||||||
if (description?.startsWith('enroll request')) {
|
if (description?.startsWith('enroll request')) {
|
||||||
@@ -313,6 +306,8 @@ private Map getBatteryResult(rawValue) {
|
|||||||
def maxVolts = 3.0
|
def maxVolts = 3.0
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
def roundedPct = Math.round(pct * 100)
|
def roundedPct = Math.round(pct * 100)
|
||||||
|
if (roundedPct <= 0)
|
||||||
|
roundedPct = 1
|
||||||
result.value = Math.min(100, roundedPct)
|
result.value = Math.min(100, roundedPct)
|
||||||
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
||||||
}
|
}
|
||||||
@@ -333,10 +328,11 @@ private Map getTemperatureResult(value) {
|
|||||||
'{{ device.displayName }} was {{ value }}°F'
|
'{{ device.displayName }} was {{ value }}°F'
|
||||||
|
|
||||||
return [
|
return [
|
||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText,
|
descriptionText: descriptionText,
|
||||||
translatable: true
|
translatable: true,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,15 +371,7 @@ private getAccelerationResult(numValue) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -413,13 +401,16 @@ def refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
|
|
||||||
log.debug "Configuring Reporting"
|
log.debug "Configuring Reporting"
|
||||||
|
|
||||||
|
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
// battery minReport 30 seconds, maxReportTime 6 hrs by default
|
||||||
def configCmds = enrollResponse() +
|
def configCmds = enrollResponse() +
|
||||||
zigbee.batteryConfig() +
|
zigbee.batteryConfig() +
|
||||||
zigbee.temperatureConfig() +
|
zigbee.temperatureConfig(30, 300) +
|
||||||
zigbee.configureReporting(0xFC02, 0x0010, 0x18, 10, 3600, 0x01, [mfgCode: manufacturerCode]) +
|
zigbee.configureReporting(0xFC02, 0x0010, 0x18, 10, 3600, 0x01, [mfgCode: manufacturerCode]) +
|
||||||
zigbee.configureReporting(0xFC02, 0x0012, 0x29, 1, 3600, 0x0001, [mfgCode: manufacturerCode]) +
|
zigbee.configureReporting(0xFC02, 0x0012, 0x29, 1, 3600, 0x0001, [mfgCode: manufacturerCode]) +
|
||||||
zigbee.configureReporting(0xFC02, 0x0013, 0x29, 1, 3600, 0x0001, [mfgCode: manufacturerCode]) +
|
zigbee.configureReporting(0xFC02, 0x0013, 0x29, 1, 3600, 0x0001, [mfgCode: manufacturerCode]) +
|
||||||
|
|||||||
@@ -206,6 +206,8 @@ def getTemperature(value) {
|
|||||||
def maxVolts = 3.0
|
def maxVolts = 3.0
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
def roundedPct = Math.round(pct * 100)
|
def roundedPct = Math.round(pct * 100)
|
||||||
|
if (roundedPct <= 0)
|
||||||
|
roundedPct = 1
|
||||||
result.value = Math.min(100, roundedPct)
|
result.value = Math.min(100, roundedPct)
|
||||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||||
}
|
}
|
||||||
@@ -223,9 +225,10 @@ def getTemperature(value) {
|
|||||||
}
|
}
|
||||||
def descriptionText = "${linkText} was ${value}°${temperatureScale}"
|
def descriptionText = "${linkText} was ${value}°${temperatureScale}"
|
||||||
return [
|
return [
|
||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText
|
descriptionText: descriptionText,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# Smartsense Open/Closed Sensor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartThings Open/Closed Sensor](https://shop.smartthings.com/#!/packs/smartsense-open-closed-sensor/)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
* [Battery](#battery-specification)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Contact Sensor** - can detect contact (possible values: open,closed)
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Temperature Measurement** - defines device measures current temperature
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
* **Sensor** - detects sensor events
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C2 open/closed sensor with maxReportTime of 1 hr.
|
||||||
|
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||||
|
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||||
|
Check-in interval = 2*60 = 120 min
|
||||||
|
|
||||||
|
## Battery Specification
|
||||||
|
|
||||||
|
One CR2 3V battery required.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the sensor doesn't pair when trying from the SmartThings mobile app, it is possible that the sensor is out of range.
|
||||||
|
Pairing needs to be tried again by placing the sensor closer to the hub.
|
||||||
|
Instructions related to pairing, resetting and removing the sensor from SmartThings can be found in the following link:
|
||||||
|
* [SmartSense Open/Closed Sensor Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/202836844-SmartSense-Open-Closed-Sensor)
|
||||||
@@ -92,13 +92,6 @@ def parse(String description) {
|
|||||||
map = parseIasMessage(description)
|
map = parseIasMessage(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
|
|
||||||
log.debug "Parse returned $map"
|
log.debug "Parse returned $map"
|
||||||
def result = map ? createEvent(map) : null
|
def result = map ? createEvent(map) : null
|
||||||
|
|
||||||
@@ -207,6 +200,8 @@ private Map getBatteryResult(rawValue) {
|
|||||||
def maxVolts = 3.0
|
def maxVolts = 3.0
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
def roundedPct = Math.round(pct * 100)
|
def roundedPct = Math.round(pct * 100)
|
||||||
|
if (roundedPct <= 0)
|
||||||
|
roundedPct = 1
|
||||||
result.value = Math.min(100, roundedPct)
|
result.value = Math.min(100, roundedPct)
|
||||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||||
}
|
}
|
||||||
@@ -226,7 +221,8 @@ private Map getTemperatureResult(value) {
|
|||||||
return [
|
return [
|
||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText
|
descriptionText: descriptionText,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -245,15 +241,7 @@ private Map getContactResult(value) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -267,23 +255,19 @@ def refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
|
|
||||||
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
||||||
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
||||||
def configCmds = [
|
def enrollCmds = [
|
||||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 1 {${device.zigbeeId}} {}", "delay 500",
|
|
||||||
"zcl global send-me-a-report 1 0x20 0x20 30 21600 {01}", //checkin time 6 hrs
|
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} ${endpointId} 1 0x402 {${device.zigbeeId}} {}", "delay 500",
|
|
||||||
"zcl global send-me-a-report 0x402 0 0x29 30 3600 {6400}",
|
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500"
|
|
||||||
]
|
]
|
||||||
return configCmds + refresh() // send refresh cmds as part of config
|
|
||||||
|
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
// battery minReport 30 seconds, maxReportTime 6 hrs by default
|
||||||
|
return enrollCmds + zigbee.batteryConfig() + zigbee.temperatureConfig(30, 300) + refresh() // send refresh cmds as part of config
|
||||||
}
|
}
|
||||||
|
|
||||||
def enrollResponse() {
|
def enrollResponse() {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
# SmartSense Temp/Humidity Sensor
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartSense Temp/Humidity Sensor](https://shop.smartthings.com/#!/products/smartsense-temp-humidity-sensor)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
* [Battery](#battery-specification)
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Relative Humidity Measurement** - defines device measures relative humidity
|
||||||
|
* **Refresh** - _refresh()_ command for status updates
|
||||||
|
* **Temperature Measurement** - defines device measures current temperature
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
* **Sensor** - detects sensor events
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
A Category C2 SmartSense Temp/Humidity Sensor with maxReportTime of 1 hr.
|
||||||
|
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||||
|
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||||
|
Check-in interval = 2*60 = 120 min
|
||||||
|
|
||||||
|
## Battery Specification
|
||||||
|
|
||||||
|
One CR2 battery is required.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the sensor doesn't pair when trying from the SmartThings mobile app, it is possible that the sensor is out of range.
|
||||||
|
Pairing needs to be tried by placing the sensor closer to the hub.
|
||||||
|
Instructions related to pairing, resetting and removing the sensor from SmartThings can be found in the following link:
|
||||||
|
* [Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/203040294)
|
||||||
@@ -83,13 +83,6 @@ def parse(String description) {
|
|||||||
map = parseCustomMessage(description)
|
map = parseCustomMessage(description)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
|
|
||||||
log.debug "Parse returned $map"
|
log.debug "Parse returned $map"
|
||||||
return map ? createEvent(map) : null
|
return map ? createEvent(map) : null
|
||||||
}
|
}
|
||||||
@@ -214,6 +207,8 @@ private Map getBatteryResult(rawValue) {
|
|||||||
def maxVolts = 3.0
|
def maxVolts = 3.0
|
||||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||||
def roundedPct = Math.round(pct * 100)
|
def roundedPct = Math.round(pct * 100)
|
||||||
|
if (roundedPct <= 0)
|
||||||
|
roundedPct = 1
|
||||||
result.value = Math.min(100, roundedPct)
|
result.value = Math.min(100, roundedPct)
|
||||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||||
}
|
}
|
||||||
@@ -233,7 +228,8 @@ private Map getTemperatureResult(value) {
|
|||||||
return [
|
return [
|
||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText
|
descriptionText: descriptionText,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,14 +246,7 @@ private Map getHumidityResult(value) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh()
|
def refresh()
|
||||||
@@ -275,23 +264,19 @@ def refresh()
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
|
|
||||||
log.debug "Configuring Reporting and Bindings."
|
log.debug "Configuring Reporting and Bindings."
|
||||||
def configCmds = [
|
def humidityConfigCmds = [
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 1 1 {${device.zigbeeId}} {}", "delay 500",
|
|
||||||
"zcl global send-me-a-report 1 0x20 0x20 30 21600 {01}", //checkin time 6 hrs
|
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 1 0x402 {${device.zigbeeId}} {}", "delay 500",
|
|
||||||
"zcl global send-me-a-report 0x402 0 0x29 30 3600 {6400}",
|
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500",
|
|
||||||
|
|
||||||
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 500",
|
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 500",
|
||||||
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}",
|
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}",
|
||||||
"send 0x${device.deviceNetworkId} 1 1", "delay 500"
|
"send 0x${device.deviceNetworkId} 1 1", "delay 500"
|
||||||
]
|
]
|
||||||
return configCmds + refresh() // send refresh cmds as part of config
|
|
||||||
|
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
// battery minReport 30 seconds, maxReportTime 6 hrs by default
|
||||||
|
return humidityConfigCmds + zigbee.batteryConfig() + zigbee.temperatureConfig(30, 300) + refresh() // send refresh cmds as part of config
|
||||||
}
|
}
|
||||||
|
|
||||||
private hex(value) {
|
private hex(value) {
|
||||||
|
|||||||
@@ -213,7 +213,8 @@ private Map getTemperatureResult(value) {
|
|||||||
return [
|
return [
|
||||||
name: 'temperature',
|
name: 'temperature',
|
||||||
value: value,
|
value: value,
|
||||||
descriptionText: descriptionText
|
descriptionText: descriptionText,
|
||||||
|
unit: temperatureScale
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -54,12 +54,6 @@ def parse(String description) {
|
|||||||
|
|
||||||
def event = zigbee.getEvent(description)
|
def event = zigbee.getEvent(description)
|
||||||
if (event) {
|
if (event) {
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
if (event.name=="level" && event.value==0) {}
|
if (event.name=="level" && event.value==0) {}
|
||||||
else {
|
else {
|
||||||
sendEvent(event)
|
sendEvent(event)
|
||||||
@@ -86,15 +80,7 @@ def setLevel(value) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.onOffRefresh()
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.onOffRefresh()
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -103,7 +89,8 @@ def refresh() {
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Reporting and Bindings."
|
log.debug "Configuring Reporting and Bindings."
|
||||||
// Enrolls device to Device-Watch with 3 x Reporting interval 30min
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
sendEvent(name: "checkInterval", value: 1800, displayed: false, data: [protocol: "zigbee"])
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,12 +85,6 @@ def parse(String description) {
|
|||||||
def event = zigbee.getEvent(description)
|
def event = zigbee.getEvent(description)
|
||||||
if (event) {
|
if (event) {
|
||||||
log.debug event
|
log.debug event
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
if (event.name=="level" && event.value==0) {}
|
if (event.name=="level" && event.value==0) {}
|
||||||
else {
|
else {
|
||||||
if (event.name=="colorTemperature") {
|
if (event.name=="colorTemperature") {
|
||||||
@@ -105,12 +99,12 @@ def parse(String description) {
|
|||||||
|
|
||||||
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
||||||
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
||||||
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 360)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "hue", value: hueValue, displayed:false)
|
sendEvent(name: "hue", value: hueValue, descriptionText: "Color has changed")
|
||||||
}
|
}
|
||||||
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
||||||
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -130,15 +124,7 @@ def off() {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.onOffRefresh()
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.onOffRefresh()
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -147,9 +133,10 @@ def refresh() {
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Reporting and Bindings."
|
log.debug "Configuring Reporting and Bindings."
|
||||||
// Enrolls device to Device-Watch with 3 x Reporting interval 30min
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
sendEvent(name: "checkInterval", value: 1800, displayed: false, data: [protocol: "zigbee"])
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, 0x20, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, 0x20, 1, 3600, 0x01) + zigbee.readAttribute(0x0006, 0x00) + zigbee.readAttribute(0x0008, 0x00) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, 0x00) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, 0x20, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, 0x20, 1, 3600, 0x01) + zigbee.readAttribute(0x0006, 0x00) + zigbee.readAttribute(0x0008, 0x00) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, 0x00) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ metadata {
|
|||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Recessed Kit RT 5/6 Tunable White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Recessed Kit RT 5/6 Tunable White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI tile definitions
|
// UI tile definitions
|
||||||
@@ -73,12 +74,6 @@ def parse(String description) {
|
|||||||
log.debug "description is $description"
|
log.debug "description is $description"
|
||||||
def event = zigbee.getEvent(description)
|
def event = zigbee.getEvent(description)
|
||||||
if (event) {
|
if (event) {
|
||||||
// Temporary fix for the case when Device is OFFLINE and is connected again
|
|
||||||
if (state.lastActivity == null){
|
|
||||||
state.lastActivity = now()
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
state.lastActivity = now()
|
|
||||||
if (event.name=="level" && event.value==0) {}
|
if (event.name=="level" && event.value==0) {}
|
||||||
else {
|
else {
|
||||||
if (event.name=="colorTemperature") {
|
if (event.name=="colorTemperature") {
|
||||||
@@ -109,15 +104,7 @@ def setLevel(value) {
|
|||||||
* PING is used by Device-Watch in attempt to reach the Device
|
* PING is used by Device-Watch in attempt to reach the Device
|
||||||
* */
|
* */
|
||||||
def ping() {
|
def ping() {
|
||||||
|
return zigbee.onOffRefresh()
|
||||||
if (state.lastActivity < (now() - (1000 * device.currentValue("checkInterval"))) ){
|
|
||||||
log.info "ping, alive=no, lastActivity=${state.lastActivity}"
|
|
||||||
state.lastActivity = null
|
|
||||||
return zigbee.onOffRefresh()
|
|
||||||
} else {
|
|
||||||
log.info "ping, alive=yes, lastActivity=${state.lastActivity}"
|
|
||||||
sendEvent(name: "deviceWatch-lastActivity", value: state.lastActivity, description: "Last Activity is on ${new Date((long)state.lastActivity)}", displayed: false, isStateChange: true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
@@ -126,9 +113,10 @@ def refresh() {
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "Configuring Reporting and Bindings."
|
log.debug "Configuring Reporting and Bindings."
|
||||||
// Enrolls device to Device-Watch with 3 x Reporting interval 30min
|
// Device-Watch allows 3 check-in misses from device. 300 seconds x 3 = 15min
|
||||||
sendEvent(name: "checkInterval", value: 1800, displayed: false, data: [protocol: "zigbee"])
|
sendEvent(name: "checkInterval", value: 900, displayed: false, data: [protocol: "zigbee"])
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ def initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def sendit(evt) {
|
def sendit(evt) {
|
||||||
log.debug "$evt.value: $evt, $settings"
|
log.debug "$evt.value: $evt"
|
||||||
sendMessage()
|
sendMessage()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +80,6 @@ def sendMessage() {
|
|||||||
sendSms phone3, msg
|
sendSms phone3, msg
|
||||||
}
|
}
|
||||||
if (!phone1 && !phone2 && !phone3) {
|
if (!phone1 && !phone2 && !phone3) {
|
||||||
sendPush msg
|
sendPush msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ definition(
|
|||||||
name: "Monitor on Sense",
|
name: "Monitor on Sense",
|
||||||
namespace: "resteele",
|
namespace: "resteele",
|
||||||
author: "Rachel Steele",
|
author: "Rachel Steele",
|
||||||
description: "Turn on Monitor when vibration is sensed",
|
description: "Turn on switch when vibration is sensed",
|
||||||
category: "My Apps",
|
category: "My Apps",
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
||||||
@@ -25,10 +25,10 @@ definition(
|
|||||||
|
|
||||||
|
|
||||||
preferences {
|
preferences {
|
||||||
section("When the keyboard is used...") {
|
section("When vibration is sensed...") {
|
||||||
input "accelerationSensor", "capability.accelerationSensor", title: "Which Sensor?"
|
input "accelerationSensor", "capability.accelerationSensor", title: "Which Sensor?"
|
||||||
}
|
}
|
||||||
section("Turn on/off a light...") {
|
section("Turn on switch...") {
|
||||||
input "switch1", "capability.switch"
|
input "switch1", "capability.switch"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,5 +47,3 @@ def updated() {
|
|||||||
def accelerationActiveHandler(evt) {
|
def accelerationActiveHandler(evt) {
|
||||||
switch1.on()
|
switch1.on()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ def authPage() {
|
|||||||
// get rid of next button until the user is actually auth'd
|
// get rid of next button until the user is actually auth'd
|
||||||
if (!oauthTokenProvided) {
|
if (!oauthTokenProvided) {
|
||||||
return dynamicPage(name: "auth", title: "Login", nextPage: "", uninstall:uninstallAllowed) {
|
return dynamicPage(name: "auth", title: "Login", nextPage: "", uninstall:uninstallAllowed) {
|
||||||
section(){
|
section() {
|
||||||
paragraph "Tap below to log in to the ecobee service and authorize SmartThings access. Be sure to scroll down on page 2 and press the 'Allow' button."
|
paragraph "Tap below to log in to the ecobee service and authorize SmartThings access. Be sure to scroll down on page 2 and press the 'Allow' button."
|
||||||
href url:redirectUrl, style:"embedded", required:true, title:"ecobee", description:description
|
href url:redirectUrl, style:"embedded", required:true, title:"ecobee", description:description
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ def authPage() {
|
|||||||
log.debug "thermostat list: $stats"
|
log.debug "thermostat list: $stats"
|
||||||
log.debug "sensor list: ${sensorsDiscovered()}"
|
log.debug "sensor list: ${sensorsDiscovered()}"
|
||||||
return dynamicPage(name: "auth", title: "Select Your Thermostats", uninstall: true) {
|
return dynamicPage(name: "auth", title: "Select Your Thermostats", uninstall: true) {
|
||||||
section(""){
|
section("") {
|
||||||
paragraph "Tap below to see the list of ecobee thermostats available in your ecobee account and select the ones you want to connect to SmartThings."
|
paragraph "Tap below to see the list of ecobee thermostats available in your ecobee account and select the ones you want to connect to SmartThings."
|
||||||
input(name: "thermostats", title:"", type: "enum", required:true, multiple:true, description: "Tap to choose", metadata:[values:stats])
|
input(name: "thermostats", title:"", type: "enum", required:true, multiple:true, description: "Tap to choose", metadata:[values:stats])
|
||||||
}
|
}
|
||||||
@@ -84,7 +84,7 @@ def authPage() {
|
|||||||
def options = sensorsDiscovered() ?: []
|
def options = sensorsDiscovered() ?: []
|
||||||
def numFound = options.size() ?: 0
|
def numFound = options.size() ?: 0
|
||||||
if (numFound > 0) {
|
if (numFound > 0) {
|
||||||
section(""){
|
section("") {
|
||||||
paragraph "Tap below to see the list of ecobee sensors available in your ecobee account and select the ones you want to connect to SmartThings."
|
paragraph "Tap below to see the list of ecobee sensors available in your ecobee account and select the ones you want to connect to SmartThings."
|
||||||
input(name: "ecobeesensors", title:"Select Ecobee Sensors (${numFound} found)", type: "enum", required:false, description: "Tap to choose", multiple:true, options:options)
|
input(name: "ecobeesensors", title:"Select Ecobee Sensors (${numFound} found)", type: "enum", required:false, description: "Tap to choose", multiple:true, options:options)
|
||||||
}
|
}
|
||||||
@@ -115,13 +115,12 @@ def callback() {
|
|||||||
def code = params.code
|
def code = params.code
|
||||||
def oauthState = params.state
|
def oauthState = params.state
|
||||||
|
|
||||||
if (oauthState == atomicState.oauthInitState){
|
if (oauthState == atomicState.oauthInitState) {
|
||||||
|
|
||||||
def tokenParams = [
|
def tokenParams = [
|
||||||
grant_type: "authorization_code",
|
grant_type: "authorization_code",
|
||||||
code : code,
|
code : code,
|
||||||
client_id : smartThingsClientId,
|
client_id : smartThingsClientId,
|
||||||
redirect_uri: callbackUrl
|
redirect_uri: callbackUrl
|
||||||
]
|
]
|
||||||
|
|
||||||
def tokenUrl = "https://www.ecobee.com/home/token?${toQueryString(tokenParams)}"
|
def tokenUrl = "https://www.ecobee.com/home/token?${toQueryString(tokenParams)}"
|
||||||
@@ -129,9 +128,6 @@ def callback() {
|
|||||||
httpPost(uri: tokenUrl) { resp ->
|
httpPost(uri: tokenUrl) { resp ->
|
||||||
atomicState.refreshToken = resp.data.refresh_token
|
atomicState.refreshToken = resp.data.refresh_token
|
||||||
atomicState.authToken = resp.data.access_token
|
atomicState.authToken = resp.data.access_token
|
||||||
log.debug "swapped token: $resp.data"
|
|
||||||
log.debug "atomicState.refreshToken: ${atomicState.refreshToken}"
|
|
||||||
log.debug "atomicState.authToken: ${atomicState.authToken}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atomicState.authToken) {
|
if (atomicState.authToken) {
|
||||||
@@ -148,8 +144,8 @@ def callback() {
|
|||||||
|
|
||||||
def success() {
|
def success() {
|
||||||
def message = """
|
def message = """
|
||||||
<p>Your ecobee Account is now connected to SmartThings!</p>
|
<p>Your ecobee Account is now connected to SmartThings!</p>
|
||||||
<p>Click 'Done' to finish setup.</p>
|
<p>Click 'Done' to finish setup.</p>
|
||||||
"""
|
"""
|
||||||
connectionStatus(message)
|
connectionStatus(message)
|
||||||
}
|
}
|
||||||
@@ -171,64 +167,63 @@ def connectionStatus(message, redirectUrl = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def html = """
|
def html = """
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta name="viewport" content="width=640">
|
<meta name="viewport" content="width=640">
|
||||||
<title>Ecobee & SmartThings connection</title>
|
<title>Ecobee & SmartThings connection</title>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Swiss 721 W01 Thin';
|
font-family: 'Swiss 721 W01 Thin';
|
||||||
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.eot');
|
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.eot');
|
||||||
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.eot?#iefix') format('embedded-opentype'),
|
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.eot?#iefix') format('embedded-opentype'),
|
||||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.woff') format('woff'),
|
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.woff') format('woff'),
|
||||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.ttf') format('truetype'),
|
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.ttf') format('truetype'),
|
||||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.svg#swis721_th_btthin') format('svg');
|
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.svg#swis721_th_btthin') format('svg');
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'Swiss 721 W01 Light';
|
font-family: 'Swiss 721 W01 Light';
|
||||||
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.eot');
|
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.eot');
|
||||||
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.eot?#iefix') format('embedded-opentype'),
|
src: url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.eot?#iefix') format('embedded-opentype'),
|
||||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.woff') format('woff'),
|
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.woff') format('woff'),
|
||||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.ttf') format('truetype'),
|
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.ttf') format('truetype'),
|
||||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.svg#swis721_lt_btlight') format('svg');
|
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.svg#swis721_lt_btlight') format('svg');
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
}
|
}
|
||||||
.container {
|
.container {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
padding: 4%;
|
padding: 4%;
|
||||||
/*background: #eee;*/
|
text-align: center;
|
||||||
text-align: center;
|
}
|
||||||
}
|
img {
|
||||||
img {
|
vertical-align: middle;
|
||||||
vertical-align: middle;
|
}
|
||||||
}
|
p {
|
||||||
p {
|
font-size: 2.2em;
|
||||||
font-size: 2.2em;
|
font-family: 'Swiss 721 W01 Thin';
|
||||||
font-family: 'Swiss 721 W01 Thin';
|
text-align: center;
|
||||||
text-align: center;
|
color: #666666;
|
||||||
color: #666666;
|
padding: 0 40px;
|
||||||
padding: 0 40px;
|
margin-bottom: 0;
|
||||||
margin-bottom: 0;
|
}
|
||||||
}
|
span {
|
||||||
span {
|
font-family: 'Swiss 721 W01 Light';
|
||||||
font-family: 'Swiss 721 W01 Light';
|
}
|
||||||
}
|
</style>
|
||||||
</style>
|
</head>
|
||||||
</head>
|
<body>
|
||||||
<body>
|
<div class="container">
|
||||||
<div class="container">
|
|
||||||
<img src="https://s3.amazonaws.com/smartapp-icons/Partner/ecobee%402x.png" alt="ecobee icon" />
|
<img src="https://s3.amazonaws.com/smartapp-icons/Partner/ecobee%402x.png" alt="ecobee icon" />
|
||||||
<img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/connected-device-icn%402x.png" alt="connected device icon" />
|
<img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/connected-device-icn%402x.png" alt="connected device icon" />
|
||||||
<img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/st-logo%402x.png" alt="SmartThings logo" />
|
<img src="https://s3.amazonaws.com/smartapp-icons/Partner/support/st-logo%402x.png" alt="SmartThings logo" />
|
||||||
${message}
|
${message}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
render contentType: 'text/html', data: html
|
render contentType: 'text/html', data: html
|
||||||
}
|
}
|
||||||
@@ -237,19 +232,26 @@ def getEcobeeThermostats() {
|
|||||||
log.debug "getting device list"
|
log.debug "getting device list"
|
||||||
atomicState.remoteSensors = []
|
atomicState.remoteSensors = []
|
||||||
|
|
||||||
def requestBody = '{"selection":{"selectionType":"registered","selectionMatch":"","includeRuntime":true,"includeSensors":true}}'
|
def bodyParams = [
|
||||||
|
selection: [
|
||||||
|
selectionType: "registered",
|
||||||
|
selectionMatch: "",
|
||||||
|
includeRuntime: true,
|
||||||
|
includeSensors: true
|
||||||
|
]
|
||||||
|
]
|
||||||
def deviceListParams = [
|
def deviceListParams = [
|
||||||
uri: apiEndpoint,
|
uri: apiEndpoint,
|
||||||
path: "/1/thermostat",
|
path: "/1/thermostat",
|
||||||
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||||
query: [format: 'json', body: requestBody]
|
// TODO - the query string below is not consistent with the Ecobee docs:
|
||||||
|
// https://www.ecobee.com/home/developer/api/documentation/v1/operations/get-thermostats.shtml
|
||||||
|
query: [format: 'json', body: toJson(bodyParams)]
|
||||||
]
|
]
|
||||||
|
|
||||||
def stats = [:]
|
def stats = [:]
|
||||||
try {
|
try {
|
||||||
httpGet(deviceListParams) { resp ->
|
httpGet(deviceListParams) { resp ->
|
||||||
|
|
||||||
if (resp.status == 200) {
|
if (resp.status == 200) {
|
||||||
resp.data.thermostatList.each { stat ->
|
resp.data.thermostatList.each { stat ->
|
||||||
atomicState.remoteSensors = atomicState.remoteSensors == null ? stat.remoteSensors : atomicState.remoteSensors << stat.remoteSensors
|
atomicState.remoteSensors = atomicState.remoteSensors == null ? stat.remoteSensors : atomicState.remoteSensors << stat.remoteSensors
|
||||||
@@ -289,9 +291,10 @@ Map sensorsDiscovered() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def getThermostatDisplayName(stat) {
|
def getThermostatDisplayName(stat) {
|
||||||
if(stat?.name)
|
if(stat?.name) {
|
||||||
return stat.name.toString()
|
return stat.name.toString()
|
||||||
return (getThermostatTypeName(stat) + " (${stat.identifier})").toString()
|
}
|
||||||
|
return (getThermostatTypeName(stat) + " (${stat.identifier})").toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
def getThermostatTypeName(stat) {
|
def getThermostatTypeName(stat) {
|
||||||
@@ -310,7 +313,6 @@ def updated() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def initialize() {
|
def initialize() {
|
||||||
|
|
||||||
log.debug "initialize"
|
log.debug "initialize"
|
||||||
def devices = thermostats.collect { dni ->
|
def devices = thermostats.collect { dni ->
|
||||||
def d = getChildDevice(dni)
|
def d = getChildDevice(dni)
|
||||||
@@ -350,8 +352,6 @@ def initialize() {
|
|||||||
log.warn "delete: ${delete}, deleting ${delete.size()} thermostats"
|
log.warn "delete: ${delete}, deleting ${delete.size()} thermostats"
|
||||||
delete.each { deleteChildDevice(it.deviceNetworkId) } //inherits from SmartApp (data-management)
|
delete.each { deleteChildDevice(it.deviceNetworkId) } //inherits from SmartApp (data-management)
|
||||||
|
|
||||||
atomicState.thermostatData = [:] //reset Map to store thermostat data
|
|
||||||
|
|
||||||
//send activity feeds to tell that device is connected
|
//send activity feeds to tell that device is connected
|
||||||
def notificationMessage = "is connected to SmartThings"
|
def notificationMessage = "is connected to SmartThings"
|
||||||
sendActivityFeeds(notificationMessage)
|
sendActivityFeeds(notificationMessage)
|
||||||
@@ -381,75 +381,41 @@ def pollHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def pollChildren(child = null) {
|
def pollChildren(child = null) {
|
||||||
def thermostatIdsString = getChildDeviceIdsString()
|
def thermostatIdsString = getChildDeviceIdsString()
|
||||||
log.debug "polling children: $thermostatIdsString"
|
log.debug "polling children: $thermostatIdsString"
|
||||||
def data = ""
|
|
||||||
|
def requestBody = [
|
||||||
|
selection: [
|
||||||
|
selectionType: "thermostats",
|
||||||
|
selectionMatch: thermostatIdsString,
|
||||||
|
includeExtendedRuntime: true,
|
||||||
|
includeSettings: true,
|
||||||
|
includeRuntime: true,
|
||||||
|
includeSensors: true
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + thermostatIdsString + '","includeExtendedRuntime":"true","includeSettings":"true","includeRuntime":"true","includeSensors":true}}'
|
|
||||||
def result = false
|
def result = false
|
||||||
|
|
||||||
def pollParams = [
|
def pollParams = [
|
||||||
uri: apiEndpoint,
|
uri: apiEndpoint,
|
||||||
path: "/1/thermostat",
|
path: "/1/thermostat",
|
||||||
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||||
query: [format: 'json', body: jsonRequestBody]
|
// TODO - the query string below is not consistent with the Ecobee docs:
|
||||||
]
|
// https://www.ecobee.com/home/developer/api/documentation/v1/operations/get-thermostats.shtml
|
||||||
|
query: [format: 'json', body: toJson(requestBody)]
|
||||||
|
]
|
||||||
|
|
||||||
try{
|
try{
|
||||||
httpGet(pollParams) { resp ->
|
httpGet(pollParams) { resp ->
|
||||||
if(resp.status == 200) {
|
if(resp.status == 200) {
|
||||||
log.debug "poll results returned resp.data ${resp.data}"
|
log.debug "poll results returned resp.data ${resp.data}"
|
||||||
atomicState.remoteSensors = resp.data.thermostatList.remoteSensors
|
atomicState.remoteSensors = resp.data.thermostatList.remoteSensors
|
||||||
atomicState.thermostatData = resp.data
|
updateSensorData()
|
||||||
updateSensorData()
|
storeThermostatData(resp.data.thermostatList)
|
||||||
atomicState.thermostats = resp.data.thermostatList.inject([:]) { collector, stat ->
|
result = true
|
||||||
def dni = [ app.id, stat.identifier ].join('.')
|
log.debug "updated ${atomicState.thermostats?.size()} stats: ${atomicState.thermostats}"
|
||||||
|
}
|
||||||
log.debug "updating dni $dni"
|
|
||||||
|
|
||||||
data = [
|
|
||||||
coolMode: (stat.settings.coolStages > 0),
|
|
||||||
heatMode: (stat.settings.heatStages > 0),
|
|
||||||
deviceTemperatureUnit: stat.settings.useCelsius,
|
|
||||||
minHeatingSetpoint: (stat.settings.heatRangeLow / 10),
|
|
||||||
maxHeatingSetpoint: (stat.settings.heatRangeHigh / 10),
|
|
||||||
minCoolingSetpoint: (stat.settings.coolRangeLow / 10),
|
|
||||||
maxCoolingSetpoint: (stat.settings.coolRangeHigh / 10),
|
|
||||||
autoMode: stat.settings.autoHeatCoolFeatureEnabled,
|
|
||||||
auxHeatMode: (stat.settings.hasHeatPump) && (stat.settings.hasForcedAir || stat.settings.hasElectric || stat.settings.hasBoiler),
|
|
||||||
temperature: (stat.runtime.actualTemperature / 10),
|
|
||||||
heatingSetpoint: stat.runtime.desiredHeat / 10,
|
|
||||||
coolingSetpoint: stat.runtime.desiredCool / 10,
|
|
||||||
thermostatMode: stat.settings.hvacMode,
|
|
||||||
humidity: stat.runtime.actualHumidity,
|
|
||||||
thermostatFanMode: stat.runtime.desiredFanMode
|
|
||||||
]
|
|
||||||
|
|
||||||
if (location.temperatureScale == "F")
|
|
||||||
{
|
|
||||||
data["temperature"] = data["temperature"] ? Math.round(data["temperature"].toDouble()) : data["temperature"]
|
|
||||||
data["heatingSetpoint"] = data["heatingSetpoint"] ? Math.round(data["heatingSetpoint"].toDouble()) : data["heatingSetpoint"]
|
|
||||||
data["coolingSetpoint"] = data["coolingSetpoint"] ? Math.round(data["coolingSetpoint"].toDouble()) : data["coolingSetpoint"]
|
|
||||||
data["minHeatingSetpoint"] = data["minHeatingSetpoint"] ? Math.round(data["minHeatingSetpoint"].toDouble()) : data["minHeatingSetpoint"]
|
|
||||||
data["maxHeatingSetpoint"] = data["maxHeatingSetpoint"] ? Math.round(data["maxHeatingSetpoint"].toDouble()) : data["maxHeatingSetpoint"]
|
|
||||||
data["minCoolingSetpoint"] = data["minCoolingSetpoint"] ? Math.round(data["minCoolingSetpoint"].toDouble()) : data["minCoolingSetpoint"]
|
|
||||||
data["maxCoolingSetpoint"] = data["maxCoolingSetpoint"] ? Math.round(data["maxCoolingSetpoint"].toDouble()) : data["maxCoolingSetpoint"]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data?.deviceTemperatureUnit == false && location.temperatureScale == "F") {
|
|
||||||
data["deviceTemperatureUnit"] = "F"
|
|
||||||
|
|
||||||
} else {
|
|
||||||
data["deviceTemperatureUnit"] = "C"
|
|
||||||
}
|
|
||||||
|
|
||||||
collector[dni] = [data:data]
|
|
||||||
return collector
|
|
||||||
}
|
|
||||||
result = true
|
|
||||||
log.debug "updated ${atomicState.thermostats?.size()} stats: ${atomicState.thermostats}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (groovyx.net.http.HttpResponseException e) {
|
} catch (groovyx.net.http.HttpResponseException e) {
|
||||||
log.trace "Exception polling children: " + e.response.data.status
|
log.trace "Exception polling children: " + e.response.data.status
|
||||||
@@ -463,13 +429,12 @@ def pollChildren(child = null) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Poll Child is invoked from the Child Device itself as part of the Poll Capability
|
// Poll Child is invoked from the Child Device itself as part of the Poll Capability
|
||||||
def pollChild(){
|
def pollChild() {
|
||||||
|
|
||||||
def devices = getChildDevices()
|
def devices = getChildDevices()
|
||||||
|
|
||||||
if (pollChildren()){
|
if (pollChildren()) {
|
||||||
devices.each { child ->
|
devices.each { child ->
|
||||||
if (!child.device.deviceNetworkId.startsWith("ecobee_sensor")){
|
if (!child.device.deviceNetworkId.startsWith("ecobee_sensor")) {
|
||||||
if(atomicState.thermostats[child.device.deviceNetworkId] != null) {
|
if(atomicState.thermostats[child.device.deviceNetworkId] != null) {
|
||||||
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
||||||
log.info "pollChild(child)>> data for ${child.device.deviceNetworkId} : ${tData.data}"
|
log.info "pollChild(child)>> data for ${child.device.deviceNetworkId} : ${tData.data}"
|
||||||
@@ -492,36 +457,7 @@ void poll() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def availableModes(child) {
|
def availableModes(child) {
|
||||||
|
|
||||||
debugEvent ("atomicState.thermostats = ${atomicState.thermostats}")
|
debugEvent ("atomicState.thermostats = ${atomicState.thermostats}")
|
||||||
|
|
||||||
debugEvent ("Child DNI = ${child.device.deviceNetworkId}")
|
|
||||||
|
|
||||||
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
|
||||||
|
|
||||||
debugEvent("Data = ${tData}")
|
|
||||||
|
|
||||||
if(!tData)
|
|
||||||
{
|
|
||||||
log.error "ERROR: Device connection removed? no data for ${child.device.deviceNetworkId} after polling"
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
def modes = ["off"]
|
|
||||||
|
|
||||||
if (tData.data.heatMode) modes.add("heat")
|
|
||||||
if (tData.data.coolMode) modes.add("cool")
|
|
||||||
if (tData.data.autoMode) modes.add("auto")
|
|
||||||
if (tData.data.auxHeatMode) modes.add("auxHeatOnly")
|
|
||||||
|
|
||||||
modes
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
def currentMode(child) {
|
|
||||||
debugEvent ("atomicState.Thermos = ${atomicState.thermostats}")
|
|
||||||
|
|
||||||
debugEvent ("Child DNI = ${child.device.deviceNetworkId}")
|
debugEvent ("Child DNI = ${child.device.deviceNetworkId}")
|
||||||
|
|
||||||
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
||||||
@@ -530,14 +466,42 @@ def currentMode(child) {
|
|||||||
|
|
||||||
if(!tData) {
|
if(!tData) {
|
||||||
log.error "ERROR: Device connection removed? no data for ${child.device.deviceNetworkId} after polling"
|
log.error "ERROR: Device connection removed? no data for ${child.device.deviceNetworkId} after polling"
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
def modes = ["off"]
|
||||||
|
|
||||||
|
if (tData.data.heatMode) {
|
||||||
|
modes.add("heat")
|
||||||
|
}
|
||||||
|
if (tData.data.coolMode) {
|
||||||
|
modes.add("cool")
|
||||||
|
}
|
||||||
|
if (tData.data.autoMode) {
|
||||||
|
modes.add("auto")
|
||||||
|
}
|
||||||
|
if (tData.data.auxHeatMode) {
|
||||||
|
modes.add("auxHeatOnly")
|
||||||
|
}
|
||||||
|
|
||||||
|
return modes
|
||||||
|
}
|
||||||
|
|
||||||
|
def currentMode(child) {
|
||||||
|
debugEvent ("atomicState.Thermos = ${atomicState.thermostats}")
|
||||||
|
debugEvent ("Child DNI = ${child.device.deviceNetworkId}")
|
||||||
|
|
||||||
|
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
||||||
|
|
||||||
|
debugEvent("Data = ${tData}")
|
||||||
|
|
||||||
|
if(!tData) {
|
||||||
|
log.error "ERROR: Device connection removed? no data for ${child.device.deviceNetworkId} after polling"
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
def mode = tData.data.thermostatMode
|
def mode = tData.data.thermostatMode
|
||||||
|
return mode
|
||||||
mode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateSensorData() {
|
def updateSensorData() {
|
||||||
@@ -558,12 +522,12 @@ def updateSensorData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (it.type == "occupancy") {
|
} else if (it.type == "occupancy") {
|
||||||
if(it.value == "true")
|
if(it.value == "true") {
|
||||||
occupancy = "active"
|
occupancy = "active"
|
||||||
else
|
} else {
|
||||||
occupancy = "inactive"
|
occupancy = "inactive"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def dni = "ecobee_sensor-"+ it?.id + "-" + it?.code
|
def dni = "ecobee_sensor-"+ it?.id + "-" + it?.code
|
||||||
@@ -582,7 +546,7 @@ def getChildDeviceIdsString() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def toJson(Map m) {
|
def toJson(Map m) {
|
||||||
return new org.json.JSONObject(m).toString()
|
return groovy.json.JsonOutput.toJson(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
def toQueryString(Map m) {
|
def toQueryString(Map m) {
|
||||||
@@ -595,54 +559,24 @@ private refreshAuthToken() {
|
|||||||
if(!atomicState.refreshToken) {
|
if(!atomicState.refreshToken) {
|
||||||
log.warn "Can not refresh OAuth token since there is no refreshToken stored"
|
log.warn "Can not refresh OAuth token since there is no refreshToken stored"
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
def refreshParams = [
|
def refreshParams = [
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
uri : apiEndpoint,
|
uri : apiEndpoint,
|
||||||
path : "/token",
|
path : "/token",
|
||||||
query : [grant_type: 'refresh_token', code: "${atomicState.refreshToken}", client_id: smartThingsClientId],
|
query : [grant_type: 'refresh_token', code: "${atomicState.refreshToken}", client_id: smartThingsClientId],
|
||||||
]
|
]
|
||||||
|
|
||||||
log.debug refreshParams
|
|
||||||
|
|
||||||
def notificationMessage = "is disconnected from SmartThings, because the access credential changed or was lost. Please go to the Ecobee (Connect) SmartApp and re-enter your account login credentials."
|
def notificationMessage = "is disconnected from SmartThings, because the access credential changed or was lost. Please go to the Ecobee (Connect) SmartApp and re-enter your account login credentials."
|
||||||
//changed to httpPost
|
//changed to httpPost
|
||||||
try {
|
try {
|
||||||
def jsonMap
|
def jsonMap
|
||||||
httpPost(refreshParams) { resp ->
|
httpPost(refreshParams) { resp ->
|
||||||
|
|
||||||
if(resp.status == 200) {
|
if(resp.status == 200) {
|
||||||
log.debug "Token refreshed...calling saved RestAction now!"
|
log.debug "Token refreshed...calling saved RestAction now!"
|
||||||
|
|
||||||
debugEvent("Token refreshed ... calling saved RestAction now!")
|
debugEvent("Token refreshed ... calling saved RestAction now!")
|
||||||
|
saveTokenAndResumeAction(resp.data)
|
||||||
log.debug resp
|
}
|
||||||
|
}
|
||||||
jsonMap = resp.data
|
|
||||||
|
|
||||||
if(resp.data) {
|
|
||||||
|
|
||||||
log.debug resp.data
|
|
||||||
debugEvent("Response = ${resp.data}")
|
|
||||||
|
|
||||||
atomicState.refreshToken = resp?.data?.refresh_token
|
|
||||||
atomicState.authToken = resp?.data?.access_token
|
|
||||||
|
|
||||||
debugEvent("Refresh Token = ${atomicState.refreshToken}")
|
|
||||||
debugEvent("OAUTH Token = ${atomicState.authToken}")
|
|
||||||
|
|
||||||
if(atomicState.action && atomicState.action != "") {
|
|
||||||
log.debug "Executing next action: ${atomicState.action}"
|
|
||||||
|
|
||||||
"${atomicState.action}"()
|
|
||||||
|
|
||||||
atomicState.action = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
atomicState.action = ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (groovyx.net.http.HttpResponseException e) {
|
} catch (groovyx.net.http.HttpResponseException e) {
|
||||||
log.error "refreshAuthToken() >> Error: e.statusCode ${e.statusCode}"
|
log.error "refreshAuthToken() >> Error: e.statusCode ${e.statusCode}"
|
||||||
def reAttemptPeriod = 300 // in sec
|
def reAttemptPeriod = 300 // in sec
|
||||||
@@ -662,118 +596,220 @@ private refreshAuthToken() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def resumeProgram(child, deviceId) {
|
/**
|
||||||
|
* Saves the refresh and auth token from the passed-in JSON object,
|
||||||
|
* and invokes any previously executing action that did not complete due to
|
||||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"functions": [{"type": "resumeProgram"}]}'
|
* an expired token.
|
||||||
def result = sendJson(jsonRequestBody)
|
*
|
||||||
return result
|
* @param json - an object representing the parsed JSON response from Ecobee
|
||||||
|
*/
|
||||||
|
private void saveTokenAndResumeAction(json) {
|
||||||
|
log.debug "token response json: $json"
|
||||||
|
if (json) {
|
||||||
|
debugEvent("Response = $json")
|
||||||
|
atomicState.refreshToken = json?.refresh_token
|
||||||
|
atomicState.authToken = json?.access_token
|
||||||
|
if (atomicState.action) {
|
||||||
|
log.debug "got refresh token, executing next action: ${atomicState.action}"
|
||||||
|
"${atomicState.action}"()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.warn "did not get response body from refresh token response"
|
||||||
|
}
|
||||||
|
atomicState.action = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
def setHold(child, heating, cooling, deviceId, sendHoldType) {
|
/**
|
||||||
|
* Executes the resume program command on the Ecobee thermostat
|
||||||
int h = heating * 10
|
* @param deviceId - the ID of the device
|
||||||
int c = cooling * 10
|
*
|
||||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"functions": [{ "type": "setHold", "params": { "coolHoldTemp": '+c+',"heatHoldTemp": '+h+', "holdType": '+sendHoldType+' } } ]}'
|
* @retrun true if the command was successful, false otherwise.
|
||||||
|
*/
|
||||||
def result = sendJson(child, jsonRequestBody)
|
boolean resumeProgram(deviceId) {
|
||||||
return result
|
def payload = [
|
||||||
|
selection: [
|
||||||
|
selectionType: "thermostats",
|
||||||
|
selectionMatch: deviceId,
|
||||||
|
includeRuntime: true
|
||||||
|
],
|
||||||
|
functions: [
|
||||||
|
[
|
||||||
|
type: "resumeProgram"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
return sendCommandToEcobee(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setFanMode(child, heating, cooling, deviceId, sendHoldType, fanMode) {
|
/**
|
||||||
|
* Executes the set hold command on the Ecobee thermostat
|
||||||
|
* @param heating - The heating temperature to set in fahrenheit
|
||||||
|
* @param cooling - the cooling temperature to set in fahrenheit
|
||||||
|
* @param deviceId - the ID of the device
|
||||||
|
* @param sendHoldType - the hold type to execute
|
||||||
|
*
|
||||||
|
* @return true if the command was successful, false otherwise
|
||||||
|
*/
|
||||||
|
boolean setHold(heating, cooling, deviceId, sendHoldType) {
|
||||||
|
// Ecobee requires that temp values be in fahrenheit multiplied by 10.
|
||||||
|
int h = heating * 10
|
||||||
|
int c = cooling * 10
|
||||||
|
|
||||||
int h = heating * 10
|
def payload = [
|
||||||
int c = cooling * 10
|
selection: [
|
||||||
|
selectionType: "thermostats",
|
||||||
|
selectionMatch: deviceId,
|
||||||
|
includeRuntime: true
|
||||||
|
],
|
||||||
|
functions: [
|
||||||
|
[
|
||||||
|
type: "setHold",
|
||||||
|
params: [
|
||||||
|
coolHoldTemp: c,
|
||||||
|
heatHoldTemp: h,
|
||||||
|
holdType: sendHoldType
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
return sendCommandToEcobee(payload)
|
||||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"functions": [{ "type": "setHold", "params": { "coolHoldTemp": '+c+',"heatHoldTemp": '+h+', "holdType": '+sendHoldType+', "fan": '+fanMode+' } } ]}'
|
|
||||||
def result = sendJson(child, jsonRequestBody)
|
|
||||||
return result
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setMode(child, mode, deviceId) {
|
/**
|
||||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"thermostat": {"settings":{"hvacMode":"'+"${mode}"+'"}}}'
|
* Executes the set fan mode command on the Ecobee thermostat
|
||||||
|
* @param heating - The heating temperature to set in fahrenheit
|
||||||
|
* @param cooling - the cooling temperature to set in fahrenheit
|
||||||
|
* @param deviceId - the ID of the device
|
||||||
|
* @param sendHoldType - the hold type to execute
|
||||||
|
* @param fanMode - the fan mode to set to
|
||||||
|
*
|
||||||
|
* @return true if the command was successful, false otherwise
|
||||||
|
*/
|
||||||
|
boolean setFanMode(heating, cooling, deviceId, sendHoldType, fanMode) {
|
||||||
|
// Ecobee requires that temp values be in fahrenheit multiplied by 10.
|
||||||
|
int h = heating * 10
|
||||||
|
int c = cooling * 10
|
||||||
|
|
||||||
def result = sendJson(jsonRequestBody)
|
def payload = [
|
||||||
return result
|
selection: [
|
||||||
|
selectionType: "thermostats",
|
||||||
|
selectionMatch: deviceId,
|
||||||
|
includeRuntime: true
|
||||||
|
],
|
||||||
|
functions: [
|
||||||
|
[
|
||||||
|
type: "setHold",
|
||||||
|
params: [
|
||||||
|
coolHoldTemp: c,
|
||||||
|
heatHoldTemp: h,
|
||||||
|
holdType: sendHoldType,
|
||||||
|
fan: fanMode
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
return sendCommandToEcobee(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
def sendJson(child = null, String jsonBody) {
|
/**
|
||||||
|
* Sets the mode of the Ecobee thermostat
|
||||||
|
* @param mode - the mode to set to
|
||||||
|
* @param deviceId - the ID of the device
|
||||||
|
*
|
||||||
|
* @return true if the command was successful, false otherwise
|
||||||
|
*/
|
||||||
|
boolean setMode(mode, deviceId) {
|
||||||
|
def payload = [
|
||||||
|
selection: [
|
||||||
|
selectionType: "thermostats",
|
||||||
|
selectionMatch: deviceId,
|
||||||
|
includeRuntime: true
|
||||||
|
],
|
||||||
|
thermostat: [
|
||||||
|
settings: [
|
||||||
|
hvacMode: mode
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
return sendCommandToEcobee(payload)
|
||||||
|
}
|
||||||
|
|
||||||
def returnStatus = false
|
/**
|
||||||
|
* Makes a request to the Ecobee API to actuate the thermostat.
|
||||||
|
* Used by command methods to send commands to Ecobee.
|
||||||
|
*
|
||||||
|
* @param bodyParams - a map of request parameters to send to Ecobee.
|
||||||
|
*
|
||||||
|
* @return true if the command was accepted by Ecobee without error, false otherwise.
|
||||||
|
*/
|
||||||
|
private boolean sendCommandToEcobee(Map bodyParams) {
|
||||||
|
def isSuccess = false
|
||||||
def cmdParams = [
|
def cmdParams = [
|
||||||
uri: apiEndpoint,
|
uri: apiEndpoint,
|
||||||
path: "/1/thermostat",
|
path: "/1/thermostat",
|
||||||
headers: ["Content-Type": "application/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
headers: ["Content-Type": "application/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||||
body: jsonBody
|
body: toJson(bodyParams)
|
||||||
]
|
]
|
||||||
|
|
||||||
try{
|
try{
|
||||||
httpPost(cmdParams) { resp ->
|
httpPost(cmdParams) { resp ->
|
||||||
|
if(resp.status == 200) {
|
||||||
if(resp.status == 200) {
|
log.debug "updated ${resp.data}"
|
||||||
|
def returnStatus = resp.data.status.code
|
||||||
log.debug "updated ${resp.data}"
|
if (returnStatus == 0) {
|
||||||
returnStatus = resp.data.status.code
|
log.debug "Successful call to ecobee API."
|
||||||
if (resp.data.status.code == 0)
|
isSuccess = true
|
||||||
log.debug "Successful call to ecobee API."
|
} else {
|
||||||
else {
|
log.debug "Error return code = ${returnStatus}"
|
||||||
log.debug "Error return code = ${resp.data.status.code}"
|
debugEvent("Error return code = ${returnStatus}")
|
||||||
debugEvent("Error return code = ${resp.data.status.code}")
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (groovyx.net.http.HttpResponseException e) {
|
} catch (groovyx.net.http.HttpResponseException e) {
|
||||||
log.trace "Exception Sending Json: " + e.response.data.status
|
log.trace "Exception Sending Json: " + e.response.data.status
|
||||||
debugEvent ("sent Json & got http status ${e.statusCode} - ${e.response.data.status.code}")
|
debugEvent ("sent Json & got http status ${e.statusCode} - ${e.response.data.status.code}")
|
||||||
if (e.response.data.status.code == 14) {
|
if (e.response.data.status.code == 14) {
|
||||||
|
// TODO - figure out why we're setting the next action to be pollChildren
|
||||||
|
// after refreshing auth token. Is it to keep UI in sync, or just copy/paste error?
|
||||||
atomicState.action = "pollChildren"
|
atomicState.action = "pollChildren"
|
||||||
log.debug "Refreshing your auth_token!"
|
log.debug "Refreshing your auth_token!"
|
||||||
refreshAuthToken()
|
refreshAuthToken()
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
debugEvent("Authentication error, invalid authentication method, lack of credentials, etc.")
|
debugEvent("Authentication error, invalid authentication method, lack of credentials, etc.")
|
||||||
log.error "Authentication error, invalid authentication method, lack of credentials, etc."
|
log.error "Authentication error, invalid authentication method, lack of credentials, etc."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnStatus == 0)
|
return isSuccess
|
||||||
return true
|
|
||||||
else
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def getChildName() { "Ecobee Thermostat" }
|
def getChildName() { return "Ecobee Thermostat" }
|
||||||
def getSensorChildName() { "Ecobee Sensor" }
|
def getSensorChildName() { return "Ecobee Sensor" }
|
||||||
def getServerUrl() { return "https://graph.api.smartthings.com" }
|
def getServerUrl() { return "https://graph.api.smartthings.com" }
|
||||||
def getShardUrl() { return getApiServerUrl() }
|
def getShardUrl() { return getApiServerUrl() }
|
||||||
def getCallbackUrl() { "https://graph.api.smartthings.com/oauth/callback" }
|
def getCallbackUrl() { return "https://graph.api.smartthings.com/oauth/callback" }
|
||||||
def getBuildRedirectUrl() { "${serverUrl}/oauth/initialize?appId=${app.id}&access_token=${atomicState.accessToken}&apiServerUrl=${shardUrl}" }
|
def getBuildRedirectUrl() { return "${serverUrl}/oauth/initialize?appId=${app.id}&access_token=${atomicState.accessToken}&apiServerUrl=${shardUrl}" }
|
||||||
def getApiEndpoint() { "https://api.ecobee.com" }
|
def getApiEndpoint() { return "https://api.ecobee.com" }
|
||||||
def getSmartThingsClientId() { appSettings.clientId }
|
def getSmartThingsClientId() { return appSettings.clientId }
|
||||||
|
|
||||||
def debugEvent(message, displayEvent = false) {
|
def debugEvent(message, displayEvent = false) {
|
||||||
|
|
||||||
def results = [
|
def results = [
|
||||||
name: "appdebug",
|
name: "appdebug",
|
||||||
descriptionText: message,
|
descriptionText: message,
|
||||||
displayed: displayEvent
|
displayed: displayEvent
|
||||||
]
|
]
|
||||||
log.debug "Generating AppDebug Event: ${results}"
|
log.debug "Generating AppDebug Event: ${results}"
|
||||||
sendEvent (results)
|
sendEvent (results)
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
def debugEventFromParent(child, message) {
|
|
||||||
if (child != null) { child.sendEvent("name":"debugEventFromParent", "value":message, "description":message, displayed: true, isStateChange: true)}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//send both push notification and mobile activity feeds
|
//send both push notification and mobile activity feeds
|
||||||
def sendPushAndFeeds(notificationMessage){
|
def sendPushAndFeeds(notificationMessage) {
|
||||||
log.warn "sendPushAndFeeds >> notificationMessage: ${notificationMessage}"
|
log.warn "sendPushAndFeeds >> notificationMessage: ${notificationMessage}"
|
||||||
log.warn "sendPushAndFeeds >> atomicState.timeSendPush: ${atomicState.timeSendPush}"
|
log.warn "sendPushAndFeeds >> atomicState.timeSendPush: ${atomicState.timeSendPush}"
|
||||||
if (atomicState.timeSendPush){
|
if (atomicState.timeSendPush) {
|
||||||
if (now() - atomicState.timeSendPush > 86400000){ // notification is sent to remind user once a day
|
if (now() - atomicState.timeSendPush > 86400000) { // notification is sent to remind user once a day
|
||||||
sendPush("Your Ecobee thermostat " + notificationMessage)
|
sendPush("Your Ecobee thermostat " + notificationMessage)
|
||||||
sendActivityFeeds(notificationMessage)
|
sendActivityFeeds(notificationMessage)
|
||||||
atomicState.timeSendPush = now()
|
atomicState.timeSendPush = now()
|
||||||
@@ -786,6 +822,58 @@ def sendPushAndFeeds(notificationMessage){
|
|||||||
atomicState.authToken = null
|
atomicState.authToken = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stores data about the thermostats in atomicState.
|
||||||
|
* @param thermostats - a list of thermostats as returned from the Ecobee API
|
||||||
|
*/
|
||||||
|
private void storeThermostatData(thermostats) {
|
||||||
|
log.trace "Storing thermostat data: $thermostats"
|
||||||
|
def data
|
||||||
|
atomicState.thermostats = thermostats.inject([:]) { collector, stat ->
|
||||||
|
def dni = [ app.id, stat.identifier ].join('.')
|
||||||
|
log.debug "updating dni $dni"
|
||||||
|
|
||||||
|
data = [
|
||||||
|
coolMode: (stat.settings.coolStages > 0),
|
||||||
|
heatMode: (stat.settings.heatStages > 0),
|
||||||
|
deviceTemperatureUnit: stat.settings.useCelsius,
|
||||||
|
minHeatingSetpoint: (stat.settings.heatRangeLow / 10),
|
||||||
|
maxHeatingSetpoint: (stat.settings.heatRangeHigh / 10),
|
||||||
|
minCoolingSetpoint: (stat.settings.coolRangeLow / 10),
|
||||||
|
maxCoolingSetpoint: (stat.settings.coolRangeHigh / 10),
|
||||||
|
autoMode: stat.settings.autoHeatCoolFeatureEnabled,
|
||||||
|
auxHeatMode: (stat.settings.hasHeatPump) && (stat.settings.hasForcedAir || stat.settings.hasElectric || stat.settings.hasBoiler),
|
||||||
|
temperature: (stat.runtime.actualTemperature / 10),
|
||||||
|
heatingSetpoint: stat.runtime.desiredHeat / 10,
|
||||||
|
coolingSetpoint: stat.runtime.desiredCool / 10,
|
||||||
|
thermostatMode: stat.settings.hvacMode,
|
||||||
|
humidity: stat.runtime.actualHumidity,
|
||||||
|
thermostatFanMode: stat.runtime.desiredFanMode
|
||||||
|
]
|
||||||
|
if (location.temperatureScale == "F") {
|
||||||
|
data["temperature"] = data["temperature"] ? Math.round(data["temperature"].toDouble()) : data["temperature"]
|
||||||
|
data["heatingSetpoint"] = data["heatingSetpoint"] ? Math.round(data["heatingSetpoint"].toDouble()) : data["heatingSetpoint"]
|
||||||
|
data["coolingSetpoint"] = data["coolingSetpoint"] ? Math.round(data["coolingSetpoint"].toDouble()) : data["coolingSetpoint"]
|
||||||
|
data["minHeatingSetpoint"] = data["minHeatingSetpoint"] ? Math.round(data["minHeatingSetpoint"].toDouble()) : data["minHeatingSetpoint"]
|
||||||
|
data["maxHeatingSetpoint"] = data["maxHeatingSetpoint"] ? Math.round(data["maxHeatingSetpoint"].toDouble()) : data["maxHeatingSetpoint"]
|
||||||
|
data["minCoolingSetpoint"] = data["minCoolingSetpoint"] ? Math.round(data["minCoolingSetpoint"].toDouble()) : data["minCoolingSetpoint"]
|
||||||
|
data["maxCoolingSetpoint"] = data["maxCoolingSetpoint"] ? Math.round(data["maxCoolingSetpoint"].toDouble()) : data["maxCoolingSetpoint"]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data?.deviceTemperatureUnit == false && location.temperatureScale == "F") {
|
||||||
|
data["deviceTemperatureUnit"] = "F"
|
||||||
|
|
||||||
|
} else {
|
||||||
|
data["deviceTemperatureUnit"] = "C"
|
||||||
|
}
|
||||||
|
|
||||||
|
collector[dni] = [data:data]
|
||||||
|
return collector
|
||||||
|
}
|
||||||
|
log.debug "updated ${atomicState.thermostats?.size()} thermostats: ${atomicState.thermostats}"
|
||||||
|
}
|
||||||
|
|
||||||
def sendActivityFeeds(notificationMessage) {
|
def sendActivityFeeds(notificationMessage) {
|
||||||
def devices = getChildDevices()
|
def devices = getChildDevices()
|
||||||
devices.each { child ->
|
devices.each { child ->
|
||||||
@@ -793,14 +881,6 @@ def sendActivityFeeds(notificationMessage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def roundC (tempC) {
|
|
||||||
return String.format("%.1f", (Math.round(tempC * 2))/2)
|
|
||||||
}
|
|
||||||
|
|
||||||
def convertFtoC (tempF) {
|
def convertFtoC (tempF) {
|
||||||
return String.format("%.1f", (Math.round(((tempF - 32)*(5/9)) * 2))/2)
|
return String.format("%.1f", (Math.round(((tempF - 32)*(5/9)) * 2))/2)
|
||||||
}
|
}
|
||||||
|
|
||||||
def convertCtoF (tempC) {
|
|
||||||
return (Math.round(tempC * (9/5)) + 32).toInteger()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -64,10 +64,12 @@ def meterHandler(evt) {
|
|||||||
def lastValue = atomicState.lastValue as double
|
def lastValue = atomicState.lastValue as double
|
||||||
atomicState.lastValue = meterValue
|
atomicState.lastValue = meterValue
|
||||||
|
|
||||||
|
def dUnit = evt.unit ?: "Watts"
|
||||||
|
|
||||||
def aboveThresholdValue = aboveThreshold as int
|
def aboveThresholdValue = aboveThreshold as int
|
||||||
if (meterValue > aboveThresholdValue) {
|
if (meterValue > aboveThresholdValue) {
|
||||||
if (lastValue < aboveThresholdValue) { // only send notifications when crossing the threshold
|
if (lastValue < aboveThresholdValue) { // only send notifications when crossing the threshold
|
||||||
def msg = "${meter} reported ${evt.value} ${evt.unit} which is above your threshold of ${aboveThreshold}."
|
def msg = "${meter} reported ${evt.value} ${dUnit} which is above your threshold of ${aboveThreshold}."
|
||||||
sendMessage(msg)
|
sendMessage(msg)
|
||||||
} else {
|
} else {
|
||||||
// log.debug "not sending notification for ${evt.description} because the threshold (${aboveThreshold}) has already been crossed"
|
// log.debug "not sending notification for ${evt.description} because the threshold (${aboveThreshold}) has already been crossed"
|
||||||
@@ -78,7 +80,7 @@ def meterHandler(evt) {
|
|||||||
def belowThresholdValue = belowThreshold as int
|
def belowThresholdValue = belowThreshold as int
|
||||||
if (meterValue < belowThresholdValue) {
|
if (meterValue < belowThresholdValue) {
|
||||||
if (lastValue > belowThresholdValue) { // only send notifications when crossing the threshold
|
if (lastValue > belowThresholdValue) { // only send notifications when crossing the threshold
|
||||||
def msg = "${meter} reported ${evt.value} ${evt.unit} which is below your threshold of ${belowThreshold}."
|
def msg = "${meter} reported ${evt.value} ${dUnit} which is below your threshold of ${belowThreshold}."
|
||||||
sendMessage(msg)
|
sendMessage(msg)
|
||||||
} else {
|
} else {
|
||||||
// log.debug "not sending notification for ${evt.description} because the threshold (${belowThreshold}) has already been crossed"
|
// log.debug "not sending notification for ${evt.description} because the threshold (${belowThreshold}) has already been crossed"
|
||||||
|
|||||||
@@ -761,7 +761,7 @@ String displayableTime(timeRemaining) {
|
|||||||
return "${minutes}:00"
|
return "${minutes}:00"
|
||||||
}
|
}
|
||||||
def fraction = "0.${parts[1]}" as double
|
def fraction = "0.${parts[1]}" as double
|
||||||
def seconds = "${60 * fraction as int}".padRight(2, "0")
|
def seconds = "${60 * fraction as int}".padLeft(2, "0")
|
||||||
return "${minutes}:${seconds}"
|
return "${minutes}:${seconds}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1101,4 +1101,4 @@ def hasStartLevel() {
|
|||||||
|
|
||||||
def hasEndLevel() {
|
def hasEndLevel() {
|
||||||
return (endLevel != null && endLevel != "")
|
return (endLevel != null && endLevel != "")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,7 @@ def bridgeDiscoveryFailed() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def bridgeLinking()
|
def bridgeLinking() {
|
||||||
{
|
|
||||||
int linkRefreshcount = !state.linkRefreshcount ? 0 : state.linkRefreshcount as int
|
int linkRefreshcount = !state.linkRefreshcount ? 0 : state.linkRefreshcount as int
|
||||||
state.linkRefreshcount = linkRefreshcount + 1
|
state.linkRefreshcount = linkRefreshcount + 1
|
||||||
def refreshInterval = 3
|
def refreshInterval = 3
|
||||||
@@ -171,7 +170,7 @@ def bulbDiscovery() {
|
|||||||
|
|
||||||
return dynamicPage(name:"bulbDiscovery", title:"Light Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
return dynamicPage(name:"bulbDiscovery", title:"Light Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
||||||
section("Please wait while we discover your Hue Lights. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
section("Please wait while we discover your Hue Lights. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
||||||
input "selectedBulbs", "enum", required:false, title:"Select Hue Lights to add (${numFound} found)", multiple:true, options:newLights
|
input "selectedBulbs", "enum", required:false, title:"Select Hue Lights to add (${numFound} found)", multiple:true, submitOnChange: true, options:newLights
|
||||||
paragraph title: "Previously added Hue Lights (${existingLights.size()} added)", existingLightsDescription
|
paragraph title: "Previously added Hue Lights (${existingLights.size()} added)", existingLightsDescription
|
||||||
}
|
}
|
||||||
section {
|
section {
|
||||||
@@ -328,7 +327,7 @@ def bulbListHandler(hub, data = "") {
|
|||||||
def object = new groovy.json.JsonSlurper().parseText(data)
|
def object = new groovy.json.JsonSlurper().parseText(data)
|
||||||
object.each { k,v ->
|
object.each { k,v ->
|
||||||
if (v instanceof Map)
|
if (v instanceof Map)
|
||||||
bulbs[k] = [id: k, name: v.name, type: v.type, modelid: v.modelid, hub:hub]
|
bulbs[k] = [id: k, name: v.name, type: v.type, modelid: v.modelid, hub:hub, online: v.state?.reachable]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
def bridge = null
|
def bridge = null
|
||||||
@@ -448,7 +447,6 @@ def addBridge() {
|
|||||||
updateBridgeStatus(childDevice)
|
updateBridgeStatus(childDevice)
|
||||||
childDevice.sendEvent(name: "idNumber", value: idNumber)
|
childDevice.sendEvent(name: "idNumber", value: idNumber)
|
||||||
|
|
||||||
|
|
||||||
if (vbridge.value.ip && vbridge.value.port) {
|
if (vbridge.value.ip && vbridge.value.port) {
|
||||||
if (vbridge.value.ip.contains(".")) {
|
if (vbridge.value.ip.contains(".")) {
|
||||||
childDevice.sendEvent(name: "networkAddress", value: vbridge.value.ip + ":" + vbridge.value.port)
|
childDevice.sendEvent(name: "networkAddress", value: vbridge.value.ip + ":" + vbridge.value.port)
|
||||||
@@ -649,8 +647,7 @@ def locationHandler(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (parsedEvent.headers && parsedEvent.body) {
|
||||||
else if (parsedEvent.headers && parsedEvent.body) {
|
|
||||||
log.trace "HUE BRIDGE RESPONSES"
|
log.trace "HUE BRIDGE RESPONSES"
|
||||||
def headerString = parsedEvent.headers.toString()
|
def headerString = parsedEvent.headers.toString()
|
||||||
if (headerString?.contains("xml")) {
|
if (headerString?.contains("xml")) {
|
||||||
@@ -727,13 +724,13 @@ private void updateBridgeStatus(childDevice) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if all Hue bridges have been heard from in the last 16 minutes, if not an Offline event will be sent
|
* Check if all Hue bridges have been heard from in the last 11 minutes, if not an Offline event will be sent
|
||||||
* for the bridge. Also, set ID number on bridge if not done previously.
|
* for the bridge and all connected lights. Also, set ID number on bridge if not done previously.
|
||||||
*/
|
*/
|
||||||
private void checkBridgeStatus() {
|
private void checkBridgeStatus() {
|
||||||
def bridges = getHueBridges()
|
def bridges = getHueBridges()
|
||||||
// Check if each bridge has been heard from within the last 16 minutes (3 poll intervals times 5 minutes plus buffer)
|
// Check if each bridge has been heard from within the last 11 minutes (2 poll intervals times 5 minutes plus buffer)
|
||||||
def time = now() - (1000 * 60 * 16)
|
def time = now() - (1000 * 60 * 11)
|
||||||
bridges.each {
|
bridges.each {
|
||||||
def d = getChildDevice(it.value.mac)
|
def d = getChildDevice(it.value.mac)
|
||||||
if(d) {
|
if(d) {
|
||||||
@@ -743,14 +740,21 @@ private void checkBridgeStatus() {
|
|||||||
d.sendEvent(name: "idNumber", value: it.value.idNumber)
|
d.sendEvent(name: "idNumber", value: it.value.idNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it.value.lastActivity < time) { // it.value.lastActivity != null &&
|
if (it.value.lastActivity < time) { // it.value.lastActivity != null &&
|
||||||
log.warn "Bridge $it.key is Offline"
|
log.warn "Bridge $it.key is Offline"
|
||||||
d.sendEvent(name: "status", value: "Offline")
|
d.sendEvent(name: "status", value: "Offline")
|
||||||
} else {
|
|
||||||
|
state.bulbs?.each {
|
||||||
|
it.value.online = false
|
||||||
|
}
|
||||||
|
getChildDevices().each {
|
||||||
|
it.sendEvent(name: "DeviceWatch-DeviceOffline", value: "offline", isStateChange: true, displayed: false)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
d.sendEvent(name: "status", value: "Online")//setOnline(false)
|
d.sendEvent(name: "status", value: "Online")//setOnline(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def isValidSource(macAddress) {
|
def isValidSource(macAddress) {
|
||||||
@@ -758,6 +762,10 @@ def isValidSource(macAddress) {
|
|||||||
return (vbridges?.find {"${it.value.mac}" == macAddress}) != null
|
return (vbridges?.find {"${it.value.mac}" == macAddress}) != null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def isInBulbDiscovery() {
|
||||||
|
return state.inBulbDiscovery
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
//CHILD DEVICE METHODS
|
//CHILD DEVICE METHODS
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
@@ -781,8 +789,7 @@ def parse(childDevice, description) {
|
|||||||
if (body instanceof java.util.Map) {
|
if (body instanceof java.util.Map) {
|
||||||
// get (poll) reponse
|
// get (poll) reponse
|
||||||
return handlePoll(body)
|
return handlePoll(body)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
//put response
|
//put response
|
||||||
return handleCommandResponse(body)
|
return handleCommandResponse(body)
|
||||||
}
|
}
|
||||||
@@ -879,36 +886,40 @@ private handleCommandResponse(body) {
|
|||||||
// scan entire response before sending events to make sure they are always in the same order
|
// scan entire response before sending events to make sure they are always in the same order
|
||||||
def updates = [:]
|
def updates = [:]
|
||||||
|
|
||||||
body.each { payload ->
|
body.each { payload ->
|
||||||
log.debug $payload
|
log.debug $payload
|
||||||
|
|
||||||
if (payload?.success) {
|
if (payload?.success) {
|
||||||
def childDeviceNetworkId = app.id + "/"
|
def childDeviceNetworkId = app.id + "/"
|
||||||
def eventType
|
def eventType
|
||||||
payload.success.each { k, v ->
|
payload.success.each { k, v ->
|
||||||
def data = k.split("/")
|
def data = k.split("/")
|
||||||
if (data.length == 5) {
|
if (data.length == 5) {
|
||||||
childDeviceNetworkId = app.id + "/" + k.split("/")[2]
|
childDeviceNetworkId = app.id + "/" + k.split("/")[2]
|
||||||
if (!updates[childDeviceNetworkId])
|
if (!updates[childDeviceNetworkId])
|
||||||
updates[childDeviceNetworkId] = [:]
|
updates[childDeviceNetworkId] = [:]
|
||||||
eventType = k.split("/")[4]
|
eventType = k.split("/")[4]
|
||||||
updates[childDeviceNetworkId]."$eventType" = v
|
updates[childDeviceNetworkId]."$eventType" = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (payload.error) {
|
} else if (payload.error) {
|
||||||
log.warn "Error returned from Hue bridge error = ${body?.error}"
|
log.warn "Error returned from Hue bridge error = ${body?.error}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// send events for each update found above (order of events should be same as handlePoll())
|
// send events for each update found above (order of events should be same as handlePoll())
|
||||||
updates.each { childDeviceNetworkId, params ->
|
updates.each { childDeviceNetworkId, params ->
|
||||||
def device = getChildDevice(childDeviceNetworkId)
|
def device = getChildDevice(childDeviceNetworkId)
|
||||||
sendBasicEvents(device, "on", params.on)
|
def id = getId(device)
|
||||||
sendBasicEvents(device, "bri", params.bri)
|
// If device is offline, then don't send events which will update device watch
|
||||||
sendColorEvents(device, params.xy, params.hue, params.sat, params.ct)
|
if (isOnline(id)) {
|
||||||
}
|
sendBasicEvents(device, "on", params.on)
|
||||||
|
sendBasicEvents(device, "bri", params.bri)
|
||||||
|
sendColorEvents(device, params.xy, params.hue, params.sat, params.ct)
|
||||||
|
}
|
||||||
|
}
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a response to a poll (GET) sent to the Hue Bridge.
|
* Handles a response to a poll (GET) sent to the Hue Bridge.
|
||||||
@@ -928,26 +939,33 @@ private handleCommandResponse(body) {
|
|||||||
* @return empty array
|
* @return empty array
|
||||||
*/
|
*/
|
||||||
private handlePoll(body) {
|
private handlePoll(body) {
|
||||||
if (state.updating) {
|
|
||||||
// If user just executed commands, then ignore poll to not confuse the turning on/off state
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
def bulbs = getChildDevices()
|
def bulbs = getChildDevices()
|
||||||
for (bulb in body) {
|
for (bulb in body) {
|
||||||
def device = bulbs.find{it.deviceNetworkId == "${app.id}/${bulb.key}"}
|
def device = bulbs.find{it.deviceNetworkId == "${app.id}/${bulb.key}"}
|
||||||
if (device) {
|
if (device) {
|
||||||
if (bulb.value.state?.reachable) {
|
if (bulb.value.state?.reachable) {
|
||||||
sendBasicEvents(device, "on", bulb.value?.state?.on)
|
if (state.bulbs[bulb.key]?.online == false) {
|
||||||
sendBasicEvents(device, "bri", bulb.value?.state?.bri)
|
// light just came back online, notify device watch
|
||||||
sendColorEvents(device, bulb.value?.state?.xy, bulb.value?.state?.hue, bulb.value?.state?.sat, bulb.value?.state?.ct, bulb.value?.state?.colormode)
|
def lastActivity = now()
|
||||||
|
device.sendEvent(name: "deviceWatch-status", value: "ONLINE", description: "Last Activity is on ${new Date((long) lastActivity)}", displayed: false, isStateChange: true)
|
||||||
|
}
|
||||||
|
state.bulbs[bulb.key]?.online = true
|
||||||
|
|
||||||
|
// If user just executed commands, then do not send events to avoid confusing the turning on/off state
|
||||||
|
if (!state.updating) {
|
||||||
|
sendBasicEvents(device, "on", bulb.value?.state?.on)
|
||||||
|
sendBasicEvents(device, "bri", bulb.value?.state?.bri)
|
||||||
|
sendColorEvents(device, bulb.value?.state?.xy, bulb.value?.state?.hue, bulb.value?.state?.sat, bulb.value?.state?.ct, bulb.value?.state?.colormode)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
state.bulbs[bulb.key]?.online = false
|
||||||
log.warn "$device is not reachable by Hue bridge"
|
log.warn "$device is not reachable by Hue bridge"
|
||||||
}
|
device.sendEvent(name: "DeviceWatch-DeviceOffline", value: "offline", displayed: false, isStateChange: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return []
|
|
||||||
}
|
}
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
private updateInProgress() {
|
private updateInProgress() {
|
||||||
state.updating = true
|
state.updating = true
|
||||||
@@ -976,22 +994,34 @@ def hubVerification(bodytext) {
|
|||||||
|
|
||||||
def on(childDevice) {
|
def on(childDevice) {
|
||||||
log.debug "Executing 'on'"
|
log.debug "Executing 'on'"
|
||||||
|
def id = getId(childDevice)
|
||||||
|
if (!isOnline(id)) {
|
||||||
|
return "Bulb is unreachable"
|
||||||
|
}
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
createSwitchEvent(childDevice, "on")
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/${getId(childDevice)}/state", [on: true])
|
put("lights/$id/state", [on: true])
|
||||||
return "Bulb is turning On"
|
return "Bulb is turning On"
|
||||||
}
|
}
|
||||||
|
|
||||||
def off(childDevice) {
|
def off(childDevice) {
|
||||||
log.debug "Executing 'off'"
|
log.debug "Executing 'off'"
|
||||||
|
def id = getId(childDevice)
|
||||||
|
if (!isOnline(id)) {
|
||||||
|
return "Bulb is unreachable"
|
||||||
|
}
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
createSwitchEvent(childDevice, "off")
|
createSwitchEvent(childDevice, "off")
|
||||||
put("lights/${getId(childDevice)}/state", [on: false])
|
put("lights/$id/state", [on: false])
|
||||||
return "Bulb is turning Off"
|
return "Bulb is turning Off"
|
||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(childDevice, percent) {
|
def setLevel(childDevice, percent) {
|
||||||
log.debug "Executing 'setLevel'"
|
log.debug "Executing 'setLevel'"
|
||||||
|
def id = getId(childDevice)
|
||||||
|
if (!isOnline(id)) {
|
||||||
|
return "Bulb is unreachable"
|
||||||
|
}
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
// 1 - 254
|
// 1 - 254
|
||||||
def level
|
def level
|
||||||
@@ -1006,48 +1036,64 @@ def setLevel(childDevice, percent) {
|
|||||||
// that means that the light will still be on when on is called next time
|
// that means that the light will still be on when on is called next time
|
||||||
// Lets emulate that here
|
// Lets emulate that here
|
||||||
if (percent > 0) {
|
if (percent > 0) {
|
||||||
put("lights/${getId(childDevice)}/state", [bri: level, on: true])
|
put("lights/$id/state", [bri: level, on: true])
|
||||||
} else {
|
} else {
|
||||||
put("lights/${getId(childDevice)}/state", [on: false])
|
put("lights/$id/state", [on: false])
|
||||||
}
|
}
|
||||||
return "Setting level to $percent"
|
return "Setting level to $percent"
|
||||||
}
|
}
|
||||||
|
|
||||||
def setSaturation(childDevice, percent) {
|
def setSaturation(childDevice, percent) {
|
||||||
log.debug "Executing 'setSaturation($percent)'"
|
log.debug "Executing 'setSaturation($percent)'"
|
||||||
updateInProgress()
|
def id = getId(childDevice)
|
||||||
|
if (!isOnline(id)) {
|
||||||
|
return "Bulb is unreachable"
|
||||||
|
}
|
||||||
|
|
||||||
|
updateInProgress()
|
||||||
// 0 - 254
|
// 0 - 254
|
||||||
def level = Math.min(Math.round(percent * 254 / 100), 254)
|
def level = Math.min(Math.round(percent * 254 / 100), 254)
|
||||||
// TODO should this be done by app only or should we default to on?
|
// TODO should this be done by app only or should we default to on?
|
||||||
createSwitchEvent(childDevice, "on")
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/${getId(childDevice)}/state", [sat: level, on: true])
|
put("lights/$id/state", [sat: level, on: true])
|
||||||
return "Setting saturation to $percent"
|
return "Setting saturation to $percent"
|
||||||
}
|
}
|
||||||
|
|
||||||
def setHue(childDevice, percent) {
|
def setHue(childDevice, percent) {
|
||||||
log.debug "Executing 'setHue($percent)'"
|
log.debug "Executing 'setHue($percent)'"
|
||||||
|
def id = getId(childDevice)
|
||||||
|
if (!isOnline(id)) {
|
||||||
|
return "Bulb is unreachable"
|
||||||
|
}
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
// 0 - 65535
|
// 0 - 65535
|
||||||
def level = Math.min(Math.round(percent * 65535 / 100), 65535)
|
def level = Math.min(Math.round(percent * 65535 / 100), 65535)
|
||||||
// TODO should this be done by app only or should we default to on?
|
// TODO should this be done by app only or should we default to on?
|
||||||
createSwitchEvent(childDevice, "on")
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/${getId(childDevice)}/state", [hue: level, on: true])
|
put("lights/$id/state", [hue: level, on: true])
|
||||||
return "Setting hue to $percent"
|
return "Setting hue to $percent"
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColorTemperature(childDevice, huesettings) {
|
def setColorTemperature(childDevice, huesettings) {
|
||||||
log.debug "Executing 'setColorTemperature($huesettings)'"
|
log.debug "Executing 'setColorTemperature($huesettings)'"
|
||||||
|
def id = getId(childDevice)
|
||||||
|
if (!isOnline(id)) {
|
||||||
|
return "Bulb is unreachable"
|
||||||
|
}
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
// 153 (6500K) to 500 (2000K)
|
// 153 (6500K) to 500 (2000K)
|
||||||
def ct = hueSettings == 6500 ? 153 : Math.round(1000000/huesettings)
|
def ct = hueSettings == 6500 ? 153 : Math.round(1000000/huesettings)
|
||||||
createSwitchEvent(childDevice, "on")
|
createSwitchEvent(childDevice, "on")
|
||||||
put("lights/${getId(childDevice)}/state", [ct: ct, on: true])
|
put("lights/$id/state", [ct: ct, on: true])
|
||||||
return "Setting color temperature to $percent"
|
return "Setting color temperature to $percent"
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColor(childDevice, huesettings) {
|
def setColor(childDevice, huesettings) {
|
||||||
log.debug "Executing 'setColor($huesettings)'"
|
log.debug "Executing 'setColor($huesettings)'"
|
||||||
|
def id = getId(childDevice)
|
||||||
|
if (!isOnline(id)) {
|
||||||
|
return "Bulb is unreachable"
|
||||||
|
}
|
||||||
updateInProgress()
|
updateInProgress()
|
||||||
|
|
||||||
def value = [:]
|
def value = [:]
|
||||||
@@ -1104,15 +1150,23 @@ def setColor(childDevice, huesettings) {
|
|||||||
value.on = false
|
value.on = false
|
||||||
|
|
||||||
createSwitchEvent(childDevice, value.on ? "on" : "off")
|
createSwitchEvent(childDevice, value.on ? "on" : "off")
|
||||||
put("lights/${getId(childDevice)}/state", value)
|
put("lights/$id/state", value)
|
||||||
return "Setting color to $value"
|
return "Setting color to $value"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def ping(childDevice) {
|
||||||
|
if (isOnline(getId(childDevice))) {
|
||||||
|
childDevice.sendEvent(name: "deviceWatch-ping", value: "ONLINE", description: "Hue Light is reachable", displayed: false, isStateChange: true)
|
||||||
|
return "Device is Online"
|
||||||
|
} else {
|
||||||
|
return "Device is Offline"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private getId(childDevice) {
|
private getId(childDevice) {
|
||||||
if (childDevice.device?.deviceNetworkId?.startsWith("HUE")) {
|
if (childDevice.device?.deviceNetworkId?.startsWith("HUE")) {
|
||||||
return childDevice.device?.deviceNetworkId[3..-1]
|
return childDevice.device?.deviceNetworkId[3..-1]
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return childDevice.device?.deviceNetworkId.split("/")[-1]
|
return childDevice.device?.deviceNetworkId.split("/")[-1]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1123,10 +1177,13 @@ private poll() {
|
|||||||
log.debug "GET: $host$uri"
|
log.debug "GET: $host$uri"
|
||||||
sendHubCommand(new physicalgraph.device.HubAction("""GET ${uri} HTTP/1.1
|
sendHubCommand(new physicalgraph.device.HubAction("""GET ${uri} HTTP/1.1
|
||||||
HOST: ${host}
|
HOST: ${host}
|
||||||
|
|
||||||
""", physicalgraph.device.Protocol.LAN, selectedHue))
|
""", physicalgraph.device.Protocol.LAN, selectedHue))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isOnline(id) {
|
||||||
|
return (state.bulbs[id].online != null && state.bulbs[id].online) || state.bulbs[id].online == null
|
||||||
|
}
|
||||||
|
|
||||||
private put(path, body) {
|
private put(path, body) {
|
||||||
def host = getBridgeIP()
|
def host = getBridgeIP()
|
||||||
def uri = "/api/${state.username}/$path"
|
def uri = "/api/${state.username}/$path"
|
||||||
@@ -1194,7 +1251,7 @@ def convertBulbListToMap() {
|
|||||||
if (state.bulbs instanceof java.util.List) {
|
if (state.bulbs instanceof java.util.List) {
|
||||||
def map = [:]
|
def map = [:]
|
||||||
state.bulbs.unique {it.id}.each { bulb ->
|
state.bulbs.unique {it.id}.each { bulb ->
|
||||||
map << ["${bulb.id}":["id":bulb.id, "name":bulb.name, "type": bulb.type, "modelid": bulb.modelid, "hub":bulb.hub]]
|
map << ["${bulb.id}":["id":bulb.id, "name":bulb.name, "type": bulb.type, "modelid": bulb.modelid, "hub":bulb.hub, "online": bulb.online]]
|
||||||
}
|
}
|
||||||
state.bulbs = map
|
state.bulbs = map
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,8 +74,6 @@ def authPage()
|
|||||||
|
|
||||||
def redirectUrl = oauthInitUrl()
|
def redirectUrl = oauthInitUrl()
|
||||||
|
|
||||||
log.debug "RedirectURL = ${redirectUrl}"
|
|
||||||
|
|
||||||
return dynamicPage(name: "Credentials", title: "Life360", nextPage:"listCirclesPage", uninstall: uninstallOption, install:false) {
|
return dynamicPage(name: "Credentials", title: "Life360", nextPage:"listCirclesPage", uninstall: uninstallOption, install:false) {
|
||||||
section {
|
section {
|
||||||
href url:redirectUrl, style:"embedded", required:false, title:"Life360", description:description
|
href url:redirectUrl, style:"embedded", required:false, title:"Life360", description:description
|
||||||
@@ -257,8 +255,6 @@ def initializeLife360Connection() {
|
|||||||
def oauthClientId = appSettings.clientId
|
def oauthClientId = appSettings.clientId
|
||||||
def oauthClientSecret = appSettings.clientSecret
|
def oauthClientSecret = appSettings.clientSecret
|
||||||
|
|
||||||
log.debug "Installed with settings: ${settings}"
|
|
||||||
|
|
||||||
initialize()
|
initialize()
|
||||||
|
|
||||||
def username = settings.username
|
def username = settings.username
|
||||||
@@ -269,8 +265,6 @@ def initializeLife360Connection() {
|
|||||||
def basicCredentials = "${oauthClientId}:${oauthClientSecret}"
|
def basicCredentials = "${oauthClientId}:${oauthClientSecret}"
|
||||||
def encodedCredentials = basicCredentials.encodeAsBase64().toString()
|
def encodedCredentials = basicCredentials.encodeAsBase64().toString()
|
||||||
|
|
||||||
log.debug "Encoded Creds: ${encodedCredentials}"
|
|
||||||
|
|
||||||
|
|
||||||
// call life360, get OAUTH token using password flow, save
|
// call life360, get OAUTH token using password flow, save
|
||||||
// curl -X POST -H "Authorization: Basic cFJFcXVnYWJSZXRyZTRFc3RldGhlcnVmcmVQdW1hbUV4dWNyRUh1YzptM2ZydXBSZXRSZXN3ZXJFQ2hBUHJFOTZxYWtFZHI0Vg=="
|
// curl -X POST -H "Authorization: Basic cFJFcXVnYWJSZXRyZTRFc3RldGhlcnVmcmVQdW1hbUV4dWNyRUh1YzptM2ZydXBSZXRSZXN3ZXJFQ2hBUHJFOTZxYWtFZHI0Vg=="
|
||||||
@@ -284,8 +278,6 @@ def initializeLife360Connection() {
|
|||||||
"username=${username}&"+
|
"username=${username}&"+
|
||||||
"password=${password}"
|
"password=${password}"
|
||||||
|
|
||||||
log.debug "Post Body: ${postBody}"
|
|
||||||
|
|
||||||
def result = null
|
def result = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -295,7 +287,6 @@ def initializeLife360Connection() {
|
|||||||
}
|
}
|
||||||
if (result.data.access_token) {
|
if (result.data.access_token) {
|
||||||
state.life360AccessToken = result.data.access_token
|
state.life360AccessToken = result.data.access_token
|
||||||
log.debug "Access Token = ${state.life360AccessToken}"
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
log.debug "Response=${result.data}"
|
log.debug "Response=${result.data}"
|
||||||
@@ -533,8 +524,6 @@ def createCircleSubscription() {
|
|||||||
|
|
||||||
def postBody = "url=${hookUrl}"
|
def postBody = "url=${hookUrl}"
|
||||||
|
|
||||||
log.debug "Post Body: ${postBody}"
|
|
||||||
|
|
||||||
def result = null
|
def result = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -586,8 +575,6 @@ def updated() {
|
|||||||
|
|
||||||
// log.debug "After Find Attempt."
|
// log.debug "After Find Attempt."
|
||||||
|
|
||||||
log.debug "Member Id = ${member.id}, Name = ${member.firstName} ${member.lastName}, Email Address = ${member.loginEmail}"
|
|
||||||
|
|
||||||
// log.debug "External Id=${app.id}:${member.id}"
|
// log.debug "External Id=${app.id}:${member.id}"
|
||||||
|
|
||||||
// create the device
|
// create the device
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ preferences {
|
|||||||
}
|
}
|
||||||
section("Via a push notification and/or an SMS message"){
|
section("Via a push notification and/or an SMS message"){
|
||||||
input("recipients", "contact", title: "Send notifications to") {
|
input("recipients", "contact", title: "Send notifications to") {
|
||||||
input "phone", "phone", title: "Phone Number (for SMS, optional)", required: false
|
input "phone", "phone", title: "Enter a phone number to get SMS", required: false
|
||||||
paragraph "If outside the US please make sure to enter the proper country code"
|
paragraph "If outside the US please make sure to enter the proper country code"
|
||||||
input "pushAndPhone", "enum", title: "Both Push and SMS?", required: false, options: ["Yes", "No"]
|
input "pushAndPhone", "enum", title: "Notify me via Push Notification", required: false, options: ["Yes", "No"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
section("Minimum time between messages (optional, defaults to every message)") {
|
section("Minimum time between messages (optional, defaults to every message)") {
|
||||||
@@ -111,19 +111,24 @@ private sendMessage(evt) {
|
|||||||
if (location.contactBookEnabled) {
|
if (location.contactBookEnabled) {
|
||||||
sendNotificationToContacts(msg, recipients, options)
|
sendNotificationToContacts(msg, recipients, options)
|
||||||
} else {
|
} else {
|
||||||
if (!phone || pushAndPhone != 'No') {
|
|
||||||
log.debug 'sending push'
|
|
||||||
options.method = 'push'
|
|
||||||
//sendPush(msg)
|
|
||||||
}
|
|
||||||
if (phone) {
|
if (phone) {
|
||||||
options.phone = phone
|
options.phone = phone
|
||||||
log.debug 'sending SMS'
|
if (pushAndPhone != 'No') {
|
||||||
//sendSms(phone, msg)
|
log.debug 'Sending push and SMS'
|
||||||
|
options.method = 'both'
|
||||||
|
} else {
|
||||||
|
log.debug 'Sending SMS'
|
||||||
|
options.method = 'phone'
|
||||||
|
}
|
||||||
|
} else if (pushAndPhone != 'No') {
|
||||||
|
log.debug 'Sending push'
|
||||||
|
options.method = 'push'
|
||||||
|
} else {
|
||||||
|
log.debug 'Sending nothing'
|
||||||
|
options.method = 'none'
|
||||||
}
|
}
|
||||||
sendNotification(msg, options)
|
sendNotification(msg, options)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (frequency) {
|
if (frequency) {
|
||||||
state[evt.deviceId] = now()
|
state[evt.deviceId] = now()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user