mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-18 05:10:52 +00:00
Compare commits
38 Commits
MSA-1577-2
...
PROD_2016.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
083ed7cc9a | ||
|
|
38ef9e5c77 | ||
|
|
6a71615ca5 | ||
|
|
9939591005 | ||
|
|
d7f2bc1d79 | ||
|
|
3c5d727d4c | ||
|
|
df6c815aa4 | ||
|
|
d16ac00eb6 | ||
|
|
1941f56007 | ||
|
|
f34df19a65 | ||
|
|
af40246655 | ||
|
|
20239ca982 | ||
|
|
b20c0e371f | ||
|
|
60756e6dc6 | ||
|
|
ee2e1ee04f | ||
|
|
e443cb641c | ||
|
|
b9993a9bf2 | ||
|
|
092971c786 | ||
|
|
a8ee927893 | ||
|
|
51979f0030 | ||
|
|
61d1205e7d | ||
|
|
1dfd1818b4 | ||
|
|
1de73b643c | ||
|
|
e5c21ef720 | ||
|
|
fcb504f57e | ||
|
|
b9229c6ef8 | ||
|
|
91a9856a32 | ||
|
|
a84ffdde91 | ||
|
|
3034cc8bcb | ||
|
|
918e9d9397 | ||
|
|
0c040120cc | ||
|
|
6c84c052cb | ||
|
|
f017bff6ef | ||
|
|
65bb10d6d6 | ||
|
|
3f93de247b | ||
|
|
2b7af3ef8d | ||
|
|
cf9d123aa0 | ||
|
|
4b44460b0b |
@@ -120,6 +120,15 @@ def configure() {
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize() {
|
||||||
sendEvent(name: "numberOfButtons", value: 4)
|
sendEvent(name: "numberOfButtons", value: 4)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,15 @@ def configure() {
|
|||||||
return cmds
|
return cmds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize() {
|
||||||
sendEvent(name: "numberOfButtons", value: 4)
|
sendEvent(name: "numberOfButtons", value: 4)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ metadata {
|
|||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Refresh"
|
capability "Refresh"
|
||||||
capability "Music Player"
|
capability "Music Player"
|
||||||
capability "Polling"
|
capability "Health Check"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define all commands, ie, if you have a custom action not
|
* Define all commands, ie, if you have a custom action not
|
||||||
@@ -236,7 +236,33 @@ def parse(String event) {
|
|||||||
* @return action(s) to take or null
|
* @return action(s) to take or null
|
||||||
*/
|
*/
|
||||||
def installed() {
|
def installed() {
|
||||||
onAction("refresh")
|
// Notify health check about this device with timeout interval 12 minutes
|
||||||
|
sendEvent(name: "checkInterval", value: 12 * 60, data: [protocol: "lan", hubHardwareId: device.hub.hardwareID], displayed: false)
|
||||||
|
startPoll()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by health check if no events been generated in the last 12 minutes
|
||||||
|
* If device doesn't respond it will be marked offline (not available)
|
||||||
|
*/
|
||||||
|
def ping() {
|
||||||
|
TRACE("ping")
|
||||||
|
boseSendGetNowPlaying()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Schedule a 2 minute poll of the device to refresh the
|
||||||
|
* tiles so the user gets the correct information.
|
||||||
|
*/
|
||||||
|
def startPoll() {
|
||||||
|
TRACE("startPoll")
|
||||||
|
unschedule()
|
||||||
|
// Schedule 2 minute polling of speaker status (song average length is 3-4 minutes)
|
||||||
|
def sec = Math.round(Math.floor(Math.random() * 60))
|
||||||
|
//def cron = "$sec 0/5 * * * ?" // every 5 min
|
||||||
|
def cron = "$sec 0/2 * * * ?" // every 2 min
|
||||||
|
log.debug "schedule('$cron', boseSendGetNowPlaying)"
|
||||||
|
schedule(cron, boseSendGetNowPlaying)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -316,14 +342,6 @@ def onAction(String user, data=null) {
|
|||||||
return actions
|
return actions
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Called every so often (every 5 minutes actually) to refresh the
|
|
||||||
* tiles so the user gets the correct information.
|
|
||||||
*/
|
|
||||||
def poll() {
|
|
||||||
return boseRefreshNowPlaying()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Joins this speaker into the everywhere zone
|
* Joins this speaker into the everywhere zone
|
||||||
*/
|
*/
|
||||||
@@ -837,6 +855,10 @@ def boseRefreshNowPlaying(delay=0) {
|
|||||||
return boseGET("/now_playing")
|
return boseGET("/now_playing")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def boseSendGetNowPlaying() {
|
||||||
|
sendHubCommand(boseGET("/now_playing"))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests the list of presets
|
* Requests the list of presets
|
||||||
*
|
*
|
||||||
@@ -1015,3 +1037,7 @@ def boseGetDeviceID() {
|
|||||||
def getDeviceIP() {
|
def getDeviceIP() {
|
||||||
return parent.resolveDNI2Address(device.deviceNetworkId)
|
return parent.resolveDNI2Address(device.deviceNetworkId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def TRACE(text) {
|
||||||
|
log.trace "${text}"
|
||||||
|
}
|
||||||
@@ -183,6 +183,15 @@ def updateState(String name, String value) {
|
|||||||
device.updateDataValue(name, value)
|
device.updateDataValue(name, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize() {
|
||||||
sendEvent(name: "numberOfButtons", value: 3)
|
sendEvent(name: "numberOfButtons", value: 3)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ metadata {
|
|||||||
void installed() {
|
void installed() {
|
||||||
// The device refreshes every 5 minutes by default so if we miss 2 refreshes we can consider it offline
|
// The device refreshes every 5 minutes by default so if we miss 2 refreshes we can consider it offline
|
||||||
// Using 12 minutes because in testing, device health team found that there could be "jitter"
|
// Using 12 minutes because in testing, device health team found that there could be "jitter"
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "cloud", hubHardwareId: device.hub.hardwareID], displayed: false)
|
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "cloud"], displayed: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Device Watch will ping the device to proactively determine if the device has gone offline
|
// Device Watch will ping the device to proactively determine if the device has gone offline
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ metadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def generatePresenceEvent(boolean present) {
|
def generatePresenceEvent(boolean present) {
|
||||||
log.debug "Here in generatePresenceEvent!"
|
log.info "Life360 generatePresenceEvent($present)"
|
||||||
def value = formatValue(present)
|
def value = formatValue(present)
|
||||||
def linkText = getLinkText(device)
|
def linkText = getLinkText(device)
|
||||||
def descriptionText = formatDescriptionText(linkText, present)
|
def descriptionText = formatDescriptionText(linkText, present)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ def parse(String description) {
|
|||||||
|
|
||||||
def event = [:]
|
def event = [:]
|
||||||
def finalResult = isKnownDescription(description)
|
def finalResult = isKnownDescription(description)
|
||||||
if (finalResult != "false") {
|
if (finalResult) {
|
||||||
log.info finalResult
|
log.info finalResult
|
||||||
if (finalResult.type == "update") {
|
if (finalResult.type == "update") {
|
||||||
log.info "$device updates: ${finalResult.value}"
|
log.info "$device updates: ${finalResult.value}"
|
||||||
@@ -212,13 +212,16 @@ def isKnownDescription(description) {
|
|||||||
else if (descMap.cluster == "0B04" || descMap.clusterId == "0B04"){
|
else if (descMap.cluster == "0B04" || descMap.clusterId == "0B04"){
|
||||||
isDescriptionPower(descMap)
|
isDescriptionPower(descMap)
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return [:]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(description?.startsWith("on/off:")) {
|
else if(description?.startsWith("on/off:")) {
|
||||||
def switchValue = description?.endsWith("1") ? "on" : "off"
|
def switchValue = description?.endsWith("1") ? "on" : "off"
|
||||||
return [type: "switch", value : switchValue]
|
return [type: "switch", value : switchValue]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "false"
|
return [:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +255,7 @@ def isDescriptionOnOff(descMap) {
|
|||||||
return [type: "switch", value : switchValue]
|
return [type: "switch", value : switchValue]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "false"
|
return [:]
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -279,10 +282,9 @@ def isDescriptionLevel(descMap) {
|
|||||||
|
|
||||||
if (dimmerValue != -1){
|
if (dimmerValue != -1){
|
||||||
return [type: "level", value : dimmerValue]
|
return [type: "level", value : dimmerValue]
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "false"
|
return [:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +306,7 @@ def isDescriptionPower(descMap) {
|
|||||||
return [type: "power", value : powerValue]
|
return [type: "power", value : powerValue]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "false"
|
return [:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00){
|
if (cluster.data[0] == 0x00){
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00) {
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ def parse(String description) {
|
|||||||
|
|
||||||
private Map parseBasicMessage(description) {
|
private Map parseBasicMessage(description) {
|
||||||
def name = parseName(description)
|
def name = parseName(description)
|
||||||
|
def results = [:]
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
def value = parseValue(description)
|
def value = parseValue(description)
|
||||||
def linkText = getLinkText(device)
|
def linkText = getLinkText(device)
|
||||||
@@ -64,7 +65,7 @@ private Map parseBasicMessage(description) {
|
|||||||
def handlerName = value
|
def handlerName = value
|
||||||
def isStateChange = isStateChange(device, name, value)
|
def isStateChange = isStateChange(device, name, value)
|
||||||
|
|
||||||
def results = [
|
results = [
|
||||||
name : name,
|
name : name,
|
||||||
value : value,
|
value : value,
|
||||||
linkText : linkText,
|
linkText : linkText,
|
||||||
@@ -73,8 +74,6 @@ private Map parseBasicMessage(description) {
|
|||||||
isStateChange : isStateChange,
|
isStateChange : isStateChange,
|
||||||
displayed : displayed(description, isStateChange)
|
displayed : displayed(description, isStateChange)
|
||||||
]
|
]
|
||||||
} else {
|
|
||||||
results = [:]
|
|
||||||
}
|
}
|
||||||
log.debug "Parse returned $results.descriptionText"
|
log.debug "Parse returned $results.descriptionText"
|
||||||
return results
|
return results
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if(cluster.data[0] == 0x00) {
|
if(cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
@@ -339,7 +339,7 @@ private Map getContactResult(value) {
|
|||||||
log.debug "Contact: ${device.displayName} value = ${value}"
|
log.debug "Contact: ${device.displayName} value = ${value}"
|
||||||
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
|
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
|
||||||
sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
|
sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
|
||||||
sendEvent(name: 'status', value: value, descriptionText: descriptionText, translatable: true)
|
return [name: 'status', value: value, descriptionText: descriptionText, translatable: true]
|
||||||
}
|
}
|
||||||
|
|
||||||
private getAccelerationResult(numValue) {
|
private getAccelerationResult(numValue) {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07){
|
if (cluster.command == 0x07){
|
||||||
if (cluster.data[0] == 0x00) {
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ private Map parseCatchAllMessage(String description) {
|
|||||||
if (cluster.command == 0x07) {
|
if (cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00){
|
if (cluster.data[0] == 0x00){
|
||||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
|
|||||||
@@ -126,6 +126,15 @@ private hold(button) {
|
|||||||
sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true)
|
sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
def initialize() {
|
||||||
sendEvent(name: "numberOfButtons", value: 4)
|
sendEvent(name: "numberOfButtons", value: 4)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,11 @@ metadata {
|
|||||||
|
|
||||||
|
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 ON/OFF/DIM", deviceJoinName: "OSRAM LIGHTIFY LED Smart Connected Light"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart A19 Soft White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FF00", outClusters: "0019", manufacturer: "MRVL", model: "MZ100", deviceJoinName: "Wemo Bulb"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FF00", outClusters: "0019", manufacturer: "MRVL", model: "MZ100", deviceJoinName: "Wemo Bulb"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B05", outClusters: "0019", manufacturer: "OSRAM SYLVANIA", model: "iQBR30", deviceJoinName: "Sylvania Ultra iQ"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B05", outClusters: "0019", manufacturer: "OSRAM SYLVANIA", model: "iQBR30", deviceJoinName: "Sylvania Ultra iQ"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY PAR38 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart PAR38 Soft White"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart BR30 Soft White"
|
||||||
}
|
}
|
||||||
|
|
||||||
tiles(scale: 2) {
|
tiles(scale: 2) {
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ metadata {
|
|||||||
capability "Switch Level"
|
capability "Switch Level"
|
||||||
capability "Health Check"
|
capability "Health Check"
|
||||||
|
|
||||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB", deviceJoinName: "OSRAM LIGHTIFY Gardenspot mini RGB"
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB"
|
||||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Gardenspot RGB", deviceJoinName: "OSRAM LIGHTIFY Gardenspot mini RGB"
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB"
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI tile definitions
|
// UI tile definitions
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ metadata {
|
|||||||
attribute "colorName", "string"
|
attribute "colorName", "string"
|
||||||
command "setGenericName"
|
command "setGenericName"
|
||||||
|
|
||||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY LED FLEXIBLE STRIP RGBW"
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Flex RGBW", deviceJoinName: "SYLVANIA Smart Flex RGBW"
|
||||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY LED FLEXIBLE STRIP RGBW"
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Flex RGBW"
|
||||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED A19 RGBW"
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 RGBW", deviceJoinName: "SYLVANIA Smart A19 RGBW"
|
||||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR RGBW", deviceJoinName: "OSRAM LIGHTIFY LED BR30 RGBW"
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR RGBW", deviceJoinName: "SYLVANIA Smart BR30 RGBW"
|
||||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT RGBW", deviceJoinName: "OSRAM LIGHTIFY LED RT 5/6 RGBW"
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT RGBW", deviceJoinName: "SYLVANIA Smart RT5/6 RGBW"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY FLEX OUTDOOR RGBW", deviceJoinName: "SYLVANIA Smart Outdoor RGBW Flex"
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI tile definitions
|
// UI tile definitions
|
||||||
|
|||||||
@@ -32,11 +32,12 @@ metadata {
|
|||||||
|
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04", outClusters: "0019"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04", outClusters: "0019"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Flood BR30 Tunable White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR Tunable White", deviceJoinName: "SYLVANIA Smart BR30 Tunable White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "OSRAM LIGHTIFY RT5/6 Tunable White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "SYLVANIA Smart RT5/6 Tunable White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "SYLVANIA Smart A19 Tunable White"
|
||||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
|
||||||
|
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0702, 0B05", outClusters: "0019", manufacturer: "sengled", model: "Z01-A19NAE26", deviceJoinName: "Sengled Element plus"
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI tile definitions
|
// UI tile definitions
|
||||||
@@ -83,105 +84,24 @@ def parse(String description) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Map bindingTable = parseBindingTableResponse(description)
|
def cluster = zigbee.parse(description)
|
||||||
if (bindingTable) {
|
|
||||||
List<String> cmds = []
|
|
||||||
bindingTable.table_entries.inject(cmds) { acc, entry ->
|
|
||||||
// The binding entry is not for our hub and should be deleted
|
|
||||||
if (entry["dstAddr"] != zigbeeEui) {
|
|
||||||
acc.addAll(removeBinding(entry.clusterId, entry.srcAddr, entry.srcEndpoint, entry.dstAddr, entry.dstEndpoint))
|
|
||||||
}
|
|
||||||
acc
|
|
||||||
}
|
|
||||||
// There are more entries that we haven't examined yet
|
|
||||||
if (bindingTable.numTableEntries > bindingTable.startIndex + bindingTable.numEntriesReturned) {
|
|
||||||
def startPos
|
|
||||||
if (cmds) {
|
|
||||||
log.warn "Removing binding entries for other devices: $cmds"
|
|
||||||
// Since we are removing some entries, we should start in the same spot as we just read since values
|
|
||||||
// will fill in the newly vacated spots
|
|
||||||
startPos = bindingTable.startIndex
|
|
||||||
} else {
|
|
||||||
// Since we aren't removing anything we move forward to the next set of table entries
|
|
||||||
startPos = bindingTable.startIndex + bindingTable.numEntriesReturned
|
|
||||||
}
|
|
||||||
cmds.addAll(requestBindingTable(startPos))
|
|
||||||
}
|
|
||||||
sendHubCommand(cmds.collect { it ->
|
|
||||||
new physicalgraph.device.HubAction(it)
|
|
||||||
}, 2000)
|
|
||||||
} else {
|
|
||||||
def cluster = zigbee.parse(description)
|
|
||||||
|
|
||||||
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
|
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
|
||||||
if (cluster.data[0] == 0x00) {
|
if (cluster.data[0] == 0x00) {
|
||||||
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
|
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
|
||||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||||
log.debug "${cluster}"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
||||||
|
log.debug "${cluster}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def parseBindingTableResponse(description) {
|
|
||||||
Map descMap = zigbee.parseDescriptionAsMap(description)
|
|
||||||
if (descMap["clusterInt"] == 0x8033) {
|
|
||||||
def header_field_lengths = ["transactionSeqNo": 1, "status": 1, "numTableEntries": 1, "startIndex": 1, "numEntriesReturned": 1]
|
|
||||||
def field_values = [:]
|
|
||||||
def data = descMap["data"]
|
|
||||||
header_field_lengths.each { k, v ->
|
|
||||||
field_values[k] = Integer.parseInt(data.take(v).join(""), 16);
|
|
||||||
data = data.drop(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Map> table = []
|
|
||||||
if (field_values.numEntriesReturned) {
|
|
||||||
def table_entry_lengths = ["srcAddr": 8, "srcEndpoint": 1, "clusterId": 2, "dstAddrMode": 1]
|
|
||||||
for (def i : 0..(field_values.numEntriesReturned - 1)) {
|
|
||||||
def entryMap = [:]
|
|
||||||
table_entry_lengths.each { k, v ->
|
|
||||||
def val = data.take(v).reverse().join("")
|
|
||||||
entryMap[k] = val.length() < 8 ? Integer.parseInt(val, 16) : val
|
|
||||||
data = data.drop(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (entryMap.dstAddrMode) {
|
|
||||||
case 0x01:
|
|
||||||
entryMap["dstAddr"] = data.take(2).reverse().join("")
|
|
||||||
data = data.drop(2)
|
|
||||||
break
|
|
||||||
case 0x03:
|
|
||||||
entryMap["dstAddr"] = data.take(8).reverse().join("")
|
|
||||||
data = data.drop(8)
|
|
||||||
entryMap["dstEndpoint"] = Integer.parseInt(data.take(1).join(""), 16)
|
|
||||||
data = data.drop(1)
|
|
||||||
break
|
|
||||||
}
|
|
||||||
table << entryMap
|
|
||||||
}
|
|
||||||
}
|
|
||||||
field_values["table_entries"] = table
|
|
||||||
return field_values
|
|
||||||
}
|
|
||||||
return [:]
|
|
||||||
}
|
|
||||||
|
|
||||||
def requestBindingTable(startPos=0) {
|
|
||||||
return ["zdo mgmt-bind 0x${zigbee.deviceNetworkId} $startPos"]
|
|
||||||
}
|
|
||||||
|
|
||||||
def removeBinding(cluster, srcAddr, srcEndpoint, destAddr, destEndpoint) {
|
|
||||||
return ["zdo unbind unicast 0x${zigbee.deviceNetworkId} {${srcAddr}} $srcEndpoint $cluster {${destAddr}} $destEndpoint"]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def off() {
|
def off() {
|
||||||
zigbee.off()
|
zigbee.off()
|
||||||
}
|
}
|
||||||
@@ -211,7 +131,8 @@ def configure() {
|
|||||||
// enrolls with default periodic reporting until newer 5 min interval is confirmed
|
// enrolls with default periodic reporting until newer 5 min interval is confirmed
|
||||||
sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
|
|
||||||
refresh() + requestBindingTable(0) + ["delay 2000"]
|
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
|
|||||||
@@ -127,8 +127,8 @@ def configureHealthCheck() {
|
|||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
log.debug "configure()"
|
log.debug "configure()"
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
|
||||||
configureHealthCheck()
|
configureHealthCheck()
|
||||||
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ metadata {
|
|||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 RGBW"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 RGBW"
|
||||||
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "PAR 16 50 RGBW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY RGBW PAR 16 50"
|
||||||
|
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Flex RGBW"
|
||||||
|
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenpole RGBW-Lightify", deviceJoinName: "OSRAM LIGHTIFY Gardenpole RGBW"
|
||||||
|
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Outdoor Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Outdoor Flex RGBW"
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI tile definitions
|
// UI tile definitions
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ metadata {
|
|||||||
|
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White"
|
||||||
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"PAR16 50 TW", deviceJoinName: "OSRAM LIGHTIFY LED PAR16 50 Tunable White"
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"PAR16 50 TW", deviceJoinName: "OSRAM LIGHTIFY LED PAR16 50 Tunable White"
|
||||||
|
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI tile definitions
|
// UI tile definitions
|
||||||
|
|||||||
@@ -1,662 +0,0 @@
|
|||||||
import javax.crypto.Mac;
|
|
||||||
import javax.crypto.spec.SecretKeySpec;
|
|
||||||
import java.security.InvalidKeyException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OpenT2T SmartApp Test
|
|
||||||
*
|
|
||||||
* Copyright 2016 OpenT2T
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
definition(
|
|
||||||
name: "OpenT2T SmartApp Test",
|
|
||||||
namespace: "opent2t",
|
|
||||||
author: "OpenT2T",
|
|
||||||
description: "Test app to test end to end SmartThings scenarios via OpenT2T",
|
|
||||||
category: "SmartThings Labs",
|
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
|
||||||
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png")
|
|
||||||
|
|
||||||
/** --------------------+---------------+-----------------------+------------------------------------
|
|
||||||
* Device Type | Attribute Name| Commands | Attribute Values
|
|
||||||
* --------------------+---------------+-----------------------+------------------------------------
|
|
||||||
* switches | switch | on, off | on, off
|
|
||||||
* motionSensors | motion | | active, inactive
|
|
||||||
* contactSensors | contact | | open, closed
|
|
||||||
* presenceSensors | presence | | present, 'not present'
|
|
||||||
* temperatureSensors | temperature | | <numeric, F or C according to unit>
|
|
||||||
* accelerationSensors | acceleration | | active, inactive
|
|
||||||
* waterSensors | water | | wet, dry
|
|
||||||
* lightSensors | illuminance | | <numeric, lux>
|
|
||||||
* humiditySensors | humidity | | <numeric, percent>
|
|
||||||
* locks | lock | lock, unlock | locked, unlocked
|
|
||||||
* garageDoors | door | open, close | unknown, closed, open, closing, opening
|
|
||||||
* cameras | image | take | <String>
|
|
||||||
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
|
|
||||||
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
|
|
||||||
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
|
|
||||||
* | | emergencyHeat, |
|
|
||||||
* | | setThermostatMode, |
|
|
||||||
* | | fanOn, fanAuto, |
|
|
||||||
* | | fanCirculate, |
|
|
||||||
* | | setThermostatFanMode |
|
|
||||||
* --------------------+---------------+-----------------------+------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Device Inputs
|
|
||||||
preferences {
|
|
||||||
section("Allow OpenT2T to control these things...") {
|
|
||||||
input "contactSensors", "capability.contactSensor", title: "Which Contact Sensors", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "garageDoors", "capability.garageDoorControl", title: "Which Garage Doors?", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "cameras", "capability.videoCapture", title: "Which Cameras?", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "motionSensors", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "presenceSensors", "capability.presenceSensor", title: "Which Presence Sensors", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "thermostats", "capability.thermostat", title: "Which Thermostat?", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
input "waterSensors", "capability.waterSensor", title: "Which Water Leak Sensors?", multiple: true, required: false, hideWhenEmpty: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def getInputs() {
|
|
||||||
def inputList = []
|
|
||||||
inputList += contactSensors?: []
|
|
||||||
inputList += garageDoors?: []
|
|
||||||
inputList += locks?: []
|
|
||||||
inputList += cameras?: []
|
|
||||||
inputList += motionSensors?: []
|
|
||||||
inputList += presenceSensors?: []
|
|
||||||
inputList += switches?: []
|
|
||||||
inputList += thermostats?: []
|
|
||||||
inputList += waterSensors?: []
|
|
||||||
return inputList
|
|
||||||
}
|
|
||||||
|
|
||||||
//API external Endpoints
|
|
||||||
mappings {
|
|
||||||
path("/devices") {
|
|
||||||
action: [
|
|
||||||
GET: "getDevices"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/devices/:id") {
|
|
||||||
action: [
|
|
||||||
GET: "getDevice"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/update/:id") {
|
|
||||||
action: [
|
|
||||||
PUT: "updateDevice"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/deviceSubscription") {
|
|
||||||
action: [
|
|
||||||
POST: "registerDeviceChange",
|
|
||||||
DELETE: "unregisterDeviceChange"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
path("/locationSubscription") {
|
|
||||||
action: [
|
|
||||||
POST: "registerDeviceGraph",
|
|
||||||
DELETE: "unregisterDeviceGraph"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def installed() {
|
|
||||||
log.debug "Installing with settings: ${settings}"
|
|
||||||
initialize()
|
|
||||||
}
|
|
||||||
|
|
||||||
def updated() {
|
|
||||||
log.debug "Updating with settings: ${settings}"
|
|
||||||
|
|
||||||
//Initialize state variables if didn't exist.
|
|
||||||
if( state.deviceSubscriptionMap == null ){
|
|
||||||
state.deviceSubscriptionMap = [:]
|
|
||||||
log.debug "deviceSubscriptionMap created."
|
|
||||||
}
|
|
||||||
if( state.locationSubscriptionMap == null ){
|
|
||||||
state.locationSubscriptionMap = [:]
|
|
||||||
log.debug "locationSubscriptionMap created."
|
|
||||||
}
|
|
||||||
if(state.verificationKeyMap == null){
|
|
||||||
state.verificationKeyMap = [:]
|
|
||||||
log.debug "verificationKeyMap created."
|
|
||||||
}
|
|
||||||
|
|
||||||
unsubscribe()
|
|
||||||
registerAllDeviceSubscriptions()
|
|
||||||
}
|
|
||||||
|
|
||||||
def initialize() {
|
|
||||||
log.debug "Initializing with settings: ${settings}"
|
|
||||||
state.deviceSubscriptionMap = [:]
|
|
||||||
log.debug "deviceSubscriptionMap created."
|
|
||||||
state.locationSubscriptionMap = [:]
|
|
||||||
log.debug "locationSubscriptionMap created."
|
|
||||||
state.verificationKeyMap = [:]
|
|
||||||
log.debug "verificationKeyMap created."
|
|
||||||
registerAllDeviceSubscriptions()
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Subscription Functions ***/
|
|
||||||
|
|
||||||
//Subscribe events for all devices
|
|
||||||
def registerAllDeviceSubscriptions() {
|
|
||||||
registerChangeHandler(inputs)
|
|
||||||
}
|
|
||||||
|
|
||||||
//Subscribe to events from a list of devices
|
|
||||||
def registerChangeHandler(myList) {
|
|
||||||
myList.each { myDevice ->
|
|
||||||
def theAtts = myDevice.supportedAttributes
|
|
||||||
theAtts.each {att ->
|
|
||||||
subscribe(myDevice, att.name, deviceEventHandler)
|
|
||||||
log.info "Registering for ${myDevice.displayName}.${att.name}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Endpoints function: Subscribe to events from a specific device
|
|
||||||
def registerDeviceChange() {
|
|
||||||
def subscriptionEndpt = params.subscriptionURL
|
|
||||||
def deviceId = params.deviceId
|
|
||||||
def myDevice = findDevice(deviceId)
|
|
||||||
|
|
||||||
if( myDevice == null ){
|
|
||||||
httpError(404, "Cannot find device with device ID ${deviceId}.")
|
|
||||||
}
|
|
||||||
|
|
||||||
def theAtts = myDevice.supportedAttributes
|
|
||||||
try {
|
|
||||||
theAtts.each {att ->
|
|
||||||
subscribe(myDevice, att.name, deviceEventHandler)
|
|
||||||
}
|
|
||||||
log.info "Subscribing for ${myDevice.displayName}"
|
|
||||||
|
|
||||||
if(subscriptionEndpt != null){
|
|
||||||
if(state.deviceSubscriptionMap[deviceId] == null){
|
|
||||||
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
|
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
|
||||||
} else if (!state.deviceSubscriptionMap[deviceId].contains(subscriptionEndpt)){
|
|
||||||
// state.deviceSubscriptionMap[deviceId] << subscriptionEndpt
|
|
||||||
// For now, we will only have one subscription endpoint per device
|
|
||||||
state.deviceSubscriptionMap.remove(deviceId)
|
|
||||||
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
|
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if(params.key != null){
|
|
||||||
state.verificationKeyMap[subscriptionEndpt] = params.key
|
|
||||||
log.info "Added verification key: ${params.key} for ${subscriptionEndpt}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
httpError(500, "something went wrong: $e")
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
|
|
||||||
log.info "Current verification key map is ${state.verificationKeyMap}"
|
|
||||||
return ["succeed"]
|
|
||||||
}
|
|
||||||
|
|
||||||
//Endpoints function: Unsubscribe to events from a specific device
|
|
||||||
def unregisterDeviceChange() {
|
|
||||||
def subscriptionEndpt = params.subscriptionURL
|
|
||||||
def deviceId = params.deviceId
|
|
||||||
def myDevice = findDevice(deviceId)
|
|
||||||
|
|
||||||
if( myDevice == null ){
|
|
||||||
httpError(404, "Cannot find device with device ID ${deviceId}.")
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
|
|
||||||
if (state.deviceSubscriptionMap[deviceId]?.contains(subscriptionEndpt)){
|
|
||||||
if(state.deviceSubscriptionMap[deviceId].size() == 1){
|
|
||||||
state.deviceSubscriptionMap.remove(deviceId)
|
|
||||||
} else {
|
|
||||||
state.deviceSubscriptionMap[deviceId].remove(subscriptionEndpt)
|
|
||||||
}
|
|
||||||
state.verificationKeyMap.remove(subscriptionEndpt)
|
|
||||||
log.info "Removed subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
state.deviceSubscriptionMap.remove(deviceId)
|
|
||||||
log.info "Unsubscriping for ${myDevice.displayName}"
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
httpError(500, "something went wrong: $e")
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
|
|
||||||
log.info "Current verification key map is ${state.verificationKeyMap}"
|
|
||||||
}
|
|
||||||
|
|
||||||
//Endpoints function: Subscribe to device additiona/removal updated in a location
|
|
||||||
def registerDeviceGraph() {
|
|
||||||
def subscriptionEndpt = params.subscriptionURL
|
|
||||||
|
|
||||||
if (subscriptionEndpt != null && subscriptionEndpt != "undefined"){
|
|
||||||
subscribe(location, "DeviceCreated", locationEventHandler, [filterEvents: false])
|
|
||||||
subscribe(location, "DeviceUpdated", locationEventHandler, [filterEvents: false])
|
|
||||||
subscribe(location, "DeviceDeleted", locationEventHandler, [filterEvents: false])
|
|
||||||
|
|
||||||
if(state.locationSubscriptionMap[location.id] == null){
|
|
||||||
state.locationSubscriptionMap.put(location.id, [subscriptionEndpt])
|
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
|
||||||
}else if (!state.locationSubscriptionMap[location.id].contains(subscriptionEndpt)){
|
|
||||||
state.locationSubscriptionMap[location.id] << subscriptionEndpt
|
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if(params.key != null){
|
|
||||||
state.verificationKeyMap[subscriptionEndpt] = params.key
|
|
||||||
log.info "Added verification key: ${params.key} for ${subscriptionEndpt}"
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
|
|
||||||
log.info "Current verification key map is ${state.verificationKeyMap}"
|
|
||||||
return ["succeed"]
|
|
||||||
} else {
|
|
||||||
httpError(400, "missing input parameter: subscriptionURL")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Endpoints function: Unsubscribe to events from a specific device
|
|
||||||
def unregisterDeviceGraph() {
|
|
||||||
def subscriptionEndpt = params.subscriptionURL
|
|
||||||
|
|
||||||
try {
|
|
||||||
if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
|
|
||||||
if (state.locationSubscriptionMap[location.id]?.contains(subscriptionEndpt)){
|
|
||||||
if(state.locationSubscriptionMap[location.id].size() == 1){
|
|
||||||
state.locationSubscriptionMap.remove(location.id)
|
|
||||||
} else {
|
|
||||||
state.locationSubscriptionMap[location.id].remove(subscriptionEndpt)
|
|
||||||
}
|
|
||||||
state.verificationKeyMap.remove(subscriptionEndpt)
|
|
||||||
log.info "Removed subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
httpError(400, "missing input parameter: subscriptionURL")
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
httpError(500, "something went wrong: $e")
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
|
|
||||||
log.info "Current verification key map is ${state.verificationKeyMap}"
|
|
||||||
}
|
|
||||||
|
|
||||||
//When events are triggered, send HTTP post to web socket servers
|
|
||||||
def deviceEventHandler(evt) {
|
|
||||||
def evtDevice = evt.device
|
|
||||||
def evtDeviceType = getDeviceType(evtDevice)
|
|
||||||
def deviceData = [];
|
|
||||||
|
|
||||||
if(evt.data != null){
|
|
||||||
def evtData = parseJson(evt.data)
|
|
||||||
log.info "Received event for ${evtDevice.displayName}, data: ${evtData}, description: ${evt.descriptionText}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if(evtDeviceType == "thermostat") {
|
|
||||||
deviceData = [name: evtDevice.displayName, id: evtDevice.id, status:evtDevice.status, deviceType:evtDeviceType, manufacturer:evtDevice.manufacturerName, model:evtDevice.modelName, attributes: deviceAttributeList(evtDevice, evtDeviceType), locationMode: getLocationModeInfo(), locationId: location.id ]
|
|
||||||
} else {
|
|
||||||
deviceData = [name: evtDevice.displayName, id: evtDevice.id, status:evtDevice.status, deviceType:evtDeviceType, manufacturer:evtDevice.manufacturerName, model:evtDevice.modelName, attributes: deviceAttributeList(evtDevice, evtDeviceType), locationId: location.id ]
|
|
||||||
}
|
|
||||||
|
|
||||||
def params = [ body: deviceData ]
|
|
||||||
|
|
||||||
//send event to all subscriptions urls
|
|
||||||
log.debug "Current subscription urls for ${evtDevice.displayName} is ${state.deviceSubscriptionMap[evtDevice.id]}"
|
|
||||||
state.deviceSubscriptionMap[evtDevice.id].each {
|
|
||||||
params.uri = "${it}"
|
|
||||||
if(state.verificationKeyMap[it] != null ){
|
|
||||||
def key = state.verificationKeyMap[it]
|
|
||||||
params.header = [Signature: ComputHMACValue(key, groovy.json.JsonOutput.toJson(params.body))]
|
|
||||||
}
|
|
||||||
log.trace "POST URI: ${params.uri}"
|
|
||||||
log.trace "Header: ${params.header}"
|
|
||||||
log.trace "Payload: ${params.body}"
|
|
||||||
try{
|
|
||||||
httpPostJson(params) { resp ->
|
|
||||||
log.trace "response status code: ${resp.status}"
|
|
||||||
log.trace "response data: ${resp.data}"
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
log.error "something went wrong: $e"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def locationEventHandler(evt) {
|
|
||||||
log.info "Received event for location ${location.name}/${location.id}, Event: ${evt.name}, description: ${evt.descriptionText}, apiServerUrl: ${apiServerUrl("")}"
|
|
||||||
switch(evt.name){
|
|
||||||
case "DeviceCreated":
|
|
||||||
case "DeviceDeleted":
|
|
||||||
def evtDevice = evt.device
|
|
||||||
def evtDeviceType = getDeviceType(evtDevice)
|
|
||||||
def params = [ body: [ eventType:evt.name, deviceId: evtDevice.id, locationId: location.id ] ]
|
|
||||||
|
|
||||||
if (evt.name == "DeviceDeleted" && state.deviceSubscriptionMap[deviceId] != null){
|
|
||||||
state.deviceSubscriptionMap.remove(evtDevice.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
state.locationSubscriptionMap[location.id].each {
|
|
||||||
params.uri = "${it}"
|
|
||||||
if(state.verificationKeyMap[it] != null ){
|
|
||||||
def key = state.verificationKeyMap[it]
|
|
||||||
params.header = [Signature: ComputHMACValue(key, groovy.json.JsonOutput.toJson(params.body))]
|
|
||||||
}
|
|
||||||
log.trace "POST URI: ${params.uri}"
|
|
||||||
log.trace "Header: ${params.header}"
|
|
||||||
log.trace "Payload: ${params.body}"
|
|
||||||
try{
|
|
||||||
httpPostJson(params) { resp ->
|
|
||||||
log.trace "response status code: ${resp.status}"
|
|
||||||
log.trace "response data: ${resp.data}"
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
log.error "something went wrong: $e"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case "DeviceUpdated":
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ComputHMACValue(key, data){
|
|
||||||
try {
|
|
||||||
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1")
|
|
||||||
Mac mac = Mac.getInstance("HmacSHA1")
|
|
||||||
mac.init(secretKeySpec)
|
|
||||||
byte[] digest = mac.doFinal(data.getBytes("UTF-8"))
|
|
||||||
return byteArrayToString(digest)
|
|
||||||
} catch (InvalidKeyException e) {
|
|
||||||
log.error "Invalid key exception while converting to HMac SHA1"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private def byteArrayToString(byte[] data) {
|
|
||||||
BigInteger bigInteger = new BigInteger(1, data)
|
|
||||||
String hash = bigInteger.toString(16)
|
|
||||||
return hash
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Device Query/Update Functions ***/
|
|
||||||
|
|
||||||
//Endpoints function: return all device data in json format
|
|
||||||
def getDevices() {
|
|
||||||
def deviceData = []
|
|
||||||
inputs?.each {
|
|
||||||
def deviceType = getDeviceType(it)
|
|
||||||
if(deviceType == "thermostat") {
|
|
||||||
deviceData << [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType), locationMode: getLocationModeInfo()]
|
|
||||||
} else {
|
|
||||||
deviceData << [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType)]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug "getDevices, return: ${deviceData}"
|
|
||||||
return deviceData
|
|
||||||
}
|
|
||||||
|
|
||||||
//Endpoints function: get device data
|
|
||||||
def getDevice() {
|
|
||||||
def it = findDevice(params.id)
|
|
||||||
def deviceType = getDeviceType(it)
|
|
||||||
def device
|
|
||||||
if(deviceType == "thermostat") {
|
|
||||||
device = [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it,deviceType), locationMode: getLocationModeInfo()]
|
|
||||||
} else {
|
|
||||||
device = [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType)]
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug "getDevice, return: ${device}"
|
|
||||||
return device
|
|
||||||
}
|
|
||||||
|
|
||||||
//Endpoints function: update device data
|
|
||||||
void updateDevice() {
|
|
||||||
def device = findDevice(params.id)
|
|
||||||
request.JSON.each {
|
|
||||||
def command = it.key
|
|
||||||
def value = it.value
|
|
||||||
if (command){
|
|
||||||
def commandList = mapDeviceCommands(command, value)
|
|
||||||
command = commandList[0]
|
|
||||||
value = commandList[1]
|
|
||||||
|
|
||||||
if (command == "setAwayMode") {
|
|
||||||
log.info "Setting away mode to ${value}"
|
|
||||||
if (location.modes?.find {it.name == value}) {
|
|
||||||
location.setMode(value)
|
|
||||||
}
|
|
||||||
}else if (command == "thermostatSetpoint"){
|
|
||||||
switch(device.currentThermostatMode){
|
|
||||||
case "cool":
|
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
|
||||||
device.setCoolingSetpoint(value)
|
|
||||||
break
|
|
||||||
case "heat":
|
|
||||||
case "emergency heat":
|
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
|
||||||
device.setHeatingSetpoint(value)
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}else if (!device) {
|
|
||||||
log.error "updateDevice, Device not found"
|
|
||||||
httpError(404, "Device not found")
|
|
||||||
} else if (!device.hasCommand(command)) {
|
|
||||||
log.error "updateDevice, Device does not have the command"
|
|
||||||
httpError(404, "Device does not have such command")
|
|
||||||
} else {
|
|
||||||
if (command == "setColor") {
|
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
|
||||||
device."$command"(hex: value)
|
|
||||||
} else if(value.isNumber()) {
|
|
||||||
def intValue = value as Integer
|
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
|
|
||||||
device."$command"(intValue)
|
|
||||||
} else if (value){
|
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
|
||||||
device."$command"(value)
|
|
||||||
} else {
|
|
||||||
log.info "Update: ${device.displayName}, [${command}]"
|
|
||||||
device."$command"()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*** Private Functions ***/
|
|
||||||
|
|
||||||
//Return current location mode info
|
|
||||||
private getLocationModeInfo() {
|
|
||||||
return [mode: location.mode, supported: location.modes.name]
|
|
||||||
}
|
|
||||||
|
|
||||||
//Map each device to a type given it's capabilities
|
|
||||||
private getDeviceType(device) {
|
|
||||||
def deviceType
|
|
||||||
def capabilities = device.capabilities
|
|
||||||
log.debug "capabilities: [${device}, ${capabilities}]"
|
|
||||||
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
|
||||||
|
|
||||||
//Loop through the device capability list to determine the device type.
|
|
||||||
capabilities.each {capability ->
|
|
||||||
switch(capability.name.toLowerCase())
|
|
||||||
{
|
|
||||||
case "switch":
|
|
||||||
deviceType = "switch"
|
|
||||||
|
|
||||||
//If the device also contains "Switch Level" capability, identify it as a "light" device.
|
|
||||||
if (capabilities.any{it.name.toLowerCase() == "switch level"}){
|
|
||||||
|
|
||||||
//If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device.
|
|
||||||
if (capabilities.any{it.name.toLowerCase() == "power meter"}){
|
|
||||||
deviceType = "dimmerSwitch"
|
|
||||||
return deviceType
|
|
||||||
} else {
|
|
||||||
deviceType = "light"
|
|
||||||
return deviceType
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case "garageDoorControl":
|
|
||||||
deviceType = "garageDoor"
|
|
||||||
return deviceType
|
|
||||||
case "lock":
|
|
||||||
deviceType = "lock"
|
|
||||||
return deviceType
|
|
||||||
case "video camera":
|
|
||||||
deviceType = "camera"
|
|
||||||
return deviceType
|
|
||||||
case "thermostat":
|
|
||||||
deviceType = "thermostat"
|
|
||||||
return deviceType
|
|
||||||
case "acceleration sensor":
|
|
||||||
case "contact sensor":
|
|
||||||
case "motion sensor":
|
|
||||||
case "presence sensor":
|
|
||||||
case "water sensor":
|
|
||||||
deviceType = "genericSensor"
|
|
||||||
return deviceType
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return deviceType
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return a specific device give the device ID.
|
|
||||||
private findDevice(deviceId) {
|
|
||||||
return inputs?.find { it.id == deviceId }
|
|
||||||
}
|
|
||||||
|
|
||||||
//Return a list of device attributes
|
|
||||||
private deviceAttributeList(device, deviceType) {
|
|
||||||
def attributeList = [:]
|
|
||||||
def allAttributes = device.supportedAttributes
|
|
||||||
allAttributes.each { attribute ->
|
|
||||||
try {
|
|
||||||
def currentState = device.currentState(attribute.name)
|
|
||||||
if(currentState != null ){
|
|
||||||
switch(attribute.name){
|
|
||||||
case 'temperature':
|
|
||||||
attributeList.putAll([ (attribute.name): currentState.value, 'temperatureScale':location.temperatureScale ])
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
attributeList.putAll([(attribute.name): currentState.value ])
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if( deviceType == "genericSensor" ){
|
|
||||||
def key = attribute.name + "_lastUpdated"
|
|
||||||
attributeList.putAll([ (key): currentState.isoDate ])
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
attributeList.putAll([ (attribute.name): null ]);
|
|
||||||
}
|
|
||||||
} catch(e) {
|
|
||||||
attributeList.putAll([ (attribute.name): null ]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return attributeList
|
|
||||||
}
|
|
||||||
|
|
||||||
//Map device command and value.
|
|
||||||
//input command and value are from UWP,
|
|
||||||
//returns resultCommand and resultValue that corresponds with function and value in SmartApps
|
|
||||||
private mapDeviceCommands(command, value) {
|
|
||||||
log.debug "mapDeviceCommands: [${command}, ${value}]"
|
|
||||||
def resultCommand = command
|
|
||||||
def resultValue = value
|
|
||||||
switch (command) {
|
|
||||||
case "switch":
|
|
||||||
if (value == 1 || value == "1" || value == "on") {
|
|
||||||
resultCommand = "on"
|
|
||||||
resultValue = ""
|
|
||||||
} else if (value == 0 || value == "0" || value == "off") {
|
|
||||||
resultCommand = "off"
|
|
||||||
resultValue = ""
|
|
||||||
}
|
|
||||||
break
|
|
||||||
// light attributes
|
|
||||||
case "level":
|
|
||||||
resultCommand = "setLevel"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "hue":
|
|
||||||
resultCommand = "setHue"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "saturation":
|
|
||||||
resultCommand = "setSaturation"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "colorTemperature":
|
|
||||||
resultCommand = "setColorTemperature"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "color":
|
|
||||||
resultCommand = "setColor"
|
|
||||||
resultValue = value
|
|
||||||
// thermostat attributes
|
|
||||||
case "hvacMode":
|
|
||||||
resultCommand = "setThermostatMode"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "fanMode":
|
|
||||||
resultCommand = "setThermostatFanMode"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "awayMode":
|
|
||||||
resultCommand = "setAwayMode"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "coolingSetpoint":
|
|
||||||
resultCommand = "setCoolingSetpoint"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "heatingSetpoint":
|
|
||||||
resultCommand = "setHeatingSetpoint"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
case "thermostatSetpoint":
|
|
||||||
resultCommand = "thermostatSetpoint"
|
|
||||||
resultValue = value
|
|
||||||
break
|
|
||||||
// lock attributes
|
|
||||||
case "locked":
|
|
||||||
if (value == 1 || value == "1" || value == "lock") {
|
|
||||||
resultCommand = "lock"
|
|
||||||
resultValue = ""
|
|
||||||
}
|
|
||||||
else if (value == 0 || value == "0" || value == "unlock") {
|
|
||||||
resultCommand = "unlock"
|
|
||||||
resultValue = ""
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
return [resultCommand,resultValue]
|
|
||||||
}
|
|
||||||
@@ -19,9 +19,9 @@
|
|||||||
author: "SmartThings",
|
author: "SmartThings",
|
||||||
description: "Control your Bose SoundTouch speakers",
|
description: "Control your Bose SoundTouch speakers",
|
||||||
category: "SmartThings Labs",
|
category: "SmartThings Labs",
|
||||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
iconUrl: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon.png",
|
||||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
iconX2Url: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon@2x.png",
|
||||||
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
iconX3Url: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon@2x-1.png",
|
||||||
singleInstance: true
|
singleInstance: true
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ def deviceDiscovery()
|
|||||||
|
|
||||||
return dynamicPage(name:"deviceDiscovery", title:"Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
return dynamicPage(name:"deviceDiscovery", title:"Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
||||||
section("Please wait while we discover your ${getDeviceName()}. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
section("Please wait while we discover your ${getDeviceName()}. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
||||||
input "selecteddevice", "enum", required:false, title:"Select ${getDeviceName()} (${numFound} found)", multiple:true, options:devices
|
input "selecteddevice", "enum", required:false, title:"Select ${getDeviceName()} (${numFound} found)", multiple:true, options:devices, submitOnChange: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,6 +196,8 @@ def addDevice(){
|
|||||||
d = addChildDevice(getNameSpace(), getDeviceName(), dni, newDevice?.value.hub, [label:"${deviceName}"])
|
d = addChildDevice(getNameSpace(), getDeviceName(), dni, newDevice?.value.hub, [label:"${deviceName}"])
|
||||||
d.boseSetDeviceID(newDevice.value.deviceID)
|
d.boseSetDeviceID(newDevice.value.deviceID)
|
||||||
log.trace "Created ${d.displayName} with id $dni"
|
log.trace "Created ${d.displayName} with id $dni"
|
||||||
|
// sync DTH with device, done here as it currently don't work from the DTH's installed() method
|
||||||
|
d.refresh()
|
||||||
} else {
|
} else {
|
||||||
log.trace "${d.displayName} with id $dni already exists"
|
log.trace "${d.displayName} with id $dni already exists"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,12 +289,12 @@ def initializeLife360Connection() {
|
|||||||
state.life360AccessToken = result.data.access_token
|
state.life360AccessToken = result.data.access_token
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
log.debug "Response=${result.data}"
|
log.info "Life360 initializeLife360Connection, response=${result.data}"
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
log.debug e
|
log.error "Life360 initializeLife360Connection, error: $e"
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,7 +656,7 @@ def generateInitialEvent (member, childDevice) {
|
|||||||
|
|
||||||
try { // we are going to just ignore any errors
|
try { // we are going to just ignore any errors
|
||||||
|
|
||||||
log.debug "Generate Initial Event for New Device for Member = ${member.id}"
|
log.info "Life360 generateInitialEvent($member, $childDevice)"
|
||||||
|
|
||||||
def place = state.places.find{it.id==settings.place}
|
def place = state.places.find{it.id==settings.place}
|
||||||
|
|
||||||
@@ -678,6 +678,8 @@ def generateInitialEvent (member, childDevice) {
|
|||||||
|
|
||||||
boolean isPresent = (distanceAway <= placeRadius)
|
boolean isPresent = (distanceAway <= placeRadius)
|
||||||
|
|
||||||
|
log.info "Life360 generateInitialEvent, member: ($memberLatitude, $memberLongitude), place: ($placeLatitude, $placeLongitude), radius: $placeRadius, dist: $distanceAway, present: $isPresent"
|
||||||
|
|
||||||
// log.debug "External Id=${app.id}:${member.id}"
|
// log.debug "External Id=${app.id}:${member.id}"
|
||||||
|
|
||||||
// def childDevice2 = getChildDevice("${app.id}.${member.id}")
|
// def childDevice2 = getChildDevice("${app.id}.${member.id}")
|
||||||
@@ -718,7 +720,7 @@ def haversine(lat1, lon1, lat2, lon2) {
|
|||||||
|
|
||||||
def placeEventHandler() {
|
def placeEventHandler() {
|
||||||
|
|
||||||
log.debug "In placeEventHandler method."
|
log.info "Life360 placeEventHandler: params=$params, settings.place=$settings.place"
|
||||||
|
|
||||||
// the POST to this end-point will look like:
|
// the POST to this end-point will look like:
|
||||||
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
||||||
@@ -729,8 +731,6 @@ def placeEventHandler() {
|
|||||||
def direction = params?.direction
|
def direction = params?.direction
|
||||||
def timestamp = params?.timestamp
|
def timestamp = params?.timestamp
|
||||||
|
|
||||||
log.debug "Life360 Event: Circle: ${circleId}, Place: ${placeId}, User: ${userId}, Direction: ${direction}"
|
|
||||||
|
|
||||||
if (placeId == settings.place) {
|
if (placeId == settings.place) {
|
||||||
|
|
||||||
def presenceState = (direction=="in")
|
def presenceState = (direction=="in")
|
||||||
@@ -745,10 +745,10 @@ def placeEventHandler() {
|
|||||||
|
|
||||||
if (deviceWrapper) {
|
if (deviceWrapper) {
|
||||||
deviceWrapper.generatePresenceEvent(presenceState)
|
deviceWrapper.generatePresenceEvent(presenceState)
|
||||||
log.debug "Event raised on child device: ${externalId}"
|
log.debug "Life360 event raised on child device: ${externalId}"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.debug "Couldn't find child device associated with inbound Life360 event."
|
log.warn "Life360 couldn't find child device associated with inbound Life360 event."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user