mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 21:03:00 +00:00
Compare commits
90 Commits
PROD_2016.
...
MSA-1483-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23daf18725 | ||
|
|
71880e2644 | ||
|
|
8d920ea072 | ||
|
|
43a1ae6371 | ||
|
|
a441b94a33 | ||
|
|
ced03d746d | ||
|
|
5341d0d06f | ||
|
|
2a58d7ff62 | ||
|
|
260917d515 | ||
|
|
c1478d3e96 | ||
|
|
8b9bff15dc | ||
|
|
75c1ede16c | ||
|
|
a7acc384a2 | ||
|
|
c6998e5f1d | ||
|
|
f95e906d6e | ||
|
|
a6c7ab49b6 | ||
|
|
4891e3b947 | ||
|
|
ae91f9bff5 | ||
|
|
bb87ad2cf0 | ||
|
|
5dff03fb69 | ||
|
|
629d768575 | ||
|
|
dd7c6b90d5 | ||
|
|
4523498dab | ||
|
|
e89e45e000 | ||
|
|
78ec280e83 | ||
|
|
1f144d36e4 | ||
|
|
f5bd580c9e | ||
|
|
d5329dbde3 | ||
|
|
48818cfb06 | ||
|
|
079919260b | ||
|
|
570922e2ac | ||
|
|
53ed9b4d2b | ||
|
|
7149a81c85 | ||
|
|
30274f0cd7 | ||
|
|
8869cd3af0 | ||
|
|
fb0caa6446 | ||
|
|
3d05d42cb8 | ||
|
|
3184615e87 | ||
|
|
0f70362e0a | ||
|
|
bc817f8530 | ||
|
|
01b8399893 | ||
|
|
81318bafac | ||
|
|
60c2006bfc | ||
|
|
1e4f1223e7 | ||
|
|
b78bce55b2 | ||
|
|
01593c3973 | ||
|
|
6862785d6c | ||
|
|
763d7411e2 | ||
|
|
c703543f36 | ||
|
|
5db6ecda3e | ||
|
|
43b836f413 | ||
|
|
006b5e7bea | ||
|
|
62c8c19805 | ||
|
|
48e9a4bd6a | ||
|
|
07a4c0decc | ||
|
|
6aa09bb052 | ||
|
|
2f889de11a | ||
|
|
5584020e96 | ||
|
|
4ef2e694c2 | ||
|
|
826993cc45 | ||
|
|
ae3306928b | ||
|
|
8777ec5f6d | ||
|
|
91eb59a10d | ||
|
|
324ac13afb | ||
|
|
878eb66b8b | ||
|
|
8dfc270c2d | ||
|
|
614573a15c | ||
|
|
9c7b0875ba | ||
|
|
7568cbf781 | ||
|
|
1858c280a5 | ||
|
|
6b7d0968f6 | ||
|
|
159d3acf4f | ||
|
|
e8101630a3 | ||
|
|
f5ba78b221 | ||
|
|
19b8a7eeb9 | ||
|
|
1b37d649a5 | ||
|
|
dedb0f8465 | ||
|
|
06acc13575 | ||
|
|
c051d719cc | ||
|
|
1e54b93b0c | ||
|
|
bac37f9ca2 | ||
|
|
f0ecb65c09 | ||
|
|
1c0ddd2571 | ||
|
|
b7e0cbda09 | ||
|
|
f80e094bd9 | ||
|
|
fe2fbc3b97 | ||
|
|
383f72580a | ||
|
|
090a306939 | ||
|
|
5e6b4f74e0 | ||
|
|
22185c5440 |
30
build.gradle
30
build.gradle
@@ -19,7 +19,7 @@ buildscript {
|
||||
username smartThingsArtifactoryUserName
|
||||
password smartThingsArtifactoryPassword
|
||||
}
|
||||
url "http://artifactory.smartthings.com/libs-release-local"
|
||||
url "https://artifactory.smartthings.com/libs-release-local"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,9 +27,37 @@ buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
jcenter()
|
||||
maven {
|
||||
credentials {
|
||||
username smartThingsArtifactoryUserName
|
||||
password smartThingsArtifactoryPassword
|
||||
}
|
||||
url "https://artifactory.smartthings.com/libs-release-local"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
devicetypes {
|
||||
groovy {
|
||||
srcDirs = ['devicetypes']
|
||||
}
|
||||
}
|
||||
smartapps {
|
||||
groovy {
|
||||
srcDirs = ['smartapps']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
devicetypesCompile 'org.codehaus.groovy:groovy-all:2.4.7'
|
||||
devicetypesCompile 'smartthings:appengine-z-wave:0.1.2'
|
||||
devicetypesCompile 'smartthings:appengine-zigbee:0.1.11'
|
||||
smartappsCompile 'org.codehaus.groovy:groovy-all:2.4.7'
|
||||
smartappsCompile 'smartthings:appengine-common:0.1.8'
|
||||
smartappsCompile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
|
||||
smartappsCompile 'org.grails:grails-web:2.3.11'
|
||||
smartappsCompile 'org.json:json:20140107'
|
||||
}
|
||||
|
||||
slackSendMessage {
|
||||
|
||||
@@ -5,7 +5,9 @@ machine:
|
||||
|
||||
dependencies:
|
||||
override:
|
||||
- echo "Nothing to do."
|
||||
- ./gradlew dependencies -PsmartThingsArtifactoryUserName="$ARTIFACTORY_USERNAME" -PsmartThingsArtifactoryPassword="$ARTIFACTORY_PASSWORD"
|
||||
post:
|
||||
- ./gradlew compileSmartappsGroovy compileDevicetypesGroovy -PsmartThingsArtifactoryUserName="$ARTIFACTORY_USERNAME" -PsmartThingsArtifactoryPassword="$ARTIFACTORY_PASSWORD"
|
||||
|
||||
test:
|
||||
override:
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "Netatmo Additional Module", namespace: "dianoga", author: "Brian Steere") {
|
||||
capability "Sensor"
|
||||
capability "Relative Humidity Measurement"
|
||||
capability "Temperature Measurement"
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "Netatmo Basestation", namespace: "dianoga", author: "Brian Steere") {
|
||||
capability "Sensor"
|
||||
capability "Relative Humidity Measurement"
|
||||
capability "Temperature Measurement"
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "Netatmo Outdoor Module", namespace: "dianoga", author: "Brian Steere") {
|
||||
capability "Sensor"
|
||||
capability "Relative Humidity Measurement"
|
||||
capability "Temperature Measurement"
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "Netatmo Rain", namespace: "dianoga", author: "Brian Steere") {
|
||||
capability "Sensor"
|
||||
|
||||
attribute "rain", "number"
|
||||
attribute "rainSumHour", "number"
|
||||
attribute "rainSumDay", "number"
|
||||
|
||||
@@ -33,8 +33,8 @@ metadata {
|
||||
tiles(scale: 2) {
|
||||
multiAttributeTile(name:"FGMS", type:"lighting", width:6, height:4) {//with generic type secondary control text is not displayed in Android app
|
||||
tileAttribute("device.motion", key:"PRIMARY_CONTROL") {
|
||||
attributeState("inactive", icon:"st.motion.motion.inactive", backgroundColor:"#79b821")
|
||||
attributeState("active", icon:"st.motion.motion.active", backgroundColor:"#ffa81e")
|
||||
attributeState("inactive", label:"no motion", icon:"st.motion.motion.inactive", backgroundColor:"#79b821")
|
||||
attributeState("active", label:"motion", icon:"st.motion.motion.active", backgroundColor:"#ffa81e")
|
||||
}
|
||||
|
||||
tileAttribute("device.tamper", key:"SECONDARY_CONTROL") {
|
||||
@@ -278,4 +278,4 @@ private encap(physicalgraph.zwave.Command cmd) {
|
||||
} else {
|
||||
crc16(cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,8 @@ Works with:
|
||||
|
||||
## 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
|
||||
A Category C6 Connected Cree LED Bulb with maxReportTime of 5 mins.
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ metadata {
|
||||
|
||||
capability "Actuator"
|
||||
capability "Configuration"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Switch"
|
||||
capability "Switch Level"
|
||||
@@ -67,12 +66,6 @@ def parse(String description) {
|
||||
def resultMap = zigbee.getEvent(description)
|
||||
if (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 {
|
||||
log.debug "DID NOT PARSE MESSAGE for description : $description"
|
||||
@@ -96,27 +89,24 @@ def setLevel(value) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.levelRefresh()
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig() + zigbee.levelConfig()
|
||||
}
|
||||
|
||||
def poll() {
|
||||
zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
def healthPoll() {
|
||||
def cmds = zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
cmds.each{ sendHubCommand(new physicalgraph.device.HubAction(it))}
|
||||
}
|
||||
|
||||
def configure() {
|
||||
unschedule()
|
||||
schedule("0 0/5 * * * ? *", "healthPoll")
|
||||
log.debug "Configuring Reporting and Bindings."
|
||||
sendEvent(name: "checkInterval", value: 1200, displayed: false, data: [protocol: "zigbee"])
|
||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, 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
|
||||
isChange = isTemperatureStateChange(device, name, value.toString())
|
||||
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") {
|
||||
def sendValue = convertTemperatureIfNeeded(value.toDouble(), "F", 1) //API return temperature value in F
|
||||
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"){
|
||||
isChange = isStateChange(device, name, value.toString())
|
||||
event << [value: value.toString(), isStateChange: isChange, displayed: false]
|
||||
@@ -234,9 +234,9 @@ void setHeatingSetpoint(setpoint) {
|
||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||
|
||||
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
||||
if (parent.setHold(this, heatingValue, coolingValue, deviceId, sendHoldType)) {
|
||||
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint)
|
||||
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint)
|
||||
if (parent.setHold(heatingValue, coolingValue, deviceId, sendHoldType)) {
|
||||
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
|
||||
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
|
||||
log.debug "Done setHeatingSetpoint> coolingSetpoint: ${coolingSetpoint}, heatingSetpoint: ${heatingSetpoint}"
|
||||
generateSetpointEvent()
|
||||
generateStatusEvent()
|
||||
@@ -271,9 +271,9 @@ void setCoolingSetpoint(setpoint) {
|
||||
def heatingValue = location.temperatureScale == "C"? convertCtoF(heatingSetpoint) : heatingSetpoint
|
||||
|
||||
def sendHoldType = holdType ? (holdType=="Temporary")? "nextTransition" : (holdType=="Permanent")? "indefinite" : "indefinite" : "indefinite"
|
||||
if (parent.setHold(this, heatingValue, coolingValue, deviceId, sendHoldType)) {
|
||||
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint)
|
||||
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint)
|
||||
if (parent.setHold(heatingValue, coolingValue, deviceId, sendHoldType)) {
|
||||
sendEvent("name":"heatingSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
|
||||
sendEvent("name":"coolingSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
|
||||
log.debug "Done setCoolingSetpoint>> coolingSetpoint = ${coolingSetpoint}, heatingSetpoint = ${heatingSetpoint}"
|
||||
generateSetpointEvent()
|
||||
generateStatusEvent()
|
||||
@@ -287,14 +287,14 @@ void resumeProgram() {
|
||||
log.debug "resumeProgram() is called"
|
||||
sendEvent("name":"thermostatStatus", "value":"resuming schedule", "description":statusText, displayed: false)
|
||||
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)
|
||||
runIn(5, "poll")
|
||||
log.debug "resumeProgram() is done"
|
||||
sendEvent("name":"resumeProgram", "value":"resume", descriptionText: "resumeProgram is done", displayed: false, isStateChange: true)
|
||||
} else {
|
||||
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() {
|
||||
log.debug "off"
|
||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||
if (parent.setMode (this,"off", deviceId))
|
||||
if (parent.setMode ("off", deviceId))
|
||||
generateModeEvent("off")
|
||||
else {
|
||||
log.debug "Error setting new mode."
|
||||
@@ -420,7 +420,7 @@ def off() {
|
||||
def heat() {
|
||||
log.debug "heat"
|
||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||
if (parent.setMode (this,"heat", deviceId))
|
||||
if (parent.setMode ("heat", deviceId))
|
||||
generateModeEvent("heat")
|
||||
else {
|
||||
log.debug "Error setting new mode."
|
||||
@@ -438,7 +438,7 @@ def emergencyHeat() {
|
||||
def auxHeatOnly() {
|
||||
log.debug "auxHeatOnly"
|
||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||
if (parent.setMode (this,"auxHeatOnly", deviceId))
|
||||
if (parent.setMode ("auxHeatOnly", deviceId))
|
||||
generateModeEvent("auxHeatOnly")
|
||||
else {
|
||||
log.debug "Error setting new mode."
|
||||
@@ -452,7 +452,7 @@ def auxHeatOnly() {
|
||||
def cool() {
|
||||
log.debug "cool"
|
||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||
if (parent.setMode (this,"cool", deviceId))
|
||||
if (parent.setMode ("cool", deviceId))
|
||||
generateModeEvent("cool")
|
||||
else {
|
||||
log.debug "Error setting new mode."
|
||||
@@ -466,7 +466,7 @@ def cool() {
|
||||
def auto() {
|
||||
log.debug "auto"
|
||||
def deviceId = device.deviceNetworkId.split(/\./).last()
|
||||
if (parent.setMode (this,"auto", deviceId))
|
||||
if (parent.setMode ("auto", deviceId))
|
||||
generateModeEvent("auto")
|
||||
else {
|
||||
log.debug "Error setting new mode."
|
||||
@@ -489,7 +489,7 @@ def fanOn() {
|
||||
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
||||
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)
|
||||
} else {
|
||||
log.debug "Error setting new mode."
|
||||
@@ -510,7 +510,7 @@ def fanAuto() {
|
||||
def coolingValue = location.temperatureScale == "C"? convertCtoF(coolingSetpoint) : coolingSetpoint
|
||||
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)
|
||||
} else {
|
||||
log.debug "Error setting new mode."
|
||||
@@ -556,12 +556,12 @@ def generateSetpointEvent() {
|
||||
|
||||
if (mode == "heat") {
|
||||
|
||||
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint )
|
||||
sendEvent("name":"thermostatSetpoint", "value":heatingSetpoint, "unit":location.temperatureScale)
|
||||
|
||||
}
|
||||
else if (mode == "cool") {
|
||||
|
||||
sendEvent("name":"thermostatSetpoint", "value":coolingSetpoint)
|
||||
sendEvent("name":"thermostatSetpoint", "value":coolingSetpoint, "unit":location.temperatureScale)
|
||||
|
||||
} else if (mode == "auto") {
|
||||
|
||||
@@ -573,7 +573,7 @@ def generateSetpointEvent() {
|
||||
|
||||
} 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
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
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 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": "heatingSetpoint", "value": targetHeatingSetpoint)
|
||||
sendEvent("name": "coolingSetpoint", "value": targetCoolingSetpoint)
|
||||
sendEvent("name": "heatingSetpoint", "value": targetHeatingSetpoint, "unit": location.temperatureScale)
|
||||
sendEvent("name": "coolingSetpoint", "value": targetCoolingSetpoint, "unit": location.temperatureScale)
|
||||
log.debug "alterSetpoint in mode $mode succeed change setpoint to= ${temp.value}"
|
||||
} else {
|
||||
log.error "Error alterSetpoint()"
|
||||
|
||||
@@ -16,6 +16,7 @@ metadata {
|
||||
capability "Switch"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Health Check"
|
||||
|
||||
command "setAdjustedColor"
|
||||
command "reset"
|
||||
@@ -55,6 +56,10 @@ metadata {
|
||||
}
|
||||
}
|
||||
|
||||
void installed() {
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false)
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
@@ -166,3 +171,7 @@ def verifyPercent(percent) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
def ping() {
|
||||
log.debug "${parent.ping(this)}"
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ metadata {
|
||||
capability "Switch"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Health Check"
|
||||
|
||||
command "setAdjustedColor"
|
||||
command "reset"
|
||||
@@ -64,6 +65,10 @@ metadata {
|
||||
}
|
||||
}
|
||||
|
||||
void installed() {
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false)
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
@@ -182,3 +187,7 @@ def verifyPercent(percent) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
def ping() {
|
||||
log.trace "${parent.ping(this)}"
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ metadata {
|
||||
capability "Switch"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Health Check"
|
||||
|
||||
command "refresh"
|
||||
}
|
||||
@@ -48,6 +49,10 @@ metadata {
|
||||
}
|
||||
}
|
||||
|
||||
void installed() {
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false)
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
@@ -87,3 +92,7 @@ void refresh() {
|
||||
log.debug "Executing 'refresh'"
|
||||
parent.manualRefresh()
|
||||
}
|
||||
|
||||
def ping() {
|
||||
log.debug "${parent.ping(this)}"
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ metadata {
|
||||
capability "Color Temperature"
|
||||
capability "Switch"
|
||||
capability "Refresh"
|
||||
capability "Health Check"
|
||||
|
||||
command "refresh"
|
||||
}
|
||||
@@ -53,6 +54,10 @@ metadata {
|
||||
}
|
||||
}
|
||||
|
||||
void installed() {
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "lan"], displayed: false)
|
||||
}
|
||||
|
||||
// parse events into attributes
|
||||
def parse(description) {
|
||||
log.debug "parse() - $description"
|
||||
@@ -101,3 +106,7 @@ void refresh() {
|
||||
log.debug "Executing 'refresh'"
|
||||
parent.manualRefresh()
|
||||
}
|
||||
|
||||
def ping() {
|
||||
log.debug "${parent.ping(this)}"
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ def parse(String description) {
|
||||
|
||||
if (descMap.cluster == "0300") {
|
||||
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"
|
||||
sendEvent(name: "hue", value: hueValue, displayed:false)
|
||||
}
|
||||
@@ -203,7 +203,7 @@ def setLevel(value) {
|
||||
|
||||
//input Hue Integer values; returns color name for saturation 100%
|
||||
private getColorName(hueValue){
|
||||
if(hueValue>360 || hueValue<0)
|
||||
if(hueValue>100 || hueValue<0)
|
||||
return
|
||||
|
||||
hueValue = Math.round(hueValue / 100 * 360)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Osram Flex RGBW Light Strip
|
||||
|
||||
Osram bulbs have a firmware issue causing it to forget its dimming level when turned off (via commands). Handling
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
metadata {
|
||||
definition (name: "OSRAM LIGHTIFY LED Flexible Strip RGBW", namespace: "smartthings", author: "SmartThings") {
|
||||
|
||||
|
||||
capability "Color Temperature"
|
||||
capability "Actuator"
|
||||
capability "Switch"
|
||||
@@ -18,7 +18,7 @@ metadata {
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Color Control"
|
||||
|
||||
|
||||
attribute "colorName", "string"
|
||||
|
||||
command "setAdjustedColor"
|
||||
@@ -49,7 +49,7 @@ metadata {
|
||||
standardTile("refresh", "device.switch", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
|
||||
|
||||
controlTile("colorTempSliderControl", "device.colorTemperature", "slider", height: 1, width: 2, inactiveLabel: false, range:"(2700..6500)") {
|
||||
state "colorTemperature", action:"color temperature.setColorTemperature"
|
||||
}
|
||||
@@ -118,7 +118,7 @@ def parse(String description) {
|
||||
}
|
||||
}
|
||||
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"
|
||||
sendEvent(name: "hue", value: hueValue, displayed:false)
|
||||
}
|
||||
@@ -274,7 +274,7 @@ private getGenericName(value){
|
||||
|
||||
//input Hue Integer values; returns color name for saturation 100%
|
||||
private getColorName(hueValue){
|
||||
if(hueValue>360 || hueValue<0)
|
||||
if(hueValue>100 || hueValue<0)
|
||||
return
|
||||
|
||||
hueValue = Math.round(hueValue / 100 * 360)
|
||||
@@ -449,7 +449,7 @@ def setColor(value){
|
||||
def level = hex(value.level * 255 / 100)
|
||||
cmd << zigbeeSetLevel(level)
|
||||
}
|
||||
|
||||
|
||||
if (value.switch == "off") {
|
||||
cmd << "delay 150"
|
||||
cmd << off()
|
||||
|
||||
@@ -23,10 +23,10 @@ Works with:
|
||||
|
||||
## 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.
|
||||
A Category C1 smart power outlet with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 2*10 = 20 min
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
||||
@@ -101,12 +101,6 @@ def parse(String description) {
|
||||
else {
|
||||
def descriptionText = finalResult.value == "on" ? '{{ device.displayName }} is On' : '{{ device.displayName }} is Off'
|
||||
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 {
|
||||
@@ -126,15 +120,7 @@ def on() {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.onOffRefresh()
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -142,8 +128,10 @@ def refresh() {
|
||||
}
|
||||
|
||||
def configure() {
|
||||
sendEvent(name: "checkInterval", value: 1200, displayed: false, data: [protocol: "zigbee"])
|
||||
zigbee.onOffConfig() + powerConfig() + refresh()
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, 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)
|
||||
|
||||
@@ -23,10 +23,10 @@ Works with:
|
||||
|
||||
## Device Health
|
||||
|
||||
A Category C2 moisture sensor with maxReportTime of 1 hr.
|
||||
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||
A Category C2 moisture sensor with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 2*60 = 120 min
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## Battery Specification
|
||||
|
||||
|
||||
@@ -101,13 +101,6 @@ def parse(String 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"
|
||||
def result = map ? createEvent(map) : null
|
||||
|
||||
@@ -233,6 +226,8 @@ private Map getBatteryResult(rawValue) {
|
||||
def maxVolts = 3.0
|
||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||
def roundedPct = Math.round(pct * 100)
|
||||
if (roundedPct <= 0)
|
||||
roundedPct = 1
|
||||
result.value = Math.min(100, roundedPct)
|
||||
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
||||
}
|
||||
@@ -283,15 +278,7 @@ private Map getMoistureResult(value) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -305,23 +292,19 @@ def refresh() {
|
||||
}
|
||||
|
||||
def configure() {
|
||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
|
||||
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
||||
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
||||
def configCmds = [
|
||||
def enrollCmds = [
|
||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||
"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() {
|
||||
|
||||
@@ -22,10 +22,10 @@ Works with:
|
||||
|
||||
## Device Health
|
||||
|
||||
A Category C2 motion sensor with maxReportTime of 1 hr.
|
||||
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||
A Category C2 motion sensor with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 2*60 = 120 min
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## Battery Specification
|
||||
|
||||
|
||||
@@ -105,13 +105,6 @@ def parse(String 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"
|
||||
def result = map ? createEvent(map) : null
|
||||
|
||||
@@ -248,6 +241,8 @@ private Map getBatteryResult(rawValue) {
|
||||
def maxVolts = 3.0
|
||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||
def roundedPct = Math.round(pct * 100)
|
||||
if (roundedPct <= 0)
|
||||
roundedPct = 1
|
||||
result.value = Math.min(100, roundedPct)
|
||||
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
||||
}
|
||||
@@ -294,15 +289,7 @@ private Map getMotionResult(value) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -316,24 +303,19 @@ def refresh() {
|
||||
}
|
||||
|
||||
def configure() {
|
||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
|
||||
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
||||
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
||||
|
||||
def configCmds = [
|
||||
def enrollCmds = [
|
||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||
"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() {
|
||||
|
||||
@@ -206,6 +206,8 @@ private Map getBatteryResult(rawValue) {
|
||||
def maxVolts = 3.0
|
||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||
def roundedPct = Math.round(pct * 100)
|
||||
if (roundedPct <= 0)
|
||||
roundedPct = 1
|
||||
result.value = Math.min(100, roundedPct)
|
||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ Works with:
|
||||
|
||||
## Device Health
|
||||
|
||||
A Category C2 multi sensor with maxReportTime of 1 hr.
|
||||
Check-in interval is double the value of maxReportTime for Zigbee device.
|
||||
A Category C2 multi sensor with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 2*60 = 120 min
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## Battery Specification
|
||||
|
||||
|
||||
@@ -127,13 +127,6 @@ def parse(String 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
|
||||
|
||||
if (description?.startsWith('enroll request')) {
|
||||
@@ -313,6 +306,8 @@ private Map getBatteryResult(rawValue) {
|
||||
def maxVolts = 3.0
|
||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||
def roundedPct = Math.round(pct * 100)
|
||||
if (roundedPct <= 0)
|
||||
roundedPct = 1
|
||||
result.value = Math.min(100, roundedPct)
|
||||
result.descriptionText = "{{ device.displayName }} battery was {{ value }}%"
|
||||
}
|
||||
@@ -376,15 +371,7 @@ private getAccelerationResult(numValue) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -414,13 +401,16 @@ def refresh() {
|
||||
}
|
||||
|
||||
def configure() {
|
||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
|
||||
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() +
|
||||
zigbee.batteryConfig() +
|
||||
zigbee.temperatureConfig() +
|
||||
zigbee.temperatureConfig(30, 300) +
|
||||
zigbee.configureReporting(0xFC02, 0x0010, 0x18, 10, 3600, 0x01, [mfgCode: manufacturerCode]) +
|
||||
zigbee.configureReporting(0xFC02, 0x0012, 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 pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||
def roundedPct = Math.round(pct * 100)
|
||||
if (roundedPct <= 0)
|
||||
roundedPct = 1
|
||||
result.value = Math.min(100, roundedPct)
|
||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ Works with:
|
||||
|
||||
## 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.
|
||||
A Category C2 open/closed sensor with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 2*60 = 120 min
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## Battery Specification
|
||||
|
||||
|
||||
@@ -92,13 +92,6 @@ def parse(String 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"
|
||||
def result = map ? createEvent(map) : null
|
||||
|
||||
@@ -207,6 +200,8 @@ private Map getBatteryResult(rawValue) {
|
||||
def maxVolts = 3.0
|
||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||
def roundedPct = Math.round(pct * 100)
|
||||
if (roundedPct <= 0)
|
||||
roundedPct = 1
|
||||
result.value = Math.min(100, roundedPct)
|
||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||
}
|
||||
@@ -246,15 +241,7 @@ private Map getContactResult(value) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -268,23 +255,19 @@ def refresh() {
|
||||
}
|
||||
|
||||
def configure() {
|
||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
|
||||
String zigbeeEui = swapEndianHex(device.hub.zigbeeEui)
|
||||
log.debug "Configuring Reporting, IAS CIE, and Bindings."
|
||||
def configCmds = [
|
||||
def enrollCmds = [
|
||||
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
|
||||
"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() {
|
||||
|
||||
@@ -24,10 +24,10 @@ Works with:
|
||||
|
||||
## 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.
|
||||
A Category C2 SmartSense Temp/Humidity Sensor with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 2*60 = 120 min
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## Battery Specification
|
||||
|
||||
|
||||
@@ -83,13 +83,6 @@ def parse(String 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"
|
||||
return map ? createEvent(map) : null
|
||||
}
|
||||
@@ -214,6 +207,8 @@ private Map getBatteryResult(rawValue) {
|
||||
def maxVolts = 3.0
|
||||
def pct = (volts - minVolts) / (maxVolts - minVolts)
|
||||
def roundedPct = Math.round(pct * 100)
|
||||
if (roundedPct <= 0)
|
||||
roundedPct = 1
|
||||
result.value = Math.min(100, roundedPct)
|
||||
result.descriptionText = "${linkText} battery was ${result.value}%"
|
||||
}
|
||||
@@ -251,14 +246,7 @@ private Map getHumidityResult(value) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
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)
|
||||
}
|
||||
return zigbee.readAttribute(0x001, 0x0020) // Read the Battery Level
|
||||
}
|
||||
|
||||
def refresh()
|
||||
@@ -276,23 +264,19 @@ def refresh()
|
||||
}
|
||||
|
||||
def configure() {
|
||||
sendEvent(name: "checkInterval", value: 14400, displayed: false, data: [protocol: "zigbee"])
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
|
||||
log.debug "Configuring Reporting and Bindings."
|
||||
def configCmds = [
|
||||
"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",
|
||||
|
||||
def humidityConfigCmds = [
|
||||
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 500",
|
||||
"zcl global send-me-a-report 0xFC45 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 humidityConfigCmds + zigbee.batteryConfig() + zigbee.temperatureConfig(30, 300) + refresh() // send refresh cmds as part of config
|
||||
}
|
||||
|
||||
private hex(value) {
|
||||
|
||||
2
devicetypes/smartthings/zigbee-dimmer.src/.st-ignore
Normal file
2
devicetypes/smartthings/zigbee-dimmer.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
||||
.st-ignore
|
||||
README.md
|
||||
36
devicetypes/smartthings/zigbee-dimmer.src/README.md
Normal file
36
devicetypes/smartthings/zigbee-dimmer.src/README.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# OSRAM Lightify LED On/Off/Dim
|
||||
|
||||
|
||||
|
||||
Works with:
|
||||
|
||||
* [OSRAM Lightify LED On/Off/Dim](https://shop.smartthings.com/#!/products/osram-led-smart-bulb-on-off-dim)
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Capabilities](#capabilities)
|
||||
* [Health](#device-health)
|
||||
* [Battery](#battery-specification)
|
||||
|
||||
## Capabilities
|
||||
|
||||
* **Actuator** - represents that a Device has commands
|
||||
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||
* **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 C1 Zigbee dimmer with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## 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.
|
||||
Other troubleshooting tips are listed as follows:
|
||||
* [Troubleshooting:](https://support.smartthings.com/hc/en-us/articles/207191763-OSRAM-LIGHTIFY-LED-Smart-Connected-Light-A19-On-Off-Dim)
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
metadata {
|
||||
definition (name: "ZigBee Dimmer", namespace: "smartthings", author: "SmartThings") {
|
||||
definition (name: "ZigBee Dimmer", namespace: "smartthings", author: "SmartThings", category: "C1") {
|
||||
capability "Actuator"
|
||||
capability "Configuration"
|
||||
capability "Refresh"
|
||||
@@ -54,12 +54,6 @@ def parse(String description) {
|
||||
|
||||
def event = zigbee.getEvent(description)
|
||||
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) {}
|
||||
else {
|
||||
sendEvent(event)
|
||||
@@ -86,15 +80,7 @@ def setLevel(value) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.onOffRefresh()
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -103,7 +89,8 @@ def refresh() {
|
||||
|
||||
def configure() {
|
||||
log.debug "Configuring Reporting and Bindings."
|
||||
// Enrolls device to Device-Watch with 3 x Reporting interval 30min
|
||||
sendEvent(name: "checkInterval", value: 1800, displayed: false, data: [protocol: "zigbee"])
|
||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||
zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
}
|
||||
|
||||
2
devicetypes/smartthings/zigbee-rgbw-bulb.src/.st-ignore
Normal file
2
devicetypes/smartthings/zigbee-rgbw-bulb.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
||||
.st-ignore
|
||||
README.md
|
||||
42
devicetypes/smartthings/zigbee-rgbw-bulb.src/README.md
Normal file
42
devicetypes/smartthings/zigbee-rgbw-bulb.src/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# OSRAM LIGHTIFY LED RGBW Bulb
|
||||
|
||||
|
||||
|
||||
Works with:
|
||||
|
||||
* [OSRAM LIGHTIFY LED RGBW Bulb](https://support.smartthings.com/hc/en-us/articles/207728173-OSRAM-LIGHTIFY-LED-Smart-Connected-Light-A19-RGBW)
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Capabilities](#capabilities)
|
||||
* [Health](#device-health)
|
||||
* [Battery](#battery-specification)
|
||||
|
||||
## Capabilities
|
||||
|
||||
* **Actuator** - It represents that a device has commands.
|
||||
* **Color Control** - It represents that the color attributes of a device can be controlled (hue, saturation, color value).
|
||||
* **Color Temperature** - It represents color temperature capability measured in degree Kelvin.
|
||||
* **Polling** - It represents that a device can be polled.
|
||||
* **Switch** - can detect state (possible values: on/off)
|
||||
* **Switch Level** - can detect current light level (0-100 in percent)
|
||||
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||
* **Refresh** - _refresh()_ command for status updates
|
||||
* **Health Check** - indicates ability to get device health notifications
|
||||
|
||||
|
||||
## Device Health
|
||||
|
||||
A Category C6 OSRAM LIGHTIFY LED RGBW Bulb with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 12 mins
|
||||
|
||||
|
||||
## 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.
|
||||
It may also happen that you need to reset the device.
|
||||
Instructions related to pairing, resetting and removing the device from SmartThings can be found in the following link:
|
||||
* [Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/207728173-OSRAM-LIGHTIFY-LED-Smart-Connected-Light-A19-RGBW)
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
metadata {
|
||||
definition (name: "ZigBee RGBW Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||
definition (name: "ZigBee RGBW Bulb", namespace: "smartthings", author: "SmartThings", category: "C6") {
|
||||
|
||||
capability "Actuator"
|
||||
capability "Color Control"
|
||||
@@ -85,12 +85,6 @@ def parse(String description) {
|
||||
def event = zigbee.getEvent(description)
|
||||
if (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) {}
|
||||
else {
|
||||
if (event.name=="colorTemperature") {
|
||||
@@ -105,7 +99,7 @@ def parse(String description) {
|
||||
|
||||
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
||||
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, descriptionText: "Color has changed")
|
||||
}
|
||||
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
||||
@@ -130,15 +124,7 @@ def off() {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.onOffRefresh()
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -147,9 +133,10 @@ def refresh() {
|
||||
|
||||
def configure() {
|
||||
log.debug "Configuring Reporting and Bindings."
|
||||
// Enrolls device to Device-Watch with 3 x Reporting interval 30min
|
||||
sendEvent(name: "checkInterval", value: 1800, 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)
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
// 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) {
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.st-ignore
|
||||
README.md
|
||||
@@ -0,0 +1,37 @@
|
||||
# OSRAM Lightify Tunable 60 White
|
||||
|
||||
|
||||
|
||||
Works with:
|
||||
|
||||
* [OSRAM Lightify Tunable 60 White](http://www.osram.com/osram_com/tools-and-services/tools/lightify---smart-connected-light/lightify-for-home---what-is-light-to-you/lightify-products/lightify-classic-a60-tunable-white/index.jsp)
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Capabilities](#capabilities)
|
||||
* [Health](#device-health)
|
||||
* [Battery](#battery-specification)
|
||||
|
||||
## Capabilities
|
||||
|
||||
* **Actuator** - represents that a Device has commands
|
||||
* **Color Temperature** - represents color temperature, measured in degrees Kelvin.
|
||||
* **Configuration** - _configure()_ command called when device is installed or device preferences updated.
|
||||
* **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 C1 OSRAM Lightify Tunable 60 White with maxReportTime of 5 mins.
|
||||
Check-in interval is double the value of maxReportTime.
|
||||
This gives the device twice the amount of time to respond before it is marked as offline.
|
||||
Check-in interval = 12 mins
|
||||
|
||||
## 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.
|
||||
Other troubleshooting tips are listed as follows:
|
||||
* [Troubleshooting:](https://support.smartthings.com/hc/en-us/articles/204576454-OSRAM-LIGHTIFY-Tunable-White-60-Bulb)
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
metadata {
|
||||
definition (name: "ZigBee White Color Temperature Bulb", namespace: "smartthings", author: "SmartThings") {
|
||||
definition (name: "ZigBee White Color Temperature Bulb", namespace: "smartthings", author: "SmartThings", category: "C1") {
|
||||
|
||||
capability "Actuator"
|
||||
capability "Color Temperature"
|
||||
@@ -74,12 +74,6 @@ def parse(String description) {
|
||||
log.debug "description is $description"
|
||||
def event = zigbee.getEvent(description)
|
||||
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) {}
|
||||
else {
|
||||
if (event.name=="colorTemperature") {
|
||||
@@ -110,15 +104,7 @@ def setLevel(value) {
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
|
||||
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)
|
||||
}
|
||||
return zigbee.onOffRefresh()
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
@@ -127,9 +113,10 @@ def refresh() {
|
||||
|
||||
def configure() {
|
||||
log.debug "Configuring Reporting and Bindings."
|
||||
// Enrolls device to Device-Watch with 3 x Reporting interval 30min
|
||||
sendEvent(name: "checkInterval", value: 1800, displayed: false, data: [protocol: "zigbee"])
|
||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee"])
|
||||
// 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) {
|
||||
|
||||
@@ -0,0 +1,683 @@
|
||||
/**
|
||||
* Copyright 2015 SmartThings
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "Z-Wave Lock Reporting", namespace: "smartthings", author: "SmartThings") {
|
||||
capability "Actuator"
|
||||
capability "Lock"
|
||||
capability "Polling"
|
||||
capability "Refresh"
|
||||
capability "Sensor"
|
||||
capability "Lock Codes"
|
||||
capability "Battery"
|
||||
|
||||
command "unlockwtimeout"
|
||||
|
||||
fingerprint deviceId: "0x4003", inClusters: "0x98"
|
||||
fingerprint deviceId: "0x4004", inClusters: "0x98"
|
||||
}
|
||||
|
||||
simulator {
|
||||
status "locked": "command: 9881, payload: 00 62 03 FF 00 00 FE FE"
|
||||
status "unlocked": "command: 9881, payload: 00 62 03 00 00 00 FE FE"
|
||||
|
||||
reply "9881006201FF,delay 4200,9881006202": "command: 9881, payload: 00 62 03 FF 00 00 FE FE"
|
||||
reply "988100620100,delay 4200,9881006202": "command: 9881, payload: 00 62 03 00 00 00 FE FE"
|
||||
}
|
||||
|
||||
tiles(scale: 2) {
|
||||
multiAttributeTile(name:"toggle", type: "generic", width: 6, height: 4){
|
||||
tileAttribute ("device.lock", key: "PRIMARY_CONTROL") {
|
||||
attributeState "locked", label:'locked', action:"lock.unlock", icon:"st.locks.lock.locked", backgroundColor:"#79b821", nextState:"unlocking"
|
||||
attributeState "unlocked", label:'unlocked', action:"lock.lock", icon:"st.locks.lock.unlocked", backgroundColor:"#ffffff", nextState:"locking"
|
||||
attributeState "unknown", label:"unknown", action:"lock.lock", icon:"st.locks.lock.unknown", backgroundColor:"#ffffff", nextState:"locking"
|
||||
attributeState "locking", label:'locking', icon:"st.locks.lock.locked", backgroundColor:"#79b821"
|
||||
attributeState "unlocking", label:'unlocking', icon:"st.locks.lock.unlocked", backgroundColor:"#ffffff"
|
||||
}
|
||||
}
|
||||
standardTile("lock", "device.lock", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:'lock', action:"lock.lock", icon:"st.locks.lock.locked", nextState:"locking"
|
||||
}
|
||||
standardTile("unlock", "device.lock", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:'unlock', action:"lock.unlock", icon:"st.locks.lock.unlocked", nextState:"unlocking"
|
||||
}
|
||||
valueTile("battery", "device.battery", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "battery", label:'${currentValue}% battery', unit:""
|
||||
}
|
||||
standardTile("refresh", "device.lock", inactiveLabel: false, decoration: "flat", width: 2, height: 2) {
|
||||
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||
}
|
||||
|
||||
main "toggle"
|
||||
details(["toggle", "lock", "unlock", "battery", "refresh"])
|
||||
}
|
||||
}
|
||||
|
||||
import physicalgraph.zwave.commands.doorlockv1.*
|
||||
import physicalgraph.zwave.commands.usercodev1.*
|
||||
|
||||
def updated() {
|
||||
try {
|
||||
if (!state.init) {
|
||||
state.init = true
|
||||
response(secureSequence([zwave.doorLockV1.doorLockOperationGet(), zwave.batteryV1.batteryGet()]))
|
||||
}
|
||||
} catch (e) {
|
||||
log.warn "updated() threw $e"
|
||||
}
|
||||
}
|
||||
|
||||
def parse(String description) {
|
||||
def result = null
|
||||
if (description.startsWith("Err 106")) {
|
||||
if (state.sec) {
|
||||
result = createEvent(descriptionText:description, displayed:false)
|
||||
} else {
|
||||
result = createEvent(
|
||||
descriptionText: "This lock failed to complete the network security key exchange. If you are unable to control it via SmartThings, you must remove it from your network and add it again.",
|
||||
eventType: "ALERT",
|
||||
name: "secureInclusion",
|
||||
value: "failed",
|
||||
displayed: true,
|
||||
)
|
||||
}
|
||||
} else if (description == "updated") {
|
||||
return null
|
||||
} else {
|
||||
def cmd = zwave.parse(description, [ 0x98: 1, 0x72: 2, 0x85: 2, 0x86: 1 ])
|
||||
if (cmd) {
|
||||
result = zwaveEvent(cmd)
|
||||
}
|
||||
}
|
||||
log.debug "\"$description\" parsed to ${result.inspect()}"
|
||||
result
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityMessageEncapsulation cmd) {
|
||||
def encapsulatedCommand = cmd.encapsulatedCommand([0x62: 1, 0x71: 2, 0x80: 1, 0x85: 2, 0x63: 1, 0x98: 1, 0x86: 1])
|
||||
// log.debug "encapsulated: $encapsulatedCommand"
|
||||
if (encapsulatedCommand) {
|
||||
zwaveEvent(encapsulatedCommand)
|
||||
}
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.securityv1.NetworkKeyVerify cmd) {
|
||||
createEvent(name:"secureInclusion", value:"success", descriptionText:"Secure inclusion was successful")
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.securityv1.SecurityCommandsSupportedReport cmd) {
|
||||
state.sec = cmd.commandClassSupport.collect { String.format("%02X ", it) }.join()
|
||||
if (cmd.commandClassControl) {
|
||||
state.secCon = cmd.commandClassControl.collect { String.format("%02X ", it) }.join()
|
||||
}
|
||||
log.debug "Security command classes: $state.sec"
|
||||
createEvent(name:"secureInclusion", value:"success", descriptionText:"Lock is securely included")
|
||||
}
|
||||
|
||||
def zwaveEvent(DoorLockOperationReport cmd) {
|
||||
def result = []
|
||||
def map = [ name: "lock" ]
|
||||
if (cmd.doorLockMode == 0xFF) {
|
||||
map.value = "locked"
|
||||
} else if (cmd.doorLockMode >= 0x40) {
|
||||
map.value = "unknown"
|
||||
} else if (cmd.doorLockMode & 1) {
|
||||
map.value = "unlocked with timeout"
|
||||
} else {
|
||||
map.value = "unlocked"
|
||||
if (state.assoc != zwaveHubNodeId) {
|
||||
log.debug "setting association"
|
||||
result << response(secure(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId)))
|
||||
result << response(zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId))
|
||||
result << response(secure(zwave.associationV1.associationGet(groupingIdentifier:1)))
|
||||
}
|
||||
}
|
||||
result ? [createEvent(map), *result] : createEvent(map)
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.alarmv2.AlarmReport cmd) {
|
||||
def result = []
|
||||
def map = null
|
||||
if (cmd.zwaveAlarmType == 6) {
|
||||
if (1 <= cmd.zwaveAlarmEvent && cmd.zwaveAlarmEvent < 10) {
|
||||
map = [ name: "lock", value: (cmd.zwaveAlarmEvent & 1) ? "locked" : "unlocked" ]
|
||||
}
|
||||
switch(cmd.zwaveAlarmEvent) {
|
||||
case 1:
|
||||
map.descriptionText = "$device.displayName was manually locked"
|
||||
break
|
||||
case 2:
|
||||
map.descriptionText = "$device.displayName was manually unlocked"
|
||||
break
|
||||
case 5:
|
||||
if (cmd.eventParameter) {
|
||||
map.descriptionText = "$device.displayName was locked with code ${cmd.eventParameter.first()}"
|
||||
map.data = [ usedCode: cmd.eventParameter[0] ]
|
||||
}
|
||||
break
|
||||
case 6:
|
||||
if (cmd.eventParameter) {
|
||||
map.descriptionText = "$device.displayName was unlocked with code ${cmd.eventParameter.first()}"
|
||||
map.data = [ usedCode: cmd.eventParameter[0] ]
|
||||
}
|
||||
break
|
||||
case 9:
|
||||
map.descriptionText = "$device.displayName was autolocked"
|
||||
break
|
||||
case 7:
|
||||
case 8:
|
||||
case 0xA:
|
||||
map = [ name: "lock", value: "unknown", descriptionText: "$device.displayName was not locked fully" ]
|
||||
break
|
||||
case 0xB:
|
||||
map = [ name: "lock", value: "unknown", descriptionText: "$device.displayName is jammed" ]
|
||||
break
|
||||
case 0xC:
|
||||
map = [ name: "codeChanged", value: "all", descriptionText: "$device.displayName: all user codes deleted", isStateChange: true ]
|
||||
allCodesDeleted()
|
||||
break
|
||||
case 0xD:
|
||||
if (cmd.eventParameter) {
|
||||
map = [ name: "codeReport", value: cmd.eventParameter[0], data: [ code: "" ], isStateChange: true ]
|
||||
map.descriptionText = "$device.displayName code ${map.value} was deleted"
|
||||
map.isStateChange = (state["code$map.value"] != "")
|
||||
state["code$map.value"] = ""
|
||||
} else {
|
||||
map = [ name: "codeChanged", descriptionText: "$device.displayName: user code deleted", isStateChange: true ]
|
||||
}
|
||||
break
|
||||
case 0xE:
|
||||
map = [ name: "codeChanged", value: cmd.alarmLevel, descriptionText: "$device.displayName: user code added", isStateChange: true ]
|
||||
if (cmd.eventParameter) {
|
||||
map.value = cmd.eventParameter[0]
|
||||
result << response(requestCode(cmd.eventParameter[0]))
|
||||
}
|
||||
break
|
||||
case 0xF:
|
||||
map = [ name: "codeChanged", descriptionText: "$device.displayName: user code not added, duplicate", isStateChange: true ]
|
||||
break
|
||||
case 0x10:
|
||||
map = [ name: "tamper", value: "detected", descriptionText: "$device.displayName: keypad temporarily disabled", displayed: true ]
|
||||
break
|
||||
case 0x11:
|
||||
map = [ descriptionText: "$device.displayName: keypad is busy" ]
|
||||
break
|
||||
case 0x12:
|
||||
map = [ name: "codeChanged", descriptionText: "$device.displayName: program code changed", isStateChange: true ]
|
||||
break
|
||||
case 0x13:
|
||||
map = [ name: "tamper", value: "detected", descriptionText: "$device.displayName: code entry attempt limit exceeded", displayed: true ]
|
||||
break
|
||||
default:
|
||||
map = map ?: [ descriptionText: "$device.displayName: alarm event $cmd.zwaveAlarmEvent", displayed: false ]
|
||||
break
|
||||
}
|
||||
} else if (cmd.zwaveAlarmType == 7) {
|
||||
map = [ name: "tamper", value: "detected", displayed: true ]
|
||||
switch (cmd.zwaveAlarmEvent) {
|
||||
case 0:
|
||||
map.value = "clear"
|
||||
map.descriptionText = "$device.displayName: tamper alert cleared"
|
||||
break
|
||||
case 1:
|
||||
case 2:
|
||||
map.descriptionText = "$device.displayName: intrusion attempt detected"
|
||||
break
|
||||
case 3:
|
||||
map.descriptionText = "$device.displayName: covering removed"
|
||||
break
|
||||
case 4:
|
||||
map.descriptionText = "$device.displayName: invalid code"
|
||||
break
|
||||
default:
|
||||
map.descriptionText = "$device.displayName: tamper alarm $cmd.zwaveAlarmEvent"
|
||||
break
|
||||
}
|
||||
} else switch(cmd.alarmType) {
|
||||
case 21: // Manually locked
|
||||
case 18: // Locked with keypad
|
||||
case 24: // Locked by command (Kwikset 914)
|
||||
case 27: // Autolocked
|
||||
map = [ name: "lock", value: "locked" ]
|
||||
break
|
||||
case 16: // Note: for levers this means it's unlocked, for non-motorized deadbolt, it's just unsecured and might not get unlocked
|
||||
case 19:
|
||||
map = [ name: "lock", value: "unlocked" ]
|
||||
if (cmd.alarmLevel) {
|
||||
map.descriptionText = "$device.displayName was unlocked with code $cmd.alarmLevel"
|
||||
map.data = [ usedCode: cmd.alarmLevel ]
|
||||
}
|
||||
break
|
||||
case 22:
|
||||
case 25: // Kwikset 914 unlocked by command
|
||||
map = [ name: "lock", value: "unlocked" ]
|
||||
break
|
||||
case 9:
|
||||
case 17:
|
||||
case 23:
|
||||
case 26:
|
||||
map = [ name: "lock", value: "unknown", descriptionText: "$device.displayName bolt is jammed" ]
|
||||
break
|
||||
case 13:
|
||||
map = [ name: "codeChanged", value: cmd.alarmLevel, descriptionText: "$device.displayName code $cmd.alarmLevel was added", isStateChange: true ]
|
||||
result << response(requestCode(cmd.alarmLevel))
|
||||
break
|
||||
case 32:
|
||||
map = [ name: "codeChanged", value: "all", descriptionText: "$device.displayName: all user codes deleted", isStateChange: true ]
|
||||
allCodesDeleted()
|
||||
break
|
||||
case 33:
|
||||
map = [ name: "codeReport", value: cmd.alarmLevel, data: [ code: "" ], isStateChange: true ]
|
||||
map.descriptionText = "$device.displayName code $cmd.alarmLevel was deleted"
|
||||
map.isStateChange = (state["code$cmd.alarmLevel"] != "")
|
||||
state["code$cmd.alarmLevel"] = ""
|
||||
break
|
||||
case 112:
|
||||
map = [ name: "codeChanged", value: cmd.alarmLevel, descriptionText: "$device.displayName code $cmd.alarmLevel changed", isStateChange: true ]
|
||||
result << response(requestCode(cmd.alarmLevel))
|
||||
break
|
||||
case 130: // Yale YRD batteries replaced
|
||||
map = [ descriptionText: "$device.displayName batteries replaced", isStateChange: true ]
|
||||
break
|
||||
case 131:
|
||||
map = [ /*name: "codeChanged", value: cmd.alarmLevel,*/ descriptionText: "$device.displayName code $cmd.alarmLevel is duplicate", isStateChange: false ]
|
||||
break
|
||||
case 161:
|
||||
if (cmd.alarmLevel == 2) {
|
||||
map = [ descriptionText: "$device.displayName front escutcheon removed", isStateChange: true ]
|
||||
} else {
|
||||
map = [ descriptionText: "$device.displayName detected failed user code attempt", isStateChange: true ]
|
||||
}
|
||||
break
|
||||
case 167:
|
||||
if (!state.lastbatt || now() - state.lastbatt > 12*60*60*1000) {
|
||||
map = [ descriptionText: "$device.displayName: battery low", isStateChange: true ]
|
||||
result << response(secure(zwave.batteryV1.batteryGet()))
|
||||
} else {
|
||||
map = [ name: "battery", value: device.currentValue("battery"), descriptionText: "$device.displayName: battery low", displayed: true ]
|
||||
}
|
||||
break
|
||||
case 168:
|
||||
map = [ name: "battery", value: 1, descriptionText: "$device.displayName: battery level critical", displayed: true ]
|
||||
break
|
||||
case 169:
|
||||
map = [ name: "battery", value: 0, descriptionText: "$device.displayName: battery too low to operate lock", isStateChange: true ]
|
||||
break
|
||||
default:
|
||||
map = [ displayed: false, descriptionText: "$device.displayName: alarm event $cmd.alarmType level $cmd.alarmLevel" ]
|
||||
break
|
||||
}
|
||||
result ? [createEvent(map), *result] : createEvent(map)
|
||||
}
|
||||
|
||||
def zwaveEvent(UserCodeReport cmd) {
|
||||
def result = []
|
||||
def name = "code$cmd.userIdentifier"
|
||||
def code = cmd.code
|
||||
def map = [:]
|
||||
if (cmd.userIdStatus == UserCodeReport.USER_ID_STATUS_OCCUPIED ||
|
||||
(cmd.userIdStatus == UserCodeReport.USER_ID_STATUS_STATUS_NOT_AVAILABLE && cmd.user && code != "**********"))
|
||||
{
|
||||
if (code == "**********") { // Schlage locks send us this instead of the real code
|
||||
state.blankcodes = true
|
||||
code = state["set$name"] ?: decrypt(state[name]) ?: code
|
||||
state.remove("set$name".toString())
|
||||
}
|
||||
if (!code && cmd.userIdStatus == 1) { // Schlage touchscreen sends blank code to notify of a changed code
|
||||
map = [ name: "codeChanged", value: cmd.userIdentifier, displayed: true, isStateChange: true ]
|
||||
map.descriptionText = "$device.displayName code $cmd.userIdentifier " + (state[name] ? "changed" : "was added")
|
||||
code = state["set$name"] ?: decrypt(state[name]) ?: "****"
|
||||
state.remove("set$name".toString())
|
||||
} else {
|
||||
map = [ name: "codeReport", value: cmd.userIdentifier, data: [ code: code ] ]
|
||||
map.descriptionText = "$device.displayName code $cmd.userIdentifier is set"
|
||||
map.displayed = (cmd.userIdentifier != state.requestCode && cmd.userIdentifier != state.pollCode)
|
||||
map.isStateChange = true
|
||||
}
|
||||
result << createEvent(map)
|
||||
} else {
|
||||
map = [ name: "codeReport", value: cmd.userIdentifier, data: [ code: "" ] ]
|
||||
if (state.blankcodes && state["reset$name"]) { // we deleted this code so we can tell that our new code gets set
|
||||
map.descriptionText = "$device.displayName code $cmd.userIdentifier was reset"
|
||||
map.displayed = map.isStateChange = true
|
||||
result << createEvent(map)
|
||||
state["set$name"] = state["reset$name"]
|
||||
result << response(setCode(cmd.userIdentifier, state["reset$name"]))
|
||||
state.remove("reset$name".toString())
|
||||
} else {
|
||||
if (state[name]) {
|
||||
map.descriptionText = "$device.displayName code $cmd.userIdentifier was deleted"
|
||||
} else {
|
||||
map.descriptionText = "$device.displayName code $cmd.userIdentifier is not set"
|
||||
}
|
||||
map.displayed = (cmd.userIdentifier != state.requestCode && cmd.userIdentifier != state.pollCode)
|
||||
map.isStateChange = true
|
||||
result << createEvent(map)
|
||||
}
|
||||
code = ""
|
||||
}
|
||||
state[name] = code ? encrypt(code) : code
|
||||
|
||||
if (cmd.userIdentifier == state.requestCode) { // reloadCodes() was called, keep requesting the codes in order
|
||||
if (state.requestCode + 1 > state.codes || state.requestCode >= 30) {
|
||||
state.remove("requestCode") // done
|
||||
} else {
|
||||
state.requestCode = state.requestCode + 1 // get next
|
||||
result << response(requestCode(state.requestCode))
|
||||
}
|
||||
}
|
||||
if (cmd.userIdentifier == state.pollCode) {
|
||||
if (state.pollCode + 1 > state.codes || state.pollCode >= 30) {
|
||||
state.remove("pollCode") // done
|
||||
} else {
|
||||
state.pollCode = state.pollCode + 1
|
||||
}
|
||||
}
|
||||
log.debug "code report parsed to ${result.inspect()}"
|
||||
result
|
||||
}
|
||||
|
||||
def zwaveEvent(UsersNumberReport cmd) {
|
||||
def result = []
|
||||
state.codes = cmd.supportedUsers
|
||||
if (state.requestCode && state.requestCode <= cmd.supportedUsers) {
|
||||
result << response(requestCode(state.requestCode))
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.associationv2.AssociationReport cmd) {
|
||||
def result = []
|
||||
if (cmd.nodeId.any { it == zwaveHubNodeId }) {
|
||||
state.remove("associationQuery")
|
||||
log.debug "$device.displayName is associated to $zwaveHubNodeId"
|
||||
result << createEvent(descriptionText: "$device.displayName is associated")
|
||||
state.assoc = zwaveHubNodeId
|
||||
if (cmd.groupingIdentifier == 2) {
|
||||
result << response(zwave.associationV1.associationRemove(groupingIdentifier:1, nodeId:zwaveHubNodeId))
|
||||
}
|
||||
} else if (cmd.groupingIdentifier == 1) {
|
||||
result << response(secure(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId)))
|
||||
} else if (cmd.groupingIdentifier == 2) {
|
||||
result << response(zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId))
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.timev1.TimeGet cmd) {
|
||||
def result = []
|
||||
def now = new Date().toCalendar()
|
||||
if(location.timeZone) now.timeZone = location.timeZone
|
||||
result << createEvent(descriptionText: "$device.displayName requested time update", displayed: false)
|
||||
result << response(secure(zwave.timeV1.timeReport(
|
||||
hourLocalTime: now.get(Calendar.HOUR_OF_DAY),
|
||||
minuteLocalTime: now.get(Calendar.MINUTE),
|
||||
secondLocalTime: now.get(Calendar.SECOND)))
|
||||
)
|
||||
result
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicSet cmd) {
|
||||
// The old Schlage locks use group 1 for basic control - we don't want that, so unsubscribe from group 1
|
||||
def result = [ createEvent(name: "lock", value: cmd.value ? "unlocked" : "locked") ]
|
||||
result << response(zwave.associationV1.associationRemove(groupingIdentifier:1, nodeId:zwaveHubNodeId))
|
||||
if (state.assoc != zwaveHubNodeId) {
|
||||
result << response(zwave.associationV1.associationGet(groupingIdentifier:2))
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.batteryv1.BatteryReport cmd) {
|
||||
def map = [ name: "battery", unit: "%" ]
|
||||
if (cmd.batteryLevel == 0xFF) {
|
||||
map.value = 1
|
||||
map.descriptionText = "$device.displayName has a low battery"
|
||||
} else {
|
||||
map.value = cmd.batteryLevel
|
||||
}
|
||||
state.lastbatt = now()
|
||||
createEvent(map)
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) {
|
||||
def result = []
|
||||
|
||||
def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId)
|
||||
log.debug "msr: $msr"
|
||||
updateDataValue("MSR", msr)
|
||||
|
||||
result << createEvent(descriptionText: "$device.displayName MSR: $msr", isStateChange: false)
|
||||
result
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.versionv1.VersionReport cmd) {
|
||||
def fw = "${cmd.applicationVersion}.${cmd.applicationSubVersion}"
|
||||
updateDataValue("fw", fw)
|
||||
if (state.MSR == "003B-6341-5044") {
|
||||
updateDataValue("ver", "${cmd.applicationVersion >> 4}.${cmd.applicationVersion & 0xF}")
|
||||
}
|
||||
def text = "$device.displayName: firmware version: $fw, Z-Wave version: ${cmd.zWaveProtocolVersion}.${cmd.zWaveProtocolSubVersion}"
|
||||
createEvent(descriptionText: text, isStateChange: false)
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.applicationstatusv1.ApplicationBusy cmd) {
|
||||
def msg = cmd.status == 0 ? "try again later" :
|
||||
cmd.status == 1 ? "try again in $cmd.waitTime seconds" :
|
||||
cmd.status == 2 ? "request queued" : "sorry"
|
||||
createEvent(displayed: true, descriptionText: "$device.displayName is busy, $msg")
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.commands.applicationstatusv1.ApplicationRejectedRequest cmd) {
|
||||
createEvent(displayed: true, descriptionText: "$device.displayName rejected the last request")
|
||||
}
|
||||
|
||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||
createEvent(displayed: false, descriptionText: "$device.displayName: $cmd")
|
||||
}
|
||||
|
||||
def lockAndCheck(doorLockMode) {
|
||||
secureSequence([
|
||||
zwave.doorLockV1.doorLockOperationSet(doorLockMode: doorLockMode),
|
||||
zwave.doorLockV1.doorLockOperationGet()
|
||||
], 4200)
|
||||
}
|
||||
|
||||
def lock() {
|
||||
lockAndCheck(DoorLockOperationSet.DOOR_LOCK_MODE_DOOR_SECURED)
|
||||
}
|
||||
|
||||
def unlock() {
|
||||
lockAndCheck(DoorLockOperationSet.DOOR_LOCK_MODE_DOOR_UNSECURED)
|
||||
}
|
||||
|
||||
def unlockwtimeout() {
|
||||
lockAndCheck(DoorLockOperationSet.DOOR_LOCK_MODE_DOOR_UNSECURED_WITH_TIMEOUT)
|
||||
}
|
||||
|
||||
def refresh() {
|
||||
def cmds = [secure(zwave.doorLockV1.doorLockOperationGet())]
|
||||
if (state.assoc == zwaveHubNodeId) {
|
||||
log.debug "$device.displayName is associated to ${state.assoc}"
|
||||
} else if (!state.associationQuery) {
|
||||
log.debug "checking association"
|
||||
cmds << "delay 4200"
|
||||
cmds << zwave.associationV1.associationGet(groupingIdentifier:2).format() // old Schlage locks use group 2 and don't secure the Association CC
|
||||
cmds << secure(zwave.associationV1.associationGet(groupingIdentifier:1))
|
||||
state.associationQuery = now()
|
||||
} else if (secondsPast(state.associationQuery, 9)) {
|
||||
cmds << "delay 6000"
|
||||
cmds << zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:zwaveHubNodeId).format()
|
||||
cmds << secure(zwave.associationV1.associationSet(groupingIdentifier:1, nodeId:zwaveHubNodeId))
|
||||
cmds << zwave.associationV1.associationGet(groupingIdentifier:2).format()
|
||||
cmds << secure(zwave.associationV1.associationGet(groupingIdentifier:1))
|
||||
state.associationQuery = now()
|
||||
}
|
||||
log.debug "refresh sending ${cmds.inspect()}"
|
||||
cmds
|
||||
}
|
||||
|
||||
def poll() {
|
||||
def cmds = []
|
||||
// Only check lock state if it changed recently or we haven't had an update in an hour
|
||||
def latest = device.currentState("lock")?.date?.time
|
||||
if (!latest || !secondsPast(latest, 6 * 60) || secondsPast(state.lastPoll, 55 * 60)) {
|
||||
cmds << secure(zwave.doorLockV1.doorLockOperationGet())
|
||||
state.lastPoll = now()
|
||||
} else if (!state.lastbatt || now() - state.lastbatt > 53*60*60*1000) {
|
||||
cmds << secure(zwave.batteryV1.batteryGet())
|
||||
state.lastbatt = now() //inside-214
|
||||
}
|
||||
if (cmds) {
|
||||
log.debug "poll is sending ${cmds.inspect()}"
|
||||
cmds
|
||||
} else {
|
||||
// workaround to keep polling from stopping due to lack of activity
|
||||
sendEvent(descriptionText: "skipping poll", isStateChange: true, displayed: false)
|
||||
null
|
||||
}
|
||||
|
||||
reportAllCodes(state)
|
||||
}
|
||||
|
||||
def requestCode(codeNumber) {
|
||||
secure(zwave.userCodeV1.userCodeGet(userIdentifier: codeNumber))
|
||||
}
|
||||
|
||||
def reloadAllCodes() {
|
||||
def cmds = []
|
||||
if (!state.codes) {
|
||||
state.requestCode = 1
|
||||
cmds << secure(zwave.userCodeV1.usersNumberGet())
|
||||
} else {
|
||||
if(!state.requestCode) state.requestCode = 1
|
||||
cmds << requestCode(codeNumber)
|
||||
}
|
||||
cmds
|
||||
}
|
||||
|
||||
def setCode(codeNumber, code) {
|
||||
def strcode = code
|
||||
log.debug "setting code $codeNumber to $code"
|
||||
if (code instanceof String) {
|
||||
code = code.toList().findResults { if(it > ' ' && it != ',' && it != '-') it.toCharacter() as Short }
|
||||
} else {
|
||||
strcode = code.collect{ it as Character }.join()
|
||||
}
|
||||
if (state.blankcodes) {
|
||||
// Can't just set, we won't be able to tell if it was successful
|
||||
if (state["code$codeNumber"] != "") {
|
||||
if (state["setcode$codeNumber"] != strcode) {
|
||||
state["resetcode$codeNumber"] = strcode
|
||||
return deleteCode(codeNumber)
|
||||
}
|
||||
} else {
|
||||
state["setcode$codeNumber"] = strcode
|
||||
}
|
||||
}
|
||||
secureSequence([
|
||||
zwave.userCodeV1.userCodeSet(userIdentifier:codeNumber, userIdStatus:1, user:code),
|
||||
zwave.userCodeV1.userCodeGet(userIdentifier:codeNumber)
|
||||
], 7000)
|
||||
}
|
||||
|
||||
def deleteCode(codeNumber) {
|
||||
log.debug "deleting code $codeNumber"
|
||||
secureSequence([
|
||||
zwave.userCodeV1.userCodeSet(userIdentifier:codeNumber, userIdStatus:0),
|
||||
zwave.userCodeV1.userCodeGet(userIdentifier:codeNumber)
|
||||
], 7000)
|
||||
}
|
||||
|
||||
def updateCodes(codeSettings) {
|
||||
if(codeSettings instanceof String) codeSettings = util.parseJson(codeSettings)
|
||||
def set_cmds = []
|
||||
def get_cmds = []
|
||||
codeSettings.each { name, updated ->
|
||||
def current = decrypt(state[name])
|
||||
if (name.startsWith("code")) {
|
||||
def n = name[4..-1].toInteger()
|
||||
log.debug "$name was $current, set to $updated"
|
||||
if (updated?.size() >= 4 && updated != current) {
|
||||
def cmds = setCode(n, updated)
|
||||
set_cmds << cmds.first()
|
||||
get_cmds << cmds.last()
|
||||
} else if ((current && updated == "") || updated == "0") {
|
||||
def cmds = deleteCode(n)
|
||||
set_cmds << cmds.first()
|
||||
get_cmds << cmds.last()
|
||||
} else if (updated && updated.size() < 4) {
|
||||
// Entered code was too short
|
||||
codeSettings["code$n"] = current
|
||||
}
|
||||
} else log.warn("unexpected entry $name: $updated")
|
||||
}
|
||||
if (set_cmds) {
|
||||
return response(delayBetween(set_cmds, 2200) + ["delay 2200"] + delayBetween(get_cmds, 4200))
|
||||
}
|
||||
}
|
||||
|
||||
def getCode(codeNumber) {
|
||||
decrypt(state["code$codeNumber"])
|
||||
}
|
||||
|
||||
def getAllCodes() {
|
||||
state.findAll { it.key.startsWith 'code' }.collectEntries {
|
||||
[it.key, (it.value instanceof String && it.value.startsWith("~")) ? decrypt(it.value) : it.value]
|
||||
}
|
||||
}
|
||||
|
||||
private secure(physicalgraph.zwave.Command cmd) {
|
||||
zwave.securityV1.securityMessageEncapsulation().encapsulate(cmd).format()
|
||||
}
|
||||
|
||||
private secureSequence(commands, delay=4200) {
|
||||
delayBetween(commands.collect{ secure(it) }, delay)
|
||||
}
|
||||
|
||||
private Boolean secondsPast(timestamp, seconds) {
|
||||
if (!(timestamp instanceof Number)) {
|
||||
if (timestamp instanceof Date) {
|
||||
timestamp = timestamp.time
|
||||
} else if ((timestamp instanceof String) && timestamp.isNumber()) {
|
||||
timestamp = timestamp.toLong()
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return (now() - timestamp) > (seconds * 1000)
|
||||
}
|
||||
|
||||
private allCodesDeleted() {
|
||||
if (state.codes instanceof Integer) {
|
||||
(1..state.codes).each { n ->
|
||||
if (state["code$n"]) {
|
||||
result << createEvent(name: "codeReport", value: n, data: [ code: "" ], descriptionText: "code $n was deleted",
|
||||
displayed: false, isStateChange: true)
|
||||
}
|
||||
state["code$n"] = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def reportAllCodes(state) {
|
||||
def map = [ name: "reportAllCodes", data: [:], displayed: false, isStateChange: false, type: "physical" ]
|
||||
state.each { entry ->
|
||||
//iterate through all the state entries and add them to the event data to be handled by application event handlers
|
||||
if ( entry.key ==~ /^code\d{1,}/ && entry.value.startsWith("~") ) {
|
||||
map.data.put(entry.key, decrypt(entry.value))
|
||||
} else {
|
||||
map.data.put(entry.key, entry.value)
|
||||
}
|
||||
}
|
||||
sendEvent(map)
|
||||
}
|
||||
@@ -65,7 +65,16 @@ void updateSwitch() {
|
||||
private void updateAll(devices) {
|
||||
def command = request.JSON?.command
|
||||
if (command) {
|
||||
devices."$command"()
|
||||
switch(command) {
|
||||
case "on":
|
||||
devices.on()
|
||||
break
|
||||
case "off":
|
||||
devices.off()
|
||||
break
|
||||
default:
|
||||
httpError(403, "Access denied. This command is not supported by current capability.")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +86,16 @@ private void update(devices) {
|
||||
if (!device) {
|
||||
httpError(404, "Device not found")
|
||||
} else {
|
||||
device."$command"()
|
||||
switch(command) {
|
||||
case "on":
|
||||
device.on()
|
||||
break
|
||||
case "off":
|
||||
device.off()
|
||||
break
|
||||
default:
|
||||
httpError(403, "Access denied. This command is not supported by current capability.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ def authPage() {
|
||||
if (canInstallLabs()) {
|
||||
|
||||
def redirectUrl = getBuildRedirectUrl()
|
||||
log.debug "Redirect url = ${redirectUrl}"
|
||||
// log.debug "Redirect url = ${redirectUrl}"
|
||||
|
||||
if (state.authToken) {
|
||||
description = "Tap 'Next' to proceed"
|
||||
@@ -113,13 +113,13 @@ def oauthInitUrl() {
|
||||
scope: "read_station"
|
||||
]
|
||||
|
||||
log.debug "REDIRECT URL: ${getVendorAuthPath() + toQueryString(oauthParams)}"
|
||||
// log.debug "REDIRECT URL: ${getVendorAuthPath() + toQueryString(oauthParams)}"
|
||||
|
||||
redirect (location: getVendorAuthPath() + toQueryString(oauthParams))
|
||||
}
|
||||
|
||||
def callback() {
|
||||
log.debug "callback()>> params: $params, params.code ${params.code}"
|
||||
// log.debug "callback()>> params: $params, params.code ${params.code}"
|
||||
|
||||
def code = params.code
|
||||
def oauthState = params.state
|
||||
@@ -135,7 +135,7 @@ def callback() {
|
||||
scope: "read_station"
|
||||
]
|
||||
|
||||
log.debug "TOKEN URL: ${getVendorTokenPath() + toQueryString(tokenParams)}"
|
||||
// log.debug "TOKEN URL: ${getVendorTokenPath() + toQueryString(tokenParams)}"
|
||||
|
||||
def tokenUrl = getVendorTokenPath()
|
||||
def params = [
|
||||
@@ -144,7 +144,7 @@ def callback() {
|
||||
body: tokenParams
|
||||
]
|
||||
|
||||
log.debug "PARAMS: ${params}"
|
||||
// log.debug "PARAMS: ${params}"
|
||||
|
||||
httpPost(params) { resp ->
|
||||
|
||||
@@ -156,7 +156,7 @@ def callback() {
|
||||
state.refreshToken = data.refresh_token
|
||||
state.authToken = data.access_token
|
||||
state.tokenExpires = now() + (data.expires_in * 1000)
|
||||
log.debug "swapped token: $resp.data"
|
||||
// log.debug "swapped token: $resp.data"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ def refreshToken() {
|
||||
|
||||
response.data.each {key, value ->
|
||||
def data = slurper.parseText(key);
|
||||
log.debug "Data: $data"
|
||||
// log.debug "Data: $data"
|
||||
|
||||
state.refreshToken = data.refresh_token
|
||||
state.accessToken = data.access_token
|
||||
|
||||
1532
smartapps/ethayer/user-lock-manager.src/user-lock-manager.groovy
Normal file
1532
smartapps/ethayer/user-lock-manager.src/user-lock-manager.groovy
Normal file
File diff suppressed because it is too large
Load Diff
@@ -26,9 +26,9 @@ preferences {
|
||||
}
|
||||
|
||||
section("Temperature monitor?") {
|
||||
input "temp", "capability.temperatureMeasurement", title: "Temp Sensor", required: false
|
||||
input "maxTemp", "number", title: "Max Temp?", required: false
|
||||
input "minTemp", "number", title: "Min Temp?", required: false
|
||||
input "temp", "capability.temperatureMeasurement", title: "Temperature Sensor", required: false
|
||||
input "maxTemp", "number", title: "Max Temperature (°${location.temperatureScale})", required: false
|
||||
input "minTemp", "number", title: "Min Temperature (°${location.temperatureScale})", required: false
|
||||
}
|
||||
|
||||
section("When which people are away?") {
|
||||
|
||||
@@ -28,7 +28,7 @@ mappings {
|
||||
path("/receivedToken") { action: [ POST: "receivedToken", GET: "receivedToken"] }
|
||||
path("/receiveToken") { action: [ POST: "receiveToken", GET: "receiveToken"] }
|
||||
path("/hookCallback") { action: [ POST: "hookEventHandler", GET: "hookEventHandler"] }
|
||||
path("/oauth/initialize") {action: [GET: "oauthInitUrl"]}
|
||||
path("/oauth/initialize") {action: [GET: "oauthInitUrl"]}
|
||||
path("/oauth/callback") { action: [ GET: "callback" ] }
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ def callback() {
|
||||
} else {
|
||||
log.warn "No authQueryString"
|
||||
}
|
||||
|
||||
|
||||
if (state.JawboneAccessToken) {
|
||||
log.debug "Access token already exists"
|
||||
setup()
|
||||
@@ -73,7 +73,7 @@ def callback() {
|
||||
|
||||
def authPage() {
|
||||
log.debug "authPage"
|
||||
def description = null
|
||||
def description = null
|
||||
if (state.JawboneAccessToken == null) {
|
||||
if (!state.accessToken) {
|
||||
log.debug "About to create access token"
|
||||
@@ -82,12 +82,13 @@ def authPage() {
|
||||
description = "Click to enter Jawbone Credentials"
|
||||
def redirectUrl = buildRedirectUrl
|
||||
log.debug "RedirectURL = ${redirectUrl}"
|
||||
def donebutton= state.JawboneAccessToken != null
|
||||
def donebutton= state.JawboneAccessToken != null
|
||||
return dynamicPage(name: "Credentials", title: "Jawbone UP", nextPage: null, uninstall: true, install: donebutton) {
|
||||
section { paragraph title: "Note:", "This device has not been officially tested and certified to “Work with SmartThings”. You can connect it to your SmartThings home but performance may vary and we will not be able to provide support or assistance." }
|
||||
section { href url:redirectUrl, style:"embedded", required:true, title:"Jawbone UP", state: hast ,description:description }
|
||||
}
|
||||
} else {
|
||||
description = "Jawbone Credentials Already Entered."
|
||||
description = "Jawbone Credentials Already Entered."
|
||||
return dynamicPage(name: "Credentials", title: "Jawbone UP", uninstall: true, install:true) {
|
||||
section { href url: buildRedirectUrl("receivedToken"), style:"embedded", state: "complete", title:"Jawbone UP", description:description }
|
||||
}
|
||||
@@ -107,7 +108,7 @@ def receiveToken(redirectUrl = null) {
|
||||
def params = [
|
||||
uri: "https://jawbone.com/auth/oauth2/token?${toQueryString(oauthParams)}",
|
||||
]
|
||||
httpGet(params) { response ->
|
||||
httpGet(params) { response ->
|
||||
log.debug "${response.data}"
|
||||
log.debug "Setting access token to ${response.data.access_token}, refresh token to ${response.data.refresh_token}"
|
||||
state.JawboneAccessToken = response.data.access_token
|
||||
@@ -149,7 +150,7 @@ def connectionStatus(message, redirectUrl = null) {
|
||||
<meta http-equiv="refresh" content="3; url=${redirectUrl}" />
|
||||
"""
|
||||
}
|
||||
|
||||
|
||||
def html = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -229,12 +230,12 @@ def validateCurrentToken() {
|
||||
log.debug "validateCurrentToken"
|
||||
def url = "https://jawbone.com/nudge/api/v.1.1/users/@me/refreshToken"
|
||||
def requestBody = "secret=${appSettings.clientSecret}"
|
||||
|
||||
|
||||
try {
|
||||
httpPost(uri: url, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ], body: requestBody) {response ->
|
||||
if (response.status == 200) {
|
||||
log.debug "${response.data}"
|
||||
log.debug "Setting refresh token to ${response.data.data.refresh_token}"
|
||||
log.debug "Setting refresh token"
|
||||
state.refreshToken = response.data.data.refresh_token
|
||||
}
|
||||
}
|
||||
@@ -258,7 +259,7 @@ def validateCurrentToken() {
|
||||
state.remove("refreshToken")
|
||||
}
|
||||
} else {
|
||||
log.debug "Setting access token to ${data.access_token}, refresh token to ${data.refresh_token}"
|
||||
log.debug "Setting access token"
|
||||
state.JawboneAccessToken = data.access_token
|
||||
state.refreshToken = data.refresh_token
|
||||
}
|
||||
@@ -271,10 +272,10 @@ def validateCurrentToken() {
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
log.debug "Callback URL - Webhook"
|
||||
def localServerUrl = getApiServerUrl()
|
||||
log.debug "Callback URL - Webhook"
|
||||
def localServerUrl = getApiServerUrl()
|
||||
def hookUrl = "${localServerUrl}/api/token/${state.accessToken}/smartapps/installations/${app.id}/hookCallback"
|
||||
def webhook = "https://jawbone.com/nudge/api/v.1.1/users/@me/pubsub?webhook=$hookUrl"
|
||||
def webhook = "https://jawbone.com/nudge/api/v.1.1/users/@me/pubsub?webhook=$hookUrl"
|
||||
httpPost(uri: webhook, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ])
|
||||
}
|
||||
|
||||
@@ -284,16 +285,16 @@ def setup() {
|
||||
|
||||
if (state.JawboneAccessToken) {
|
||||
def urlmember = "https://jawbone.com/nudge/api/users/@me/"
|
||||
def member = null
|
||||
httpGet(uri: urlmember, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
def member = null
|
||||
httpGet(uri: urlmember, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
member = response.data.data
|
||||
}
|
||||
|
||||
|
||||
if (member) {
|
||||
state.member = member
|
||||
def externalId = "${app.id}.${member.xid}"
|
||||
|
||||
// find the appropriate child device based on my app id and the device network id
|
||||
// find the appropriate child device based on my app id and the device network id
|
||||
def deviceWrapper = getChildDevice("${externalId}")
|
||||
|
||||
// invoke the generatePresenceEvent method on the child device
|
||||
@@ -312,7 +313,7 @@ def setup() {
|
||||
}
|
||||
|
||||
def installed() {
|
||||
|
||||
|
||||
if (!state.accessToken) {
|
||||
log.debug "About to create access token"
|
||||
createAccessToken()
|
||||
@@ -324,7 +325,7 @@ def installed() {
|
||||
}
|
||||
|
||||
def updated() {
|
||||
|
||||
|
||||
if (!state.accessToken) {
|
||||
log.debug "About to create access token"
|
||||
createAccessToken()
|
||||
@@ -348,29 +349,29 @@ def uninstalled() {
|
||||
}
|
||||
|
||||
def pollChild(childDevice) {
|
||||
def member = state.member
|
||||
generatePollingEvents (member, childDevice)
|
||||
def member = state.member
|
||||
generatePollingEvents (member, childDevice)
|
||||
}
|
||||
|
||||
def generatePollingEvents (member, childDevice) {
|
||||
// lets figure out if the member is currently "home" (At the place)
|
||||
def urlgoals = "https://jawbone.com/nudge/api/users/@me/goals"
|
||||
def urlmoves = "https://jawbone.com/nudge/api/users/@me/moves"
|
||||
def urlsleeps = "https://jawbone.com/nudge/api/users/@me/sleeps"
|
||||
def urlgoals = "https://jawbone.com/nudge/api/users/@me/goals"
|
||||
def urlmoves = "https://jawbone.com/nudge/api/users/@me/moves"
|
||||
def urlsleeps = "https://jawbone.com/nudge/api/users/@me/sleeps"
|
||||
def goals = null
|
||||
def moves = null
|
||||
def sleeps = null
|
||||
httpGet(uri: urlgoals, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
def sleeps = null
|
||||
httpGet(uri: urlgoals, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
goals = response.data.data
|
||||
}
|
||||
httpGet(uri: urlmoves, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
}
|
||||
httpGet(uri: urlmoves, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
moves = response.data.data.items[0]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try { // we are going to just ignore any errors
|
||||
log.debug "Member = ${member.first}"
|
||||
log.debug "Moves Goal = ${goals.move_steps} Steps"
|
||||
log.debug "Moves = ${moves.details.steps} Steps"
|
||||
log.debug "Moves = ${moves.details.steps} Steps"
|
||||
|
||||
childDevice?.sendEvent(name:"steps", value: moves.details.steps)
|
||||
childDevice?.sendEvent(name:"goal", value: goals.move_steps)
|
||||
@@ -378,29 +379,29 @@ def generatePollingEvents (member, childDevice) {
|
||||
}
|
||||
catch (e) {
|
||||
// eat it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def generateInitialEvent (member, childDevice) {
|
||||
// lets figure out if the member is currently "home" (At the place)
|
||||
def urlgoals = "https://jawbone.com/nudge/api/users/@me/goals"
|
||||
def urlmoves = "https://jawbone.com/nudge/api/users/@me/moves"
|
||||
def urlsleeps = "https://jawbone.com/nudge/api/users/@me/sleeps"
|
||||
def urlgoals = "https://jawbone.com/nudge/api/users/@me/goals"
|
||||
def urlmoves = "https://jawbone.com/nudge/api/users/@me/moves"
|
||||
def urlsleeps = "https://jawbone.com/nudge/api/users/@me/sleeps"
|
||||
def goals = null
|
||||
def moves = null
|
||||
def sleeps = null
|
||||
httpGet(uri: urlgoals, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
def sleeps = null
|
||||
httpGet(uri: urlgoals, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
goals = response.data.data
|
||||
}
|
||||
httpGet(uri: urlmoves, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
}
|
||||
httpGet(uri: urlmoves, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
moves = response.data.data.items[0]
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try { // we are going to just ignore any errors
|
||||
log.debug "Member = ${member.first}"
|
||||
log.debug "Moves Goal = ${goals.move_steps} Steps"
|
||||
log.debug "Moves = ${moves.details.steps} Steps"
|
||||
log.debug "Sleeping state = false"
|
||||
log.debug "Sleeping state = false"
|
||||
childDevice?.generateSleepingEvent(false)
|
||||
childDevice?.sendEvent(name:"steps", value: moves.details.steps)
|
||||
childDevice?.sendEvent(name:"goal", value: goals.move_steps)
|
||||
@@ -408,27 +409,27 @@ def generateInitialEvent (member, childDevice) {
|
||||
}
|
||||
catch (e) {
|
||||
// eat it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def setColor (steps,goal,childDevice) {
|
||||
def result = steps * 100 / goal
|
||||
if (result < 25)
|
||||
if (result < 25)
|
||||
childDevice?.sendEvent(name:"steps", value: "steps", label: steps)
|
||||
else if ((result >= 25) && (result < 50))
|
||||
else if ((result >= 25) && (result < 50))
|
||||
childDevice?.sendEvent(name:"steps", value: "steps1", label: steps)
|
||||
else if ((result >= 50) && (result < 75))
|
||||
else if ((result >= 50) && (result < 75))
|
||||
childDevice?.sendEvent(name:"steps", value: "steps1", label: steps)
|
||||
else if (result >= 75)
|
||||
childDevice?.sendEvent(name:"steps", value: "stepsgoal", label: steps)
|
||||
else if (result >= 75)
|
||||
childDevice?.sendEvent(name:"steps", value: "stepsgoal", label: steps)
|
||||
}
|
||||
|
||||
def hookEventHandler() {
|
||||
// log.debug "In hookEventHandler method."
|
||||
log.debug "request = ${request}"
|
||||
|
||||
def json = request.JSON
|
||||
|
||||
|
||||
def json = request.JSON
|
||||
|
||||
// get some stuff we need
|
||||
def userId = json.events.user_xid[0]
|
||||
def json_type = json.events.type[0]
|
||||
@@ -437,39 +438,39 @@ def hookEventHandler() {
|
||||
//log.debug json
|
||||
log.debug "Userid = ${userId}"
|
||||
log.debug "Notification Type: " + json_type
|
||||
log.debug "Notification Action: " + json_action
|
||||
|
||||
log.debug "Notification Action: " + json_action
|
||||
|
||||
// find the appropriate child device based on my app id and the device network id
|
||||
def externalId = "${app.id}.${userId}"
|
||||
def childDevice = getChildDevice("${externalId}")
|
||||
|
||||
|
||||
if (childDevice) {
|
||||
switch (json_action) {
|
||||
case "enter_sleep_mode":
|
||||
childDevice?.generateSleepingEvent(true)
|
||||
break
|
||||
case "exit_sleep_mode":
|
||||
childDevice?.generateSleepingEvent(false)
|
||||
break
|
||||
case "creation":
|
||||
switch (json_action) {
|
||||
case "enter_sleep_mode":
|
||||
childDevice?.generateSleepingEvent(true)
|
||||
break
|
||||
case "exit_sleep_mode":
|
||||
childDevice?.generateSleepingEvent(false)
|
||||
break
|
||||
case "creation":
|
||||
childDevice?.sendEvent(name:"steps", value: 0)
|
||||
break
|
||||
case "updation":
|
||||
def urlgoals = "https://jawbone.com/nudge/api/users/@me/goals"
|
||||
def urlmoves = "https://jawbone.com/nudge/api/users/@me/moves"
|
||||
def urlgoals = "https://jawbone.com/nudge/api/users/@me/goals"
|
||||
def urlmoves = "https://jawbone.com/nudge/api/users/@me/moves"
|
||||
def goals = null
|
||||
def moves = null
|
||||
httpGet(uri: urlgoals, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
def moves = null
|
||||
httpGet(uri: urlgoals, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
goals = response.data.data
|
||||
}
|
||||
httpGet(uri: urlmoves, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
}
|
||||
httpGet(uri: urlmoves, headers: ["Authorization": "Bearer ${state.JawboneAccessToken}" ]) {response ->
|
||||
moves = response.data.data.items[0]
|
||||
}
|
||||
}
|
||||
log.debug "Goal = ${goals.move_steps} Steps"
|
||||
log.debug "Steps = ${moves.details.steps} Steps"
|
||||
log.debug "Steps = ${moves.details.steps} Steps"
|
||||
childDevice?.sendEvent(name:"steps", value: moves.details.steps)
|
||||
childDevice?.sendEvent(name:"goal", value: goals.move_steps)
|
||||
//setColor(moves.details.steps,goals.move_steps,childDevice)
|
||||
childDevice?.sendEvent(name:"goal", value: goals.move_steps)
|
||||
//setColor(moves.details.steps,goals.move_steps,childDevice)
|
||||
break
|
||||
case "deletion":
|
||||
app.delete()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
definition(
|
||||
name: "Smart Home Ventilation",
|
||||
namespace: "MichaelStruck",
|
||||
@@ -164,7 +164,7 @@ def installed() {
|
||||
def updated() {
|
||||
unschedule()
|
||||
turnOffSwitch() //Turn off all switches if the schedules are changed while in mid-schedule
|
||||
unsubscribe
|
||||
unsubscribe()
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
init()
|
||||
}
|
||||
@@ -174,12 +174,12 @@ def init() {
|
||||
schedule (midnightTime, midNight)
|
||||
subscribe(location, "mode", locationHandler)
|
||||
startProcess()
|
||||
}
|
||||
}
|
||||
|
||||
// Common methods
|
||||
|
||||
def startProcess () {
|
||||
createDayArray()
|
||||
createDayArray()
|
||||
state.dayCount=state.data.size()
|
||||
if (state.dayCount){
|
||||
state.counter = 0
|
||||
@@ -190,7 +190,7 @@ def startProcess () {
|
||||
def startDay() {
|
||||
def start = convertEpoch(state.data[state.counter].start)
|
||||
def stop = convertEpoch(state.data[state.counter].stop)
|
||||
|
||||
|
||||
runOnce(start, turnOnSwitch, [overwrite: true])
|
||||
runOnce(stop, incDay, [overwrite: true])
|
||||
}
|
||||
@@ -218,7 +218,7 @@ def locationHandler(evt) {
|
||||
}
|
||||
if (!result) {
|
||||
startProcess()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def midNight(){
|
||||
@@ -238,7 +238,7 @@ def turnOffSwitch() {
|
||||
}
|
||||
log.debug "Home ventilation switches are off."
|
||||
}
|
||||
|
||||
|
||||
def schedDesc(on1, off1, on2, off2, on3, off3, on4, off4, modeList, dayList) {
|
||||
def title = ""
|
||||
def dayListClean = "On "
|
||||
@@ -252,7 +252,7 @@ def schedDesc(on1, off1, on2, off2, on3, off3, on4, off4, modeList, dayList) {
|
||||
dayListClean = "${dayListClean}, "
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dayListClean = "Every day"
|
||||
}
|
||||
@@ -272,7 +272,7 @@ def schedDesc(on1, off1, on2, off2, on3, off3, on4, off4, modeList, dayList) {
|
||||
modeListClean = "${modeListClean} ${modePrefix}"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
modeListClean = "${modeListClean}all modes"
|
||||
}
|
||||
@@ -283,16 +283,16 @@ def schedDesc(on1, off1, on2, off2, on3, off3, on4, off4, modeList, dayList) {
|
||||
title += "\nSchedule 2: ${humanReadableTime(on2)} to ${humanReadableTime(off2)}"
|
||||
}
|
||||
if (on3 && off3) {
|
||||
title += "\nSchedule 3: ${humanReadableTime(on3)} to ${humanReadableTime(off3)}"
|
||||
title += "\nSchedule 3: ${humanReadableTime(on3)} to ${humanReadableTime(off3)}"
|
||||
}
|
||||
if (on4 && off4) {
|
||||
title += "\nSchedule 4: ${humanReadableTime(on4)} to ${humanReadableTime(off4)}"
|
||||
title += "\nSchedule 4: ${humanReadableTime(on4)} to ${humanReadableTime(off4)}"
|
||||
}
|
||||
if (on1 || on2 || on3 || on4) {
|
||||
title += "\n$modeListClean"
|
||||
title += "\n$dayListClean"
|
||||
title += "\n$dayListClean"
|
||||
}
|
||||
|
||||
|
||||
if (!on1 && !on2 && !on3 && !on4) {
|
||||
title="Click to configure scenario"
|
||||
}
|
||||
@@ -374,7 +374,7 @@ def createDayArray() {
|
||||
timeOk(timeOnD1, timeOffD1)
|
||||
timeOk(timeOnD2, timeOffD2)
|
||||
timeOk(timeOnD3, timeOffD3)
|
||||
timeOk(timeOnD4, timeOffD4)
|
||||
timeOk(timeOnD4, timeOffD4)
|
||||
}
|
||||
}
|
||||
state.data.sort{it.start}
|
||||
@@ -384,7 +384,7 @@ def createDayArray() {
|
||||
|
||||
private def textAppName() {
|
||||
def text = "Smart Home Ventilation"
|
||||
}
|
||||
}
|
||||
|
||||
private def textVersion() {
|
||||
def text = "Version 2.1.2 (05/31/2015)"
|
||||
@@ -416,4 +416,4 @@ private def textHelp() {
|
||||
"that each scenario does not overlap and run in separate modes (i.e. Home, Out of town, etc). Also note that you should " +
|
||||
"avoid scheduling the ventilation fan at exactly midnight; the app resets itself at that time. It is suggested to start any new schedule " +
|
||||
"at 12:15 am or later."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ definition(
|
||||
name: "Monitor on Sense",
|
||||
namespace: "resteele",
|
||||
author: "Rachel Steele",
|
||||
description: "Turn on Monitor when vibration is sensed",
|
||||
description: "Turn on switch when vibration is sensed",
|
||||
category: "My Apps",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
||||
@@ -25,10 +25,10 @@ definition(
|
||||
|
||||
|
||||
preferences {
|
||||
section("When the keyboard is used...") {
|
||||
section("When vibration is sensed...") {
|
||||
input "accelerationSensor", "capability.accelerationSensor", title: "Which Sensor?"
|
||||
}
|
||||
section("Turn on/off a light...") {
|
||||
section("Turn on switch...") {
|
||||
input "switch1", "capability.switch"
|
||||
}
|
||||
}
|
||||
@@ -47,5 +47,3 @@ def updated() {
|
||||
def accelerationActiveHandler(evt) {
|
||||
switch1.on()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -114,13 +114,16 @@ def beaconHandler(evt) {
|
||||
|
||||
if (allOk) {
|
||||
def data = new groovy.json.JsonSlurper().parseText(evt.data)
|
||||
log.debug "<beacon-control> data: $data - phones: " + phones*.deviceNetworkId
|
||||
// removed logging of device names. can be added back for debugging
|
||||
//log.debug "<beacon-control> data: $data - phones: " + phones*.deviceNetworkId
|
||||
|
||||
def beaconName = getBeaconName(evt)
|
||||
log.debug "<beacon-control> beaconName: $beaconName"
|
||||
// removed logging of device names. can be added back for debugging
|
||||
//log.debug "<beacon-control> beaconName: $beaconName"
|
||||
|
||||
def phoneName = getPhoneName(data)
|
||||
log.debug "<beacon-control> phoneName: $phoneName"
|
||||
// removed logging of device names. can be added back for debugging
|
||||
//log.debug "<beacon-control> phoneName: $phoneName"
|
||||
if (phoneName != null) {
|
||||
def action = data.presence == "1" ? "arrived" : "left"
|
||||
def msg = "$phoneName has $action ${action == 'arrived' ? 'at ' : ''}the $beaconName"
|
||||
|
||||
@@ -49,13 +49,15 @@ preferences {
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
// commented out log statement because presence sensor label could contain user's name
|
||||
//log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
subscribe(people, "presence", presence)
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
// commented out log statement because presence sensor label could contain user's name
|
||||
//log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
unsubscribe()
|
||||
subscribe(people, "presence", presence)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ def authPage() {
|
||||
// get rid of next button until the user is actually auth'd
|
||||
if (!oauthTokenProvided) {
|
||||
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."
|
||||
href url:redirectUrl, style:"embedded", required:true, title:"ecobee", description:description
|
||||
}
|
||||
@@ -76,7 +76,7 @@ def authPage() {
|
||||
log.debug "thermostat list: $stats"
|
||||
log.debug "sensor list: ${sensorsDiscovered()}"
|
||||
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."
|
||||
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 numFound = options.size() ?: 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."
|
||||
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 oauthState = params.state
|
||||
|
||||
if (oauthState == atomicState.oauthInitState){
|
||||
|
||||
if (oauthState == atomicState.oauthInitState) {
|
||||
def tokenParams = [
|
||||
grant_type: "authorization_code",
|
||||
code : code,
|
||||
client_id : smartThingsClientId,
|
||||
redirect_uri: callbackUrl
|
||||
grant_type: "authorization_code",
|
||||
code : code,
|
||||
client_id : smartThingsClientId,
|
||||
redirect_uri: callbackUrl
|
||||
]
|
||||
|
||||
def tokenUrl = "https://www.ecobee.com/home/token?${toQueryString(tokenParams)}"
|
||||
@@ -129,9 +128,6 @@ def callback() {
|
||||
httpPost(uri: tokenUrl) { resp ->
|
||||
atomicState.refreshToken = resp.data.refresh_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) {
|
||||
@@ -148,8 +144,8 @@ def callback() {
|
||||
|
||||
def success() {
|
||||
def message = """
|
||||
<p>Your ecobee Account is now connected to SmartThings!</p>
|
||||
<p>Click 'Done' to finish setup.</p>
|
||||
<p>Your ecobee Account is now connected to SmartThings!</p>
|
||||
<p>Click 'Done' to finish setup.</p>
|
||||
"""
|
||||
connectionStatus(message)
|
||||
}
|
||||
@@ -171,64 +167,63 @@ def connectionStatus(message, redirectUrl = null) {
|
||||
}
|
||||
|
||||
def html = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=640">
|
||||
<title>Ecobee & SmartThings connection</title>
|
||||
<style type="text/css">
|
||||
@font-face {
|
||||
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?#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.ttf') format('truetype'),
|
||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.svg#swis721_th_btthin') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
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?#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.ttf') format('truetype'),
|
||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.svg#swis721_lt_btlight') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
.container {
|
||||
width: 90%;
|
||||
padding: 4%;
|
||||
/*background: #eee;*/
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
p {
|
||||
font-size: 2.2em;
|
||||
font-family: 'Swiss 721 W01 Thin';
|
||||
text-align: center;
|
||||
color: #666666;
|
||||
padding: 0 40px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
span {
|
||||
font-family: 'Swiss 721 W01 Light';
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=640">
|
||||
<title>Ecobee & SmartThings connection</title>
|
||||
<style type="text/css">
|
||||
@font-face {
|
||||
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?#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.ttf') format('truetype'),
|
||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-thin-webfont.svg#swis721_th_btthin') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
@font-face {
|
||||
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?#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.ttf') format('truetype'),
|
||||
url('https://s3.amazonaws.com/smartapp-icons/Partner/fonts/swiss-721-light-webfont.svg#swis721_lt_btlight') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
.container {
|
||||
width: 90%;
|
||||
padding: 4%;
|
||||
text-align: center;
|
||||
}
|
||||
img {
|
||||
vertical-align: middle;
|
||||
}
|
||||
p {
|
||||
font-size: 2.2em;
|
||||
font-family: 'Swiss 721 W01 Thin';
|
||||
text-align: center;
|
||||
color: #666666;
|
||||
padding: 0 40px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
span {
|
||||
font-family: 'Swiss 721 W01 Light';
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<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/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" />
|
||||
${message}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
render contentType: 'text/html', data: html
|
||||
}
|
||||
@@ -237,19 +232,26 @@ def getEcobeeThermostats() {
|
||||
log.debug "getting device list"
|
||||
atomicState.remoteSensors = []
|
||||
|
||||
def requestBody = '{"selection":{"selectionType":"registered","selectionMatch":"","includeRuntime":true,"includeSensors":true}}'
|
||||
|
||||
def bodyParams = [
|
||||
selection: [
|
||||
selectionType: "registered",
|
||||
selectionMatch: "",
|
||||
includeRuntime: true,
|
||||
includeSensors: true
|
||||
]
|
||||
]
|
||||
def deviceListParams = [
|
||||
uri: apiEndpoint,
|
||||
path: "/1/thermostat",
|
||||
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||
query: [format: 'json', body: requestBody]
|
||||
uri: apiEndpoint,
|
||||
path: "/1/thermostat",
|
||||
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||
// 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 = [:]
|
||||
try {
|
||||
httpGet(deviceListParams) { resp ->
|
||||
|
||||
if (resp.status == 200) {
|
||||
resp.data.thermostatList.each { stat ->
|
||||
atomicState.remoteSensors = atomicState.remoteSensors == null ? stat.remoteSensors : atomicState.remoteSensors << stat.remoteSensors
|
||||
@@ -289,9 +291,10 @@ Map sensorsDiscovered() {
|
||||
}
|
||||
|
||||
def getThermostatDisplayName(stat) {
|
||||
if(stat?.name)
|
||||
return stat.name.toString()
|
||||
return (getThermostatTypeName(stat) + " (${stat.identifier})").toString()
|
||||
if(stat?.name) {
|
||||
return stat.name.toString()
|
||||
}
|
||||
return (getThermostatTypeName(stat) + " (${stat.identifier})").toString()
|
||||
}
|
||||
|
||||
def getThermostatTypeName(stat) {
|
||||
@@ -310,7 +313,6 @@ def updated() {
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
|
||||
log.debug "initialize"
|
||||
def devices = thermostats.collect { dni ->
|
||||
def d = getChildDevice(dni)
|
||||
@@ -350,8 +352,6 @@ def initialize() {
|
||||
log.warn "delete: ${delete}, deleting ${delete.size()} thermostats"
|
||||
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
|
||||
def notificationMessage = "is connected to SmartThings"
|
||||
sendActivityFeeds(notificationMessage)
|
||||
@@ -381,75 +381,41 @@ def pollHandler() {
|
||||
}
|
||||
|
||||
def pollChildren(child = null) {
|
||||
def thermostatIdsString = getChildDeviceIdsString()
|
||||
log.debug "polling children: $thermostatIdsString"
|
||||
def data = ""
|
||||
def thermostatIdsString = getChildDeviceIdsString()
|
||||
log.debug "polling children: $thermostatIdsString"
|
||||
|
||||
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 pollParams = [
|
||||
uri: apiEndpoint,
|
||||
path: "/1/thermostat",
|
||||
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||
query: [format: 'json', body: jsonRequestBody]
|
||||
]
|
||||
uri: apiEndpoint,
|
||||
path: "/1/thermostat",
|
||||
headers: ["Content-Type": "text/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||
// 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{
|
||||
httpGet(pollParams) { resp ->
|
||||
if(resp.status == 200) {
|
||||
log.debug "poll results returned resp.data ${resp.data}"
|
||||
atomicState.remoteSensors = resp.data.thermostatList.remoteSensors
|
||||
atomicState.thermostatData = resp.data
|
||||
updateSensorData()
|
||||
atomicState.thermostats = resp.data.thermostatList.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
|
||||
}
|
||||
result = true
|
||||
log.debug "updated ${atomicState.thermostats?.size()} stats: ${atomicState.thermostats}"
|
||||
}
|
||||
log.debug "poll results returned resp.data ${resp.data}"
|
||||
atomicState.remoteSensors = resp.data.thermostatList.remoteSensors
|
||||
updateSensorData()
|
||||
storeThermostatData(resp.data.thermostatList)
|
||||
result = true
|
||||
log.debug "updated ${atomicState.thermostats?.size()} stats: ${atomicState.thermostats}"
|
||||
}
|
||||
}
|
||||
} catch (groovyx.net.http.HttpResponseException e) {
|
||||
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
|
||||
def pollChild(){
|
||||
|
||||
def pollChild() {
|
||||
def devices = getChildDevices()
|
||||
|
||||
if (pollChildren()){
|
||||
if (pollChildren()) {
|
||||
devices.each { child ->
|
||||
if (!child.device.deviceNetworkId.startsWith("ecobee_sensor")){
|
||||
if (!child.device.deviceNetworkId.startsWith("ecobee_sensor")) {
|
||||
if(atomicState.thermostats[child.device.deviceNetworkId] != null) {
|
||||
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
||||
log.info "pollChild(child)>> data for ${child.device.deviceNetworkId} : ${tData.data}"
|
||||
@@ -492,36 +457,7 @@ void poll() {
|
||||
}
|
||||
|
||||
def availableModes(child) {
|
||||
|
||||
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}")
|
||||
|
||||
def tData = atomicState.thermostats[child.device.deviceNetworkId]
|
||||
@@ -530,14 +466,42 @@ def currentMode(child) {
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
def mode = tData.data.thermostatMode
|
||||
|
||||
mode
|
||||
return mode
|
||||
}
|
||||
|
||||
def updateSensorData() {
|
||||
@@ -558,12 +522,12 @@ def updateSensorData() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (it.type == "occupancy") {
|
||||
if(it.value == "true")
|
||||
occupancy = "active"
|
||||
else
|
||||
if(it.value == "true") {
|
||||
occupancy = "active"
|
||||
} else {
|
||||
occupancy = "inactive"
|
||||
}
|
||||
}
|
||||
}
|
||||
def dni = "ecobee_sensor-"+ it?.id + "-" + it?.code
|
||||
@@ -582,7 +546,7 @@ def getChildDeviceIdsString() {
|
||||
}
|
||||
|
||||
def toJson(Map m) {
|
||||
return new org.json.JSONObject(m).toString()
|
||||
return groovy.json.JsonOutput.toJson(m)
|
||||
}
|
||||
|
||||
def toQueryString(Map m) {
|
||||
@@ -595,54 +559,24 @@ private refreshAuthToken() {
|
||||
if(!atomicState.refreshToken) {
|
||||
log.warn "Can not refresh OAuth token since there is no refreshToken stored"
|
||||
} else {
|
||||
|
||||
def refreshParams = [
|
||||
method: 'POST',
|
||||
uri : apiEndpoint,
|
||||
path : "/token",
|
||||
query : [grant_type: 'refresh_token', code: "${atomicState.refreshToken}", client_id: smartThingsClientId],
|
||||
method: 'POST',
|
||||
uri : apiEndpoint,
|
||||
path : "/token",
|
||||
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."
|
||||
//changed to httpPost
|
||||
try {
|
||||
def jsonMap
|
||||
httpPost(refreshParams) { resp ->
|
||||
|
||||
if(resp.status == 200) {
|
||||
log.debug "Token refreshed...calling saved RestAction now!"
|
||||
|
||||
debugEvent("Token refreshed ... calling saved RestAction now!")
|
||||
|
||||
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 = ""
|
||||
}
|
||||
}
|
||||
saveTokenAndResumeAction(resp.data)
|
||||
}
|
||||
}
|
||||
} catch (groovyx.net.http.HttpResponseException e) {
|
||||
log.error "refreshAuthToken() >> Error: e.statusCode ${e.statusCode}"
|
||||
def reAttemptPeriod = 300 // in sec
|
||||
@@ -662,118 +596,220 @@ private refreshAuthToken() {
|
||||
}
|
||||
}
|
||||
|
||||
def resumeProgram(child, deviceId) {
|
||||
|
||||
|
||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"functions": [{"type": "resumeProgram"}]}'
|
||||
def result = sendJson(jsonRequestBody)
|
||||
return result
|
||||
/**
|
||||
* Saves the refresh and auth token from the passed-in JSON object,
|
||||
* and invokes any previously executing action that did not complete due to
|
||||
* an expired token.
|
||||
*
|
||||
* @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) {
|
||||
|
||||
int h = heating * 10
|
||||
int c = cooling * 10
|
||||
def jsonRequestBody = '{"selection":{"selectionType":"thermostats","selectionMatch":"' + deviceId + '","includeRuntime":true},"functions": [{ "type": "setHold", "params": { "coolHoldTemp": '+c+',"heatHoldTemp": '+h+', "holdType": '+sendHoldType+' } } ]}'
|
||||
|
||||
def result = sendJson(child, jsonRequestBody)
|
||||
return result
|
||||
/**
|
||||
* Executes the resume program command on the Ecobee thermostat
|
||||
* @param deviceId - the ID of the device
|
||||
*
|
||||
* @retrun true if the command was successful, false otherwise.
|
||||
*/
|
||||
boolean resumeProgram(deviceId) {
|
||||
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
|
||||
int c = cooling * 10
|
||||
def payload = [
|
||||
selection: [
|
||||
selectionType: "thermostats",
|
||||
selectionMatch: deviceId,
|
||||
includeRuntime: true
|
||||
],
|
||||
functions: [
|
||||
[
|
||||
type: "setHold",
|
||||
params: [
|
||||
coolHoldTemp: c,
|
||||
heatHoldTemp: h,
|
||||
holdType: sendHoldType
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
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
|
||||
return sendCommandToEcobee(payload)
|
||||
}
|
||||
|
||||
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)
|
||||
return result
|
||||
def payload = [
|
||||
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 = [
|
||||
uri: apiEndpoint,
|
||||
path: "/1/thermostat",
|
||||
headers: ["Content-Type": "application/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||
body: jsonBody
|
||||
uri: apiEndpoint,
|
||||
path: "/1/thermostat",
|
||||
headers: ["Content-Type": "application/json", "Authorization": "Bearer ${atomicState.authToken}"],
|
||||
body: toJson(bodyParams)
|
||||
]
|
||||
|
||||
try{
|
||||
httpPost(cmdParams) { resp ->
|
||||
|
||||
if(resp.status == 200) {
|
||||
|
||||
log.debug "updated ${resp.data}"
|
||||
returnStatus = resp.data.status.code
|
||||
if (resp.data.status.code == 0)
|
||||
log.debug "Successful call to ecobee API."
|
||||
else {
|
||||
log.debug "Error return code = ${resp.data.status.code}"
|
||||
debugEvent("Error return code = ${resp.data.status.code}")
|
||||
}
|
||||
}
|
||||
}
|
||||
httpPost(cmdParams) { resp ->
|
||||
if(resp.status == 200) {
|
||||
log.debug "updated ${resp.data}"
|
||||
def returnStatus = resp.data.status.code
|
||||
if (returnStatus == 0) {
|
||||
log.debug "Successful call to ecobee API."
|
||||
isSuccess = true
|
||||
} else {
|
||||
log.debug "Error return code = ${returnStatus}"
|
||||
debugEvent("Error return code = ${returnStatus}")
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (groovyx.net.http.HttpResponseException e) {
|
||||
log.trace "Exception Sending Json: " + e.response.data.status
|
||||
debugEvent ("sent Json & got http status ${e.statusCode} - ${e.response.data.status.code}")
|
||||
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"
|
||||
log.debug "Refreshing your auth_token!"
|
||||
refreshAuthToken()
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
debugEvent("Authentication error, invalid authentication method, lack of credentials, etc.")
|
||||
log.error "Authentication error, invalid authentication method, lack of credentials, etc."
|
||||
}
|
||||
}
|
||||
|
||||
if (returnStatus == 0)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
return isSuccess
|
||||
}
|
||||
|
||||
def getChildName() { "Ecobee Thermostat" }
|
||||
def getSensorChildName() { "Ecobee Sensor" }
|
||||
def getChildName() { return "Ecobee Thermostat" }
|
||||
def getSensorChildName() { return "Ecobee Sensor" }
|
||||
def getServerUrl() { return "https://graph.api.smartthings.com" }
|
||||
def getShardUrl() { return getApiServerUrl() }
|
||||
def getCallbackUrl() { "https://graph.api.smartthings.com/oauth/callback" }
|
||||
def getBuildRedirectUrl() { "${serverUrl}/oauth/initialize?appId=${app.id}&access_token=${atomicState.accessToken}&apiServerUrl=${shardUrl}" }
|
||||
def getApiEndpoint() { "https://api.ecobee.com" }
|
||||
def getSmartThingsClientId() { appSettings.clientId }
|
||||
def getCallbackUrl() { return "https://graph.api.smartthings.com/oauth/callback" }
|
||||
def getBuildRedirectUrl() { return "${serverUrl}/oauth/initialize?appId=${app.id}&access_token=${atomicState.accessToken}&apiServerUrl=${shardUrl}" }
|
||||
def getApiEndpoint() { return "https://api.ecobee.com" }
|
||||
def getSmartThingsClientId() { return appSettings.clientId }
|
||||
|
||||
def debugEvent(message, displayEvent = false) {
|
||||
|
||||
def results = [
|
||||
name: "appdebug",
|
||||
descriptionText: message,
|
||||
displayed: displayEvent
|
||||
name: "appdebug",
|
||||
descriptionText: message,
|
||||
displayed: displayEvent
|
||||
]
|
||||
log.debug "Generating AppDebug Event: ${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
|
||||
def sendPushAndFeeds(notificationMessage){
|
||||
def sendPushAndFeeds(notificationMessage) {
|
||||
log.warn "sendPushAndFeeds >> notificationMessage: ${notificationMessage}"
|
||||
log.warn "sendPushAndFeeds >> atomicState.timeSendPush: ${atomicState.timeSendPush}"
|
||||
if (atomicState.timeSendPush){
|
||||
if (now() - atomicState.timeSendPush > 86400000){ // notification is sent to remind user once a day
|
||||
if (atomicState.timeSendPush) {
|
||||
if (now() - atomicState.timeSendPush > 86400000) { // notification is sent to remind user once a day
|
||||
sendPush("Your Ecobee thermostat " + notificationMessage)
|
||||
sendActivityFeeds(notificationMessage)
|
||||
atomicState.timeSendPush = now()
|
||||
@@ -786,6 +822,58 @@ def sendPushAndFeeds(notificationMessage){
|
||||
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 devices = getChildDevices()
|
||||
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) {
|
||||
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
|
||||
atomicState.lastValue = meterValue
|
||||
|
||||
def dUnit = evt.unit ?: "Watts"
|
||||
|
||||
def aboveThresholdValue = aboveThreshold as int
|
||||
if (meterValue > aboveThresholdValue) {
|
||||
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)
|
||||
} else {
|
||||
// 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
|
||||
if (meterValue < belowThresholdValue) {
|
||||
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)
|
||||
} else {
|
||||
// log.debug "not sending notification for ${evt.description} because the threshold (${belowThreshold}) has already been crossed"
|
||||
|
||||
@@ -54,10 +54,10 @@ def waterWetHandler(evt) {
|
||||
def alreadySentSms = recentEvents.count { it.value && it.value == "wet" } > 1
|
||||
|
||||
if (alreadySentSms) {
|
||||
log.debug "SMS already sent to $phone within the last $deltaSeconds seconds"
|
||||
log.debug "SMS already sent within the last $deltaSeconds seconds"
|
||||
} else {
|
||||
def msg = "${alarm.displayName} is wet!"
|
||||
log.debug "$alarm is wet, texting $phone"
|
||||
log.debug "$alarm is wet, texting phone number"
|
||||
|
||||
if (location.contactBookEnabled) {
|
||||
sendNotificationToContacts(msg, recipients)
|
||||
|
||||
@@ -90,7 +90,7 @@ def takeAction(){
|
||||
}
|
||||
|
||||
def sendTextMessage() {
|
||||
log.debug "$multisensor was open too long, texting $phone"
|
||||
log.debug "$multisensor was open too long, texting phone"
|
||||
|
||||
updateSmsHistory()
|
||||
def openMinutes = maxOpenTime * (state.smsHistory?.size() ?: 1)
|
||||
|
||||
@@ -761,7 +761,7 @@ String displayableTime(timeRemaining) {
|
||||
return "${minutes}:00"
|
||||
}
|
||||
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}"
|
||||
}
|
||||
|
||||
@@ -1101,4 +1101,4 @@ def hasStartLevel() {
|
||||
|
||||
def hasEndLevel() {
|
||||
return (endLevel != null && endLevel != "")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,13 +47,13 @@ preferences {
|
||||
|
||||
def installed() {
|
||||
log.debug "Installed with settings: ${settings}"
|
||||
log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
// log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
subscribe(people, "presence", presence)
|
||||
}
|
||||
|
||||
def updated() {
|
||||
log.debug "Updated with settings: ${settings}"
|
||||
log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
// log.debug "Current mode = ${location.mode}, people = ${people.collect{it.label + ': ' + it.currentPresence}}"
|
||||
unsubscribe()
|
||||
subscribe(people, "presence", presence)
|
||||
}
|
||||
@@ -71,11 +71,10 @@ def presence(evt)
|
||||
def person = getPerson(evt)
|
||||
def recentNotPresent = person.statesSince("presence", t0).find{it.value == "not present"}
|
||||
if (recentNotPresent) {
|
||||
log.debug "skipping notification of arrival of ${person.displayName} because last departure was only ${now() - recentNotPresent.date.time} msec ago"
|
||||
log.debug "skipping notification of arrival of Person because last departure was only ${now() - recentNotPresent.date.time} msec ago"
|
||||
}
|
||||
else {
|
||||
def message = "${person.displayName} arrived at home, changing mode to '${newMode}'"
|
||||
log.info message
|
||||
send(message)
|
||||
setLocationMode(newMode)
|
||||
}
|
||||
@@ -106,6 +105,4 @@ private send(msg) {
|
||||
sendSms(phone, msg)
|
||||
}
|
||||
}
|
||||
|
||||
log.debug msg
|
||||
}
|
||||
|
||||
@@ -57,12 +57,11 @@ def scheduleCheck()
|
||||
def message = message1 ?: "SmartThings - Habit Helper Reminder!"
|
||||
|
||||
if (location.contactBookEnabled) {
|
||||
log.debug "Texting reminder: ($message) to contacts:${recipients?.size()}"
|
||||
log.debug "Texting reminder to contacts:${recipients?.size()}"
|
||||
sendNotificationToContacts(message, recipients)
|
||||
}
|
||||
else {
|
||||
|
||||
log.debug "Texting reminder: ($message) to $phone1"
|
||||
log.debug "Texting reminder"
|
||||
sendSms(phone1, message)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,8 +95,7 @@ def bridgeDiscoveryFailed() {
|
||||
}
|
||||
}
|
||||
|
||||
def bridgeLinking()
|
||||
{
|
||||
def bridgeLinking() {
|
||||
int linkRefreshcount = !state.linkRefreshcount ? 0 : state.linkRefreshcount as int
|
||||
state.linkRefreshcount = linkRefreshcount + 1
|
||||
def refreshInterval = 3
|
||||
@@ -171,7 +170,7 @@ def bulbDiscovery() {
|
||||
|
||||
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.") {
|
||||
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
|
||||
}
|
||||
section {
|
||||
@@ -328,7 +327,7 @@ def bulbListHandler(hub, data = "") {
|
||||
def object = new groovy.json.JsonSlurper().parseText(data)
|
||||
object.each { k,v ->
|
||||
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
|
||||
@@ -448,7 +447,6 @@ def addBridge() {
|
||||
updateBridgeStatus(childDevice)
|
||||
childDevice.sendEvent(name: "idNumber", value: idNumber)
|
||||
|
||||
|
||||
if (vbridge.value.ip && vbridge.value.port) {
|
||||
if (vbridge.value.ip.contains(".")) {
|
||||
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"
|
||||
def headerString = parsedEvent.headers.toString()
|
||||
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
|
||||
* for the bridge. Also, set ID number on bridge if not done previously.
|
||||
* 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 and all connected lights. Also, set ID number on bridge if not done previously.
|
||||
*/
|
||||
private void checkBridgeStatus() {
|
||||
def bridges = getHueBridges()
|
||||
// Check if each bridge has been heard from within the last 16 minutes (3 poll intervals times 5 minutes plus buffer)
|
||||
def time = now() - (1000 * 60 * 16)
|
||||
// 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 * 11)
|
||||
bridges.each {
|
||||
def d = getChildDevice(it.value.mac)
|
||||
if(d) {
|
||||
@@ -743,14 +740,21 @@ private void checkBridgeStatus() {
|
||||
d.sendEvent(name: "idNumber", value: it.value.idNumber)
|
||||
}
|
||||
|
||||
if (it.value.lastActivity < time) { // it.value.lastActivity != null &&
|
||||
log.warn "Bridge $it.key is Offline"
|
||||
d.sendEvent(name: "status", value: "Offline")
|
||||
} else {
|
||||
if (it.value.lastActivity < time) { // it.value.lastActivity != null &&
|
||||
log.warn "Bridge $it.key is Offline"
|
||||
d.sendEvent(name: "status", value: "Offline")
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def isValidSource(macAddress) {
|
||||
@@ -785,8 +789,7 @@ def parse(childDevice, description) {
|
||||
if (body instanceof java.util.Map) {
|
||||
// get (poll) reponse
|
||||
return handlePoll(body)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//put response
|
||||
return handleCommandResponse(body)
|
||||
}
|
||||
@@ -798,10 +801,12 @@ def parse(childDevice, description) {
|
||||
}
|
||||
|
||||
// Philips Hue priority for color is xy > ct > hs
|
||||
// For SmartThings, try to always send hue, sat and hex
|
||||
private sendColorEvents(device, xy, hue, sat, ct, colormode = null) {
|
||||
if (device == null || (xy == null && hue == null && sat == null && ct == null))
|
||||
return
|
||||
|
||||
def events = [:]
|
||||
// For now, only care about changing color temperature if requested by user
|
||||
if (ct != null && (colormode == "ct" || (xy == null && hue == null && sat == null))) {
|
||||
// for some reason setting Hue to their specified minimum off 153 yields 154, dealt with below
|
||||
@@ -815,13 +820,13 @@ private sendColorEvents(device, xy, hue, sat, ct, colormode = null) {
|
||||
if (hue != null) {
|
||||
// 0-65535
|
||||
def value = Math.min(Math.round(hue * 100 / 65535), 65535) as int
|
||||
device.sendEvent([name: "hue", value: value, descriptionText: "Color has changed"])
|
||||
events["hue"] = [name: "hue", value: value, descriptionText: "Color has changed", displayed: false]
|
||||
}
|
||||
|
||||
if (sat != null) {
|
||||
// 0-254
|
||||
def value = Math.round(sat * 100 / 254) as int
|
||||
device.sendEvent([name: "saturation", value: value, descriptionText: "Color has changed"])
|
||||
events["saturation"] = [name: "saturation", value: value, descriptionText: "Color has changed", displayed: false]
|
||||
}
|
||||
|
||||
// Following is used to decide what to base hex calculations on since it is preferred to return a colorchange in hex
|
||||
@@ -833,17 +838,28 @@ private sendColorEvents(device, xy, hue, sat, ct, colormode = null) {
|
||||
def model = state.bulbs[id]?.modelid
|
||||
def hex = colorFromXY(xy, model)
|
||||
|
||||
// TODO Disabled until a solution for the jumping color picker can be figured out
|
||||
//device.sendEvent([name: "color", value: hex.toUpperCase(), descriptionText: "Color has changed", displayed: false])
|
||||
// Create Hue and Saturation events if not previously existing
|
||||
def hsv = hexToHsv(hex)
|
||||
if (events["hue"] == null)
|
||||
events["hue"] = [name: "hue", value: hsv[0], descriptionText: "Color has changed", displayed: false]
|
||||
if (events["saturation"] == null)
|
||||
events["saturation"] = [name: "saturation", value: hsv[1], descriptionText: "Color has changed", displayed: false]
|
||||
|
||||
events["color"] = [name: "color", value: hex.toUpperCase(), descriptionText: "Color has changed", displayed: true]
|
||||
} else if (colormode == "hs" || colormode == null) {
|
||||
// colormode is "hs" or "xy" is missing, default to follow hue/sat which is already handled above
|
||||
def hueValue = (hue != null) ? events["hue"].value : Integer.parseInt("$device.currentHue")
|
||||
def satValue = (sat != null) ? events["saturation"].value : Integer.parseInt("$device.currentSaturation")
|
||||
|
||||
// TODO Disabled until the standard behavior of lights is defined (hue and sat events are sent above)
|
||||
//def hex = colorUtil.hslToHex((int) device.currentHue, (int) device.currentSaturation)
|
||||
// device.sendEvent([name: "color", value: hex.toUpperCase(), descriptionText: "Color has changed"])
|
||||
|
||||
def hex = hsvToHex(hueValue, satValue)
|
||||
events["color"] = [name: "color", value: hex.toUpperCase(), descriptionText: "Color has changed", displayed: true]
|
||||
}
|
||||
|
||||
return debug
|
||||
boolean sendColorChanged = false
|
||||
events.each {
|
||||
device.sendEvent(it.value)
|
||||
}
|
||||
}
|
||||
|
||||
private sendBasicEvents(device, param, value) {
|
||||
@@ -883,36 +899,38 @@ private handleCommandResponse(body) {
|
||||
// scan entire response before sending events to make sure they are always in the same order
|
||||
def updates = [:]
|
||||
|
||||
body.each { payload ->
|
||||
log.debug $payload
|
||||
|
||||
body.each { payload ->
|
||||
if (payload?.success) {
|
||||
def childDeviceNetworkId = app.id + "/"
|
||||
def eventType
|
||||
def childDeviceNetworkId = app.id + "/"
|
||||
def eventType
|
||||
payload.success.each { k, v ->
|
||||
def data = k.split("/")
|
||||
if (data.length == 5) {
|
||||
childDeviceNetworkId = app.id + "/" + k.split("/")[2]
|
||||
if (!updates[childDeviceNetworkId])
|
||||
updates[childDeviceNetworkId] = [:]
|
||||
eventType = k.split("/")[4]
|
||||
eventType = k.split("/")[4]
|
||||
updates[childDeviceNetworkId]."$eventType" = v
|
||||
}
|
||||
}
|
||||
} else if (payload.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())
|
||||
updates.each { childDeviceNetworkId, params ->
|
||||
def device = getChildDevice(childDeviceNetworkId)
|
||||
sendBasicEvents(device, "on", params.on)
|
||||
sendBasicEvents(device, "bri", params.bri)
|
||||
sendColorEvents(device, params.xy, params.hue, params.sat, params.ct)
|
||||
}
|
||||
def id = getId(device)
|
||||
// If device is offline, then don't send events which will update device watch
|
||||
if (isOnline(id)) {
|
||||
sendBasicEvents(device, "on", params.on)
|
||||
sendBasicEvents(device, "bri", params.bri)
|
||||
sendColorEvents(device, params.xy, params.hue, params.sat, params.ct)
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a response to a poll (GET) sent to the Hue Bridge.
|
||||
@@ -932,26 +950,33 @@ private handleCommandResponse(body) {
|
||||
* @return empty array
|
||||
*/
|
||||
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()
|
||||
for (bulb in body) {
|
||||
def device = bulbs.find{it.deviceNetworkId == "${app.id}/${bulb.key}"}
|
||||
if (device) {
|
||||
if (bulb.value.state?.reachable) {
|
||||
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)
|
||||
if (state.bulbs[bulb.key]?.online == false) {
|
||||
// light just came back online, notify device watch
|
||||
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 {
|
||||
state.bulbs[bulb.key]?.online = false
|
||||
log.warn "$device is not reachable by Hue bridge"
|
||||
}
|
||||
}
|
||||
}
|
||||
return []
|
||||
device.sendEvent(name: "DeviceWatch-DeviceOffline", value: "offline", displayed: false, isStateChange: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
private updateInProgress() {
|
||||
state.updating = true
|
||||
@@ -980,22 +1005,34 @@ def hubVerification(bodytext) {
|
||||
|
||||
def on(childDevice) {
|
||||
log.debug "Executing 'on'"
|
||||
def id = getId(childDevice)
|
||||
if (!isOnline(id)) {
|
||||
return "Bulb is unreachable"
|
||||
}
|
||||
updateInProgress()
|
||||
createSwitchEvent(childDevice, "on")
|
||||
put("lights/${getId(childDevice)}/state", [on: true])
|
||||
put("lights/$id/state", [on: true])
|
||||
return "Bulb is turning On"
|
||||
}
|
||||
|
||||
def off(childDevice) {
|
||||
log.debug "Executing 'off'"
|
||||
def id = getId(childDevice)
|
||||
if (!isOnline(id)) {
|
||||
return "Bulb is unreachable"
|
||||
}
|
||||
updateInProgress()
|
||||
createSwitchEvent(childDevice, "off")
|
||||
put("lights/${getId(childDevice)}/state", [on: false])
|
||||
put("lights/$id/state", [on: false])
|
||||
return "Bulb is turning Off"
|
||||
}
|
||||
|
||||
def setLevel(childDevice, percent) {
|
||||
log.debug "Executing 'setLevel'"
|
||||
def id = getId(childDevice)
|
||||
if (!isOnline(id)) {
|
||||
return "Bulb is unreachable"
|
||||
}
|
||||
updateInProgress()
|
||||
// 1 - 254
|
||||
def level
|
||||
@@ -1010,48 +1047,64 @@ def setLevel(childDevice, percent) {
|
||||
// that means that the light will still be on when on is called next time
|
||||
// Lets emulate that here
|
||||
if (percent > 0) {
|
||||
put("lights/${getId(childDevice)}/state", [bri: level, on: true])
|
||||
put("lights/$id/state", [bri: level, on: true])
|
||||
} else {
|
||||
put("lights/${getId(childDevice)}/state", [on: false])
|
||||
put("lights/$id/state", [on: false])
|
||||
}
|
||||
return "Setting level to $percent"
|
||||
}
|
||||
|
||||
def setSaturation(childDevice, percent) {
|
||||
log.debug "Executing 'setSaturation($percent)'"
|
||||
updateInProgress()
|
||||
def id = getId(childDevice)
|
||||
if (!isOnline(id)) {
|
||||
return "Bulb is unreachable"
|
||||
}
|
||||
|
||||
updateInProgress()
|
||||
// 0 - 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?
|
||||
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"
|
||||
}
|
||||
|
||||
def setHue(childDevice, percent) {
|
||||
log.debug "Executing 'setHue($percent)'"
|
||||
def id = getId(childDevice)
|
||||
if (!isOnline(id)) {
|
||||
return "Bulb is unreachable"
|
||||
}
|
||||
updateInProgress()
|
||||
// 0 - 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?
|
||||
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"
|
||||
}
|
||||
|
||||
def setColorTemperature(childDevice, huesettings) {
|
||||
log.debug "Executing 'setColorTemperature($huesettings)'"
|
||||
def id = getId(childDevice)
|
||||
if (!isOnline(id)) {
|
||||
return "Bulb is unreachable"
|
||||
}
|
||||
updateInProgress()
|
||||
// 153 (6500K) to 500 (2000K)
|
||||
def ct = hueSettings == 6500 ? 153 : Math.round(1000000/huesettings)
|
||||
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"
|
||||
}
|
||||
|
||||
def setColor(childDevice, huesettings) {
|
||||
log.debug "Executing 'setColor($huesettings)'"
|
||||
|
||||
def id = getId(childDevice)
|
||||
if (!isOnline(id)) {
|
||||
return "Bulb is unreachable"
|
||||
}
|
||||
updateInProgress()
|
||||
|
||||
def value = [:]
|
||||
@@ -1059,26 +1112,22 @@ def setColor(childDevice, huesettings) {
|
||||
def sat = null
|
||||
def xy = null
|
||||
|
||||
// For now ignore model to get a consistent color if same color is set across multiple devices
|
||||
// def model = state.bulbs[getId(childDevice)]?.modelid
|
||||
if (huesettings.hex != null) {
|
||||
// Prefer hue/sat over hex to make sure it works with the majority of the smartapps
|
||||
if (huesettings.hue != null || huesettings.sat != null) {
|
||||
// If both hex and hue/sat are set, send all values to bridge to get hue/sat in response from bridge to
|
||||
// generate hue/sat events even though bridge will prioritize XY when setting color
|
||||
if (huesettings.hue != null)
|
||||
value.hue = Math.min(Math.round(huesettings.hue * 65535 / 100), 65535)
|
||||
if (huesettings.saturation != null)
|
||||
value.sat = Math.min(Math.round(huesettings.saturation * 254 / 100), 254)
|
||||
} else if (huesettings.hex != null && false) {
|
||||
// For now ignore model to get a consistent color if same color is set across multiple devices
|
||||
// def model = state.bulbs[getId(childDevice)]?.modelid
|
||||
// value.xy = calculateXY(huesettings.hex, model)
|
||||
// Once groups, or scenes are introduced it might be a good idea to use unique models again
|
||||
value.xy = calculateXY(huesettings.hex)
|
||||
}
|
||||
|
||||
// If both hex and hue/sat are set, send all values to bridge to get hue/sat in response from bridge to
|
||||
// generate hue/sat events even though bridge will prioritize XY when setting color
|
||||
if (huesettings.hue != null)
|
||||
value.hue = Math.min(Math.round(huesettings.hue * 65535 / 100), 65535)
|
||||
else
|
||||
value.hue = Math.min(Math.round(childDevice.device?.currentValue("hue") * 65535 / 100), 65535)
|
||||
|
||||
if (huesettings.saturation != null)
|
||||
value.sat = Math.min(Math.round(huesettings.saturation * 254 / 100), 254)
|
||||
else
|
||||
value.sat = Math.min(Math.round(childDevice.device?.currentValue("saturation") * 254 / 100), 254)
|
||||
|
||||
/* Disabled for now due to bad behavior via Lightning Wizard
|
||||
if (!value.xy) {
|
||||
// Below will translate values to hex->XY to take into account the color support of the different hue types
|
||||
@@ -1108,15 +1157,23 @@ def setColor(childDevice, huesettings) {
|
||||
value.on = false
|
||||
|
||||
createSwitchEvent(childDevice, value.on ? "on" : "off")
|
||||
put("lights/${getId(childDevice)}/state", value)
|
||||
put("lights/$id/state", 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) {
|
||||
if (childDevice.device?.deviceNetworkId?.startsWith("HUE")) {
|
||||
return childDevice.device?.deviceNetworkId[3..-1]
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return childDevice.device?.deviceNetworkId.split("/")[-1]
|
||||
}
|
||||
}
|
||||
@@ -1125,10 +1182,12 @@ private poll() {
|
||||
def host = getBridgeIP()
|
||||
def uri = "/api/${state.username}/lights/"
|
||||
log.debug "GET: $host$uri"
|
||||
sendHubCommand(new physicalgraph.device.HubAction("""GET ${uri} HTTP/1.1
|
||||
HOST: ${host}
|
||||
sendHubCommand(new physicalgraph.device.HubAction("GET ${uri} HTTP/1.1\r\n" +
|
||||
"HOST: ${host}\r\n\r\n", 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) {
|
||||
@@ -1140,13 +1199,11 @@ private put(path, body) {
|
||||
log.debug "PUT: $host$uri"
|
||||
log.debug "BODY: ${bodyJSON}"
|
||||
|
||||
sendHubCommand(new physicalgraph.device.HubAction("""PUT $uri HTTP/1.1
|
||||
HOST: ${host}
|
||||
Content-Length: ${length}
|
||||
|
||||
${bodyJSON}
|
||||
""", physicalgraph.device.Protocol.LAN, "${selectedHue}"))
|
||||
|
||||
sendHubCommand(new physicalgraph.device.HubAction("PUT $uri HTTP/1.1\r\n" +
|
||||
"HOST: ${host}\r\n" +
|
||||
"Content-Length: ${length}\r\n" +
|
||||
"\r\n" +
|
||||
"${bodyJSON}", physicalgraph.device.Protocol.LAN, "${selectedHue}"))
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1198,7 +1255,7 @@ def convertBulbListToMap() {
|
||||
if (state.bulbs instanceof java.util.List) {
|
||||
def map = [:]
|
||||
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
|
||||
}
|
||||
@@ -1604,3 +1661,101 @@ private boolean checkPointInLampsReach(p, colorPoints) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an RGB color in hex to HSV.
|
||||
* Algorithm based on http://en.wikipedia.org/wiki/HSV_color_space.
|
||||
*
|
||||
* @param colorStr color value in hex (#ff03d3)
|
||||
*
|
||||
* @return HSV representation in an array (0-100) [hue, sat, value]
|
||||
*/
|
||||
def hexToHsv(colorStr){
|
||||
def r = Integer.valueOf( colorStr.substring( 1, 3 ), 16 ) / 255
|
||||
def g = Integer.valueOf( colorStr.substring( 3, 5 ), 16 ) / 255
|
||||
def b = Integer.valueOf( colorStr.substring( 5, 7 ), 16 ) / 255;
|
||||
|
||||
def max = Math.max(Math.max(r, g), b)
|
||||
def min = Math.min(Math.min(r, g), b)
|
||||
|
||||
def h, s, v = max;
|
||||
|
||||
def d = max - min;
|
||||
s = max == 0 ? 0 : d / max;
|
||||
|
||||
if(max == min){
|
||||
h = 0;
|
||||
}else{
|
||||
switch(max){
|
||||
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
|
||||
case g: h = (b - r) / d + 2; break;
|
||||
case b: h = (r - g) / d + 4; break;
|
||||
}
|
||||
h /= 6;
|
||||
}
|
||||
|
||||
return [(h * 100).round(), (s * 100).round(), (v * 100).round()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts HSV color to RGB in hex.
|
||||
* Algorithm based on http://en.wikipedia.org/wiki/HSV_color_space.
|
||||
*
|
||||
* @param hue hue 0-100
|
||||
* @param sat saturation 0-100
|
||||
* @param value value 0-100 (defaults to 100)
|
||||
|
||||
* @return the color in hex (#ff03d3)
|
||||
*/
|
||||
def hsvToHex(hue, sat, value = 100){
|
||||
def r, g, b;
|
||||
def h = hue / 100
|
||||
def s = sat / 100
|
||||
def v = value / 100
|
||||
|
||||
def i = Math.floor(h * 6);
|
||||
def f = h * 6 - i;
|
||||
def p = v * (1 - s);
|
||||
def q = v * (1 - f * s);
|
||||
def t = v * (1 - (1 - f) * s);
|
||||
|
||||
switch (i % 6) {
|
||||
case 0:
|
||||
r = v
|
||||
g = t
|
||||
b = p
|
||||
break
|
||||
case 1:
|
||||
r = q
|
||||
g = v
|
||||
b = p
|
||||
break
|
||||
case 2:
|
||||
r = p
|
||||
g = v
|
||||
b = t
|
||||
break
|
||||
case 3:
|
||||
r = p
|
||||
g = q
|
||||
b = v
|
||||
break
|
||||
case 4:
|
||||
r = t
|
||||
g = p
|
||||
b = v
|
||||
break
|
||||
case 5:
|
||||
r = v
|
||||
g = p
|
||||
b = q
|
||||
break
|
||||
}
|
||||
|
||||
// Converting float components to int components.
|
||||
def r1 = String.format("%02X", (int) (r * 255.0f));
|
||||
def g1 = String.format("%02X", (int) (g * 255.0f));
|
||||
def b1 = String.format("%02X", (int) (b * 255.0f));
|
||||
|
||||
return "#$r1$g1$b1"
|
||||
}
|
||||
|
||||
@@ -53,14 +53,14 @@ def accelerationActiveHandler(evt) {
|
||||
def alreadySentSms = recentEvents.count { it.value && it.value == "active" } > 1
|
||||
|
||||
if (alreadySentSms) {
|
||||
log.debug "SMS already sent to $phone1 within the last $deltaSeconds seconds"
|
||||
log.debug "SMS already sent within the last $deltaSeconds seconds"
|
||||
} else {
|
||||
if (location.contactBookEnabled) {
|
||||
log.debug "$accelerationSensor has moved, texting contacts: ${recipients?.size()}"
|
||||
log.debug "accelerationSensor has moved, texting contacts: ${recipients?.size()}"
|
||||
sendNotificationToContacts("${accelerationSensor.label ?: accelerationSensor.name} moved", recipients)
|
||||
}
|
||||
else {
|
||||
log.debug "$accelerationSensor has moved, texting $phone1"
|
||||
log.debug "accelerationSensor has moved, sending text message"
|
||||
sendSms(phone1, "${accelerationSensor.label ?: accelerationSensor.name} moved")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ def temperatureHandler(evt) {
|
||||
def alreadySentSms = recentEvents.count { it.doubleValue >= tooHot } > 1
|
||||
|
||||
if (alreadySentSms) {
|
||||
log.debug "SMS already sent to $phone1 within the last $deltaMinutes minutes"
|
||||
log.debug "SMS already sent within the last $deltaMinutes minutes"
|
||||
// TODO: Send "Temperature back to normal" SMS, turn switch off
|
||||
} else {
|
||||
log.debug "Temperature rose above $tooHot: sending SMS to $phone1 and activating $mySwitch"
|
||||
log.debug "Temperature rose above $tooHot: sending SMS and activating $mySwitch"
|
||||
def tempScale = location.temperatureScale ?: "F"
|
||||
send("${temperatureSensor1.displayName} is too hot, reporting a temperature of ${evt.value}${evt.unit?:tempScale}")
|
||||
switch1?.on()
|
||||
|
||||
@@ -50,9 +50,9 @@ def authPage() {
|
||||
}
|
||||
def description = "Tap to enter LIFX credentials"
|
||||
def redirectUrl = "${serverUrl}/oauth/initialize?appId=${app.id}&access_token=${state.accessToken}&apiServerUrl=${apiServerUrl}" // this triggers oauthInit() below
|
||||
// def redirectUrl = "${apiServerUrl}"
|
||||
log.debug "app id: ${app.id}"
|
||||
log.debug "redirect url: ${redirectUrl}"
|
||||
// def redirectUrl = "${apiServerUrl}"
|
||||
// log.debug "app id: ${app.id}"
|
||||
// log.debug "redirect url: ${redirectUrl}"s
|
||||
return dynamicPage(name: "Credentials", title: "Connect to LIFX", nextPage: null, uninstall: true, install:true) {
|
||||
section {
|
||||
href(url:redirectUrl, required:true, title:"Connect to LIFX", description:"Tap here to connect your LIFX account")
|
||||
@@ -372,7 +372,7 @@ def updateDevices() {
|
||||
def childDevice = getChildDevice(device.id)
|
||||
selectors.add("${device.id}")
|
||||
if (!childDevice) {
|
||||
log.info("Adding device ${device.id}: ${device.product}")
|
||||
// log.info("Adding device ${device.id}: ${device.product}")
|
||||
def data = [
|
||||
label: device.label,
|
||||
level: Math.round((device.brightness ?: 1) * 100),
|
||||
|
||||
@@ -51,7 +51,7 @@ definition(
|
||||
}
|
||||
|
||||
preferences(oauthPage: "deviceAuthorization") {
|
||||
page(name: "Credentials", title: "Connect to your Logitech Harmony device", content: "authPage", install: false, nextPage: "deviceAuthorization")
|
||||
page(name: "Credentials", title: "Connect to your Logitech Harmony device", content: "authPage", install: false, nextPage: "deviceAuthorization")
|
||||
page(name: "deviceAuthorization", title: "Logitech Harmony device authorization", install: true) {
|
||||
section("Allow Logitech Harmony to control these things...") {
|
||||
input "switches", "capability.switch", title: "Which Switches?", multiple: true, required: false
|
||||
@@ -102,7 +102,8 @@ def authPage() {
|
||||
description = "Click to enter Harmony Credentials"
|
||||
def redirectUrl = buildRedirectUrl
|
||||
return dynamicPage(name: "Credentials", title: "Harmony", nextPage: null, uninstall: true, install:false) {
|
||||
section { href url:redirectUrl, style:"embedded", required:true, title:"Harmony", description:description }
|
||||
section { paragraph title: "Note:", "This device has not been officially tested and certified to “Work with SmartThings”. You can connect it to your SmartThings home but performance may vary and we will not be able to provide support or assistance." }
|
||||
section { href url:redirectUrl, style:"embedded", required:true, title:"Harmony", description:description }
|
||||
}
|
||||
} else {
|
||||
//device discovery request every 5 //25 seconds
|
||||
@@ -314,8 +315,6 @@ def installed() {
|
||||
}
|
||||
|
||||
def updated() {
|
||||
unsubscribe()
|
||||
unschedule()
|
||||
if (!state.accessToken) {
|
||||
log.debug "About to create access token"
|
||||
createAccessToken()
|
||||
|
||||
@@ -41,10 +41,10 @@ def updated() {
|
||||
|
||||
def presenceHandler(evt) {
|
||||
if (evt.value == "present") {
|
||||
log.debug "${presence.label ?: presence.name} has arrived at the ${location}"
|
||||
// log.debug "${presence.label ?: presence.name} has arrived at the ${location}"
|
||||
sendPush("${presence.label ?: presence.name} has arrived at the ${location}")
|
||||
} else if (evt.value == "not present") {
|
||||
log.debug "${presence.label ?: presence.name} has left the ${location}"
|
||||
// log.debug "${presence.label ?: presence.name} has left the ${location}"
|
||||
sendPush("${presence.label ?: presence.name} has left the ${location}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ def updated() {
|
||||
|
||||
def presenceHandler(evt) {
|
||||
if (evt.value == "present") {
|
||||
log.debug "${presence.label ?: presence.name} has arrived at the ${location}"
|
||||
// log.debug "${presence.label ?: presence.name} has arrived at the ${location}"
|
||||
|
||||
if (location.contactBookEnabled) {
|
||||
sendNotificationToContacts("${presence.label ?: presence.name} has arrived at the ${location}", recipients)
|
||||
@@ -56,7 +56,7 @@ def presenceHandler(evt) {
|
||||
sendSms(phone1, "${presence.label ?: presence.name} has arrived at the ${location}")
|
||||
}
|
||||
} else if (evt.value == "not present") {
|
||||
log.debug "${presence.label ?: presence.name} has left the ${location}"
|
||||
// log.debug "${presence.label ?: presence.name} has left the ${location}"
|
||||
|
||||
if (location.contactBookEnabled) {
|
||||
sendNotificationToContacts("${presence.label ?: presence.name} has left the ${location}", recipients)
|
||||
|
||||
@@ -67,7 +67,7 @@ def updated() {
|
||||
}
|
||||
|
||||
def subscribe() {
|
||||
log.debug "present: ${cars.collect{it.displayName + ': ' + it.currentPresence}}"
|
||||
// log.debug "present: ${cars.collect{it.displayName + ': ' + it.currentPresence}}"
|
||||
subscribe(doorSensor, "contact", garageDoorContact)
|
||||
|
||||
subscribe(cars, "presence", carPresence)
|
||||
|
||||
@@ -71,7 +71,7 @@ def updated() {
|
||||
private subscribeToEvents()
|
||||
{
|
||||
subscribe intrusionMotions, "motion", intruderMotion
|
||||
subscribe residentMotions, "motion", residentMotion
|
||||
// subscribe residentMotions, "motion", residentMotion
|
||||
subscribe intrusionContacts, "contact", contact
|
||||
subscribe alarms, "alarm", alarm
|
||||
subscribe(app, appTouch)
|
||||
@@ -156,6 +156,7 @@ def residentMotion(evt)
|
||||
// startReArmSequence()
|
||||
// }
|
||||
//}
|
||||
unsubscribe(residentMotions)
|
||||
}
|
||||
|
||||
def contact(evt)
|
||||
@@ -214,7 +215,7 @@ def checkForReArm()
|
||||
}
|
||||
else {
|
||||
log.warn "checkForReArm: lastIntruderMotion was null, unable to check for re-arming intrusion detection"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private startAlarmSequence()
|
||||
|
||||
@@ -48,7 +48,7 @@ def updated()
|
||||
|
||||
def contactOpenHandler(evt) {
|
||||
log.trace "$evt.value: $evt, $settings"
|
||||
log.debug "$contact1 was opened, texting $phone1"
|
||||
log.debug "$contact1 was opened, sending text"
|
||||
if (location.contactBookEnabled) {
|
||||
sendNotificationToContacts("Your ${contact1.label ?: contact1.name} was opened", recipients)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ def updated() {
|
||||
|
||||
def motionActiveHandler(evt) {
|
||||
log.trace "$evt.value: $evt, $settings"
|
||||
|
||||
|
||||
if (presence1.latestValue("presence") == "not present") {
|
||||
// Don't send a continuous stream of text messages
|
||||
def deltaSeconds = 10
|
||||
@@ -60,14 +60,14 @@ def motionActiveHandler(evt) {
|
||||
def alreadySentSms = recentEvents.count { it.value && it.value == "active" } > 1
|
||||
|
||||
if (alreadySentSms) {
|
||||
log.debug "SMS already sent to $phone1 within the last $deltaSeconds seconds"
|
||||
log.debug "SMS already sent within the last $deltaSeconds seconds"
|
||||
} else {
|
||||
if (location.contactBookEnabled) {
|
||||
log.debug "$motion1 has moved while you were out, sending notifications to: ${recipients?.size()}"
|
||||
sendNotificationToContacts("${motion1.label} ${motion1.name} moved while you were out", recipients)
|
||||
}
|
||||
else {
|
||||
log.debug "$motion1 has moved while you were out, texting $phone1"
|
||||
log.debug "$motion1 has moved while you were out, sending text"
|
||||
sendSms(phone1, "${motion1.label} ${motion1.name} moved while you were out")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,13 +53,13 @@ def accelerationActiveHandler(evt) {
|
||||
def alreadySentSms = recentEvents.count { it.value && it.value == "active" } > 1
|
||||
|
||||
if (alreadySentSms) {
|
||||
log.debug "SMS already sent to $phone1 within the last $deltaSeconds seconds"
|
||||
log.debug "SMS already sent to phone within the last $deltaSeconds seconds"
|
||||
} else {
|
||||
if (location.contactBookEnabled) {
|
||||
sendNotificationToContacts("Gun case has moved!", recipients)
|
||||
}
|
||||
else {
|
||||
log.debug "$accelerationSensor has moved, texting $phone1"
|
||||
log.debug "$accelerationSensor has moved, texting phone"
|
||||
sendSms(phone1, "Gun case has moved!")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ def firstPage()
|
||||
def lightSwitchesDiscovered = lightSwitchesDiscovered()
|
||||
|
||||
return dynamicPage(name:"firstPage", title:"Discovery Started!", nextPage:"", refreshInterval: refreshInterval, install:true, uninstall: true) {
|
||||
section { paragraph title: "Note:", "This device has not been officially tested and certified to “Work with SmartThings”. You can connect it to your SmartThings home but performance may vary and we will not be able to provide support or assistance." }
|
||||
section("Select a device...") {
|
||||
input "selectedSwitches", "enum", required:false, title:"Select Wemo Switches \n(${switchesDiscovered.size() ?: 0} found)", multiple:true, options:switchesDiscovered
|
||||
input "selectedMotions", "enum", required:false, title:"Select Wemo Motions \n(${motionsDiscovered.size() ?: 0} found)", multiple:true, options:motionsDiscovered
|
||||
@@ -681,4 +682,4 @@ private Boolean hasAllHubsOver(String desiredFirmware) {
|
||||
|
||||
private List getRealHubFirmwareVersions() {
|
||||
return location.hubs*.firmwareVersionString.findAll { it }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ def authPage() {
|
||||
|
||||
def oauthInitUrl() {
|
||||
def token = getToken()
|
||||
log.debug "initiateOauth got token: $token"
|
||||
//log.debug "initiateOauth got token: $token"
|
||||
|
||||
// store these for validate after the user takes the oauth journey
|
||||
state.oauth_request_token = token.oauth_token
|
||||
@@ -76,7 +76,7 @@ def getToken() {
|
||||
]
|
||||
def requestTokenBaseUrl = "https://oauth.withings.com/account/request_token"
|
||||
def url = buildSignedUrl(requestTokenBaseUrl, params)
|
||||
log.debug "getToken - url: $url"
|
||||
//log.debug "getToken - url: $url"
|
||||
|
||||
return getJsonFromUrl(url)
|
||||
}
|
||||
@@ -182,7 +182,7 @@ def exchangeToken() {
|
||||
|
||||
def requestTokenBaseUrl = "https://oauth.withings.com/account/access_token"
|
||||
def url = buildSignedUrl(requestTokenBaseUrl, params, tokenSecret)
|
||||
log.debug "signed url: $url with secret $tokenSecret"
|
||||
//log.debug "signed url: $url with secret $tokenSecret"
|
||||
|
||||
def token = getJsonFromUrl(url)
|
||||
|
||||
@@ -198,8 +198,8 @@ def exchangeToken() {
|
||||
|
||||
def load() {
|
||||
def json = get(getMeasurement(new Date() - 30))
|
||||
|
||||
log.debug "swapped, then received: $json"
|
||||
// removed logging of actual json payload. Can be put back for debugging
|
||||
log.debug "swapped, then received json"
|
||||
parse(data:json)
|
||||
|
||||
def html = """
|
||||
|
||||
Reference in New Issue
Block a user