mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-19 13:20:53 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1241802315 | ||
|
|
0414ae0460 | ||
|
|
67006204da | ||
|
|
32e3916a85 | ||
|
|
dc1071d132 | ||
|
|
94f8b4ecfc | ||
|
|
239f771ac1 | ||
|
|
87b6715a00 | ||
|
|
d6a96317bf | ||
|
|
6d64212c93 | ||
|
|
088e746f99 | ||
|
|
c26701383e | ||
|
|
0b8f1d0168 | ||
|
|
b78337c96b | ||
|
|
9fcd327da2 | ||
|
|
c3ce69994e | ||
|
|
5bd03d1914 | ||
|
|
950780d30c | ||
|
|
8040ddd6f7 | ||
|
|
4863b2345e | ||
|
|
32b4914ba0 | ||
|
|
c76a2e807b | ||
|
|
617d53da43 |
@@ -34,8 +34,8 @@ metadata {
|
|||||||
preferences {
|
preferences {
|
||||||
section {
|
section {
|
||||||
image(name: 'educationalcontent', multiple: true, images: [
|
image(name: 'educationalcontent', multiple: true, images: [
|
||||||
"http://cdn.device-gse.smartthings.com/Arrival/Arrival1.png",
|
"http://cdn.device-gse.smartthings.com/Arrival/Arrival1.jpg",
|
||||||
"http://cdn.device-gse.smartthings.com/Arrival/Arrival2.png"
|
"http://cdn.device-gse.smartthings.com/Arrival/Arrival2.jpg"
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ metadata {
|
|||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
|
|
||||||
fingerprint deviceId: "0x1000", inClusters: "0x25,0x72,0x86,0x71,0x22,0x70"
|
fingerprint deviceId: "0x1000", inClusters: "0x25,0x72,0x86,0x71,0x22,0x70"
|
||||||
fingerprint deviceId: "0x1006", inClusters: "0x25"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulator metadata
|
// simulator metadata
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ def setLevel(value) {
|
|||||||
state.trigger = "setLevel"
|
state.trigger = "setLevel"
|
||||||
state.lvl = "${level}"
|
state.lvl = "${level}"
|
||||||
|
|
||||||
if (dimRate) {
|
if (dimRate && (state?.rate != null)) {
|
||||||
cmds << "st cmd 0x${device.deviceNetworkId} 1 8 4 {${level} ${state.rate}}"
|
cmds << "st cmd 0x${device.deviceNetworkId} 1 8 4 {${level} ${state.rate}}"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ metadata {
|
|||||||
preferences {
|
preferences {
|
||||||
section {
|
section {
|
||||||
image(name: 'educationalcontent', multiple: true, images: [
|
image(name: 'educationalcontent', multiple: true, images: [
|
||||||
"http://cdn.device-gse.smartthings.com/Outlet/US/OutletUS1.png",
|
"http://cdn.device-gse.smartthings.com/Outlet/US/OutletUS1.jpg",
|
||||||
"http://cdn.device-gse.smartthings.com/Outlet/US/OutletUS2.png"
|
"http://cdn.device-gse.smartthings.com/Outlet/US/OutletUS2.jpg"
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ metadata {
|
|||||||
preferences {
|
preferences {
|
||||||
section {
|
section {
|
||||||
image(name: 'educationalcontent', multiple: true, images: [
|
image(name: 'educationalcontent', multiple: true, images: [
|
||||||
"http://cdn.device-gse.smartthings.com/Motion/Motion1.png",
|
"http://cdn.device-gse.smartthings.com/Motion/Motion1.jpg",
|
||||||
"http://cdn.device-gse.smartthings.com/Motion/Motion2.png",
|
"http://cdn.device-gse.smartthings.com/Motion/Motion2.jpg",
|
||||||
"http://cdn.device-gse.smartthings.com/Motion/Motion3.png"
|
"http://cdn.device-gse.smartthings.com/Motion/Motion3.jpg"
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
section {
|
section {
|
||||||
|
|||||||
@@ -54,10 +54,10 @@
|
|||||||
preferences {
|
preferences {
|
||||||
section {
|
section {
|
||||||
image(name: 'educationalcontent', multiple: true, images: [
|
image(name: 'educationalcontent', multiple: true, images: [
|
||||||
"http://cdn.device-gse.smartthings.com/Multi/Multi1.png",
|
"http://cdn.device-gse.smartthings.com/Multi/Multi1.jpg",
|
||||||
"http://cdn.device-gse.smartthings.com/Multi/Multi2.png",
|
"http://cdn.device-gse.smartthings.com/Multi/Multi2.jpg",
|
||||||
"http://cdn.device-gse.smartthings.com/Multi/Multi3.png",
|
"http://cdn.device-gse.smartthings.com/Multi/Multi3.jpg",
|
||||||
"http://cdn.device-gse.smartthings.com/Multi/Multi4.png"
|
"http://cdn.device-gse.smartthings.com/Multi/Multi4.jpg"
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
section {
|
section {
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
/**
|
||||||
|
* 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 Water Valve", namespace: "smartthings", author: "SmartThings") {
|
||||||
|
capability "Actuator"
|
||||||
|
capability "Valve"
|
||||||
|
capability "Polling"
|
||||||
|
capability "Refresh"
|
||||||
|
capability "Sensor"
|
||||||
|
|
||||||
|
fingerprint deviceId: "0x1006", inClusters: "0x25"
|
||||||
|
}
|
||||||
|
|
||||||
|
// simulator metadata
|
||||||
|
simulator {
|
||||||
|
status "open": "command: 2503, payload: FF"
|
||||||
|
status "close": "command: 2503, payload: 00"
|
||||||
|
|
||||||
|
// reply messages
|
||||||
|
reply "2001FF,delay 100,2502": "command: 2503, payload: FF"
|
||||||
|
reply "200100,delay 100,2502": "command: 2503, payload: 00"
|
||||||
|
}
|
||||||
|
|
||||||
|
// tile definitions
|
||||||
|
tiles(scale: 2) {
|
||||||
|
multiAttributeTile(name:"valve", type: "generic", width: 6, height: 4, canChangeIcon: true){
|
||||||
|
tileAttribute ("device.contact", key: "PRIMARY_CONTROL") {
|
||||||
|
attributeState "open", label: '${name}', action: "valve.close", icon: "st.valves.water.open", backgroundColor: "#53a7c0", nextState:"closing"
|
||||||
|
attributeState "closed", label: '${name}', action: "valve.open", icon: "st.valves.water.closed", backgroundColor: "#e86d13", nextState:"opening"
|
||||||
|
attributeState "opening", label: '${name}', action: "valve.close", icon: "st.valves.water.open", backgroundColor: "#ffe71e"
|
||||||
|
attributeState "closing", label: '${name}', action: "valve.open", icon: "st.valves.water.closed", backgroundColor: "#ffe71e"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
standardTile("refresh", "device.contact", width: 2, height: 2, inactiveLabel: false, decoration: "flat") {
|
||||||
|
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "valve"
|
||||||
|
details(["valve","refresh"])
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def updated() {
|
||||||
|
response(refresh())
|
||||||
|
}
|
||||||
|
|
||||||
|
def parse(String description) {
|
||||||
|
log.trace "parse description : $description"
|
||||||
|
def result = null
|
||||||
|
def cmd = zwave.parse(description, [0x20: 1])
|
||||||
|
if (cmd) {
|
||||||
|
result = createEvent(zwaveEvent(cmd))
|
||||||
|
}
|
||||||
|
log.debug "Parse returned ${result?.descriptionText}"
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
|
||||||
|
def value = cmd.value == 0xFF ? "open" : cmd.value == 0x00 ? "closed" : "unknown"
|
||||||
|
[name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.manufacturerspecificv2.ManufacturerSpecificReport cmd) { //TODO should show MSR when device is discovered
|
||||||
|
log.debug "manufacturerId: ${cmd.manufacturerId}"
|
||||||
|
log.debug "manufacturerName: ${cmd.manufacturerName}"
|
||||||
|
log.debug "productId: ${cmd.productId}"
|
||||||
|
log.debug "productTypeId: ${cmd.productTypeId}"
|
||||||
|
def msr = String.format("%04X-%04X-%04X", cmd.manufacturerId, cmd.productTypeId, cmd.productId)
|
||||||
|
updateDataValue("MSR", msr)
|
||||||
|
[descriptionText: "$device.displayName MSR: $msr", isStateChange: false]
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.deviceresetlocallyv1.DeviceResetLocallyNotification cmd) {
|
||||||
|
[descriptionText: cmd.toString(), isStateChange: true, displayed: true]
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.commands.switchbinaryv1.SwitchBinaryReport cmd) {
|
||||||
|
def value = cmd.value == 0xFF ? "open" : cmd.value == 0x00 ? "closed" : "unknown"
|
||||||
|
[name: "contact", value: value, descriptionText: "$device.displayName valve is $value"]
|
||||||
|
}
|
||||||
|
|
||||||
|
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||||
|
[:] // Handles all Z-Wave commands we aren't interested in
|
||||||
|
}
|
||||||
|
|
||||||
|
def open() {
|
||||||
|
delayBetween([
|
||||||
|
zwave.basicV1.basicSet(value: 0xFF).format(),
|
||||||
|
zwave.switchBinaryV1.switchBinaryGet().format()
|
||||||
|
],10000) //wait for a water valve to be completely opened
|
||||||
|
}
|
||||||
|
|
||||||
|
def close() {
|
||||||
|
delayBetween([
|
||||||
|
zwave.basicV1.basicSet(value: 0x00).format(),
|
||||||
|
zwave.switchBinaryV1.switchBinaryGet().format()
|
||||||
|
],10000) //wait for a water valve to be completely closed
|
||||||
|
}
|
||||||
|
|
||||||
|
def poll() {
|
||||||
|
zwave.switchBinaryV1.switchBinaryGet().format()
|
||||||
|
}
|
||||||
|
|
||||||
|
def refresh() {
|
||||||
|
log.debug "refresh() is called"
|
||||||
|
def commands = [zwave.switchBinaryV1.switchBinaryGet().format()]
|
||||||
|
if (getDataValue("MSR") == null) {
|
||||||
|
commands << zwave.manufacturerSpecificV1.manufacturerSpecificGet().format()
|
||||||
|
}
|
||||||
|
delayBetween(commands,100)
|
||||||
|
}
|
||||||
@@ -68,6 +68,7 @@ def bridgeDiscovery(params=[:])
|
|||||||
log.trace "Cleaning old bridges memory"
|
log.trace "Cleaning old bridges memory"
|
||||||
state.bridges = [:]
|
state.bridges = [:]
|
||||||
state.bridgeRefreshCount = 0
|
state.bridgeRefreshCount = 0
|
||||||
|
app.updateSetting("selectedHue", "")
|
||||||
}
|
}
|
||||||
|
|
||||||
subscribe(location, null, locationHandler, [filterEvents:false])
|
subscribe(location, null, locationHandler, [filterEvents:false])
|
||||||
@@ -131,17 +132,24 @@ def bulbDiscovery() {
|
|||||||
state.bulbRefreshCount = bulbRefreshCount + 1
|
state.bulbRefreshCount = bulbRefreshCount + 1
|
||||||
def refreshInterval = 3
|
def refreshInterval = 3
|
||||||
state.inBulbDiscovery = true
|
state.inBulbDiscovery = true
|
||||||
|
def bridge = null
|
||||||
|
if (selectedHue) {
|
||||||
|
bridge = getChildDevice(selectedHue)
|
||||||
|
subscribe(bridge, "bulbList", bulbListData)
|
||||||
|
}
|
||||||
state.bridgeRefreshCount = 0
|
state.bridgeRefreshCount = 0
|
||||||
def options = bulbsDiscovered() ?: []
|
def bulboptions = bulbsDiscovered() ?: [:]
|
||||||
def numFound = options.size() ?: 0
|
def numFound = bulboptions.size() ?: 0
|
||||||
|
if (numFound == 0)
|
||||||
|
app.updateSetting("selectedBulbs", "")
|
||||||
|
|
||||||
if((bulbRefreshCount % 3) == 0) {
|
if((bulbRefreshCount % 3) == 0) {
|
||||||
discoverHueBulbs()
|
discoverHueBulbs()
|
||||||
}
|
}
|
||||||
|
|
||||||
return dynamicPage(name:"bulbDiscovery", title:"Bulb Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
return dynamicPage(name:"bulbDiscovery", title:"Bulb Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
||||||
section("Please wait while we discover your Hue Bulbs. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
section("Please wait while we discover your Hue Bulbs. 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 Bulbs (${numFound} found)", multiple:true, options:options
|
input "selectedBulbs", "enum", required:false, title:"Select Hue Bulbs (${numFound} found)", multiple:true, options:bulboptions
|
||||||
}
|
}
|
||||||
section {
|
section {
|
||||||
def title = getBridgeIP() ? "Hue bridge (${getBridgeIP()})" : "Find bridges"
|
def title = getBridgeIP() ? "Hue bridge (${getBridgeIP()})" : "Find bridges"
|
||||||
@@ -223,10 +231,14 @@ Map bulbsDiscovered() {
|
|||||||
bulbmap["${key}"] = value
|
bulbmap["${key}"] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bulbmap
|
return bulbmap
|
||||||
}
|
}
|
||||||
|
|
||||||
def getHueBulbs() {
|
def bulbListData(evt) {
|
||||||
|
state.bulbs = evt.jsonData
|
||||||
|
}
|
||||||
|
|
||||||
|
Map getHueBulbs() {
|
||||||
state.bulbs = state.bulbs ?: [:]
|
state.bulbs = state.bulbs ?: [:]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -252,7 +264,10 @@ def updated() {
|
|||||||
|
|
||||||
def initialize() {
|
def initialize() {
|
||||||
log.debug "Initializing"
|
log.debug "Initializing"
|
||||||
|
unsubscribe(bridge)
|
||||||
state.inBulbDiscovery = false
|
state.inBulbDiscovery = false
|
||||||
|
state.bridgeRefreshCount = 0
|
||||||
|
state.bulbRefreshCount = 0
|
||||||
if (selectedHue) {
|
if (selectedHue) {
|
||||||
addBridge()
|
addBridge()
|
||||||
addBulbs()
|
addBulbs()
|
||||||
@@ -276,9 +291,8 @@ def uninstalled(){
|
|||||||
// Handles events to add new bulbs
|
// Handles events to add new bulbs
|
||||||
def bulbListHandler(hub, data = "") {
|
def bulbListHandler(hub, data = "") {
|
||||||
def msg = "Bulbs list not processed. Only while in settings menu."
|
def msg = "Bulbs list not processed. Only while in settings menu."
|
||||||
log.trace "Here: $hub, $data"
|
def bulbs = [:]
|
||||||
if (state.inBulbDiscovery) {
|
if (state.inBulbDiscovery) {
|
||||||
def bulbs = [:]
|
|
||||||
def logg = ""
|
def logg = ""
|
||||||
log.trace "Adding bulbs to state..."
|
log.trace "Adding bulbs to state..."
|
||||||
state.bridgeProcessedLightList = true
|
state.bridgeProcessedLightList = true
|
||||||
@@ -287,15 +301,18 @@ def bulbListHandler(hub, data = "") {
|
|||||||
if (v instanceof Map)
|
if (v instanceof Map)
|
||||||
bulbs[k] = [id: k, name: v.name, type: v.type, hub:hub]
|
bulbs[k] = [id: k, name: v.name, type: v.type, hub:hub]
|
||||||
}
|
}
|
||||||
state.bulbs = bulbs
|
}
|
||||||
msg = "${bulbs.size()} bulbs found. $state.bulbs"
|
def bridge = null
|
||||||
}
|
if (selectedHue)
|
||||||
|
bridge = getChildDevice(selectedHue)
|
||||||
|
bridge.sendEvent(name: "bulbList", value: hub, data: bulbs, isStateChange: true, displayed: false)
|
||||||
|
msg = "${bulbs.size()} bulbs found. ${bulbs}"
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
def addBulbs() {
|
def addBulbs() {
|
||||||
def bulbs = getHueBulbs()
|
def bulbs = getHueBulbs()
|
||||||
selectedBulbs.each { dni ->
|
selectedBulbs?.each { dni ->
|
||||||
def d = getChildDevice(dni)
|
def d = getChildDevice(dni)
|
||||||
if(!d) {
|
if(!d) {
|
||||||
def newHueBulb
|
def newHueBulb
|
||||||
@@ -413,8 +430,11 @@ def locationHandler(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
networkAddress = d.latestState('networkAddress').stringValue
|
if (d.getDeviceDataByName("networkAddress"))
|
||||||
|
networkAddress = d.getDeviceDataByName("networkAddress")
|
||||||
|
else
|
||||||
|
networkAddress = d.latestState('networkAddress').stringValue
|
||||||
log.trace "Host: $host - $networkAddress"
|
log.trace "Host: $host - $networkAddress"
|
||||||
if(host != networkAddress) {
|
if(host != networkAddress) {
|
||||||
log.debug "Device's port or ip changed for device $d..."
|
log.debug "Device's port or ip changed for device $d..."
|
||||||
@@ -422,7 +442,8 @@ def locationHandler(evt) {
|
|||||||
dstate.port = port
|
dstate.port = port
|
||||||
dstate.name = "Philips hue ($ip)"
|
dstate.name = "Philips hue ($ip)"
|
||||||
d.sendEvent(name:"networkAddress", value: host)
|
d.sendEvent(name:"networkAddress", value: host)
|
||||||
}
|
d.updateDataValue("networkAddress", host)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -701,6 +722,11 @@ private getBridgeIP() {
|
|||||||
if (host == null || host == "") {
|
if (host == null || host == "") {
|
||||||
def serialNumber = selectedHue
|
def serialNumber = selectedHue
|
||||||
def bridge = getHueBridges().find { it?.value?.serialNumber?.equalsIgnoreCase(serialNumber) }?.value
|
def bridge = getHueBridges().find { it?.value?.serialNumber?.equalsIgnoreCase(serialNumber) }?.value
|
||||||
|
if (!bridge) {
|
||||||
|
//failed because mac address sent from hub is wrong and doesn't match the hue's real mac address and serial number
|
||||||
|
//in this case we will look up the bridge by comparing the incorrect mac addresses
|
||||||
|
bridge = getHueBridges().find { it?.value?.mac?.equalsIgnoreCase(serialNumber) }?.value
|
||||||
|
}
|
||||||
if (bridge?.ip && bridge?.port) {
|
if (bridge?.ip && bridge?.port) {
|
||||||
if (bridge?.ip.contains("."))
|
if (bridge?.ip.contains("."))
|
||||||
host = "${bridge?.ip}:${bridge?.port}"
|
host = "${bridge?.ip}:${bridge?.port}"
|
||||||
|
|||||||
@@ -0,0 +1,702 @@
|
|||||||
|
/**
|
||||||
|
* Home Remote
|
||||||
|
*
|
||||||
|
* Copyright 2015 The Home Remote
|
||||||
|
*
|
||||||
|
* 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: "Home Remote",
|
||||||
|
namespace: "thehomeremote.homeremote",
|
||||||
|
author: "The Home Remote",
|
||||||
|
description: "Web service that enables communication between the Home Remote app and a SmartThings hub.",
|
||||||
|
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",
|
||||||
|
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
||||||
|
oauth: [displayName: "The Home Remote", displayLink: "http://thehomeremote.com/"])
|
||||||
|
|
||||||
|
|
||||||
|
preferences {
|
||||||
|
section() {
|
||||||
|
input "accelerationSensors", "capability.accelerationSensor",title: "Acceleration Sensors", multiple: true, required: false
|
||||||
|
input "alarms", "capability.alarm",title: "Alarms", multiple: true, required: false
|
||||||
|
input "batteries", "capability.battery",title: "Batteries", multiple: true, required: false
|
||||||
|
input "beacons", "capability.beacon",title: "Beacons", multiple: true, required: false
|
||||||
|
input "buttonGroup", "capability.button",title: "Buttons", multiple: true, required: false
|
||||||
|
input "carbonMonoxideDetectors", "capability.carbonMonoxideDetector",title: "CO Detectors", multiple: true, required: false
|
||||||
|
input "colorControls", "capability.colorControl",title: "Color Lights", multiple: true, required: false
|
||||||
|
input "contactSensors", "capability.contactSensor",title: "Contact Sensors", multiple: true, required: false
|
||||||
|
input "doorControls", "capability.doorControl",title: "Door Controllers", multiple: true, required: false
|
||||||
|
input "energyMeters", "capability.energyMeter",title: "Energy Meters", multiple: true, required: false
|
||||||
|
input "illuminanceMeasurements", "capability.illuminanceMeasurement",title: "Illuminance Sensors", multiple: true, required: false
|
||||||
|
input "imageCaptures", "capability.imageCapture",title: "Cameras", multiple: true, required: false
|
||||||
|
input "locks", "capability.lock",title: "Locks", multiple: true, required: false
|
||||||
|
input "mediaControllers", "capability.mediaController",title: "Media Controllers", multiple: true, required: false
|
||||||
|
input "momentaries", "capability.momentary",title: "Momentary Buttons", multiple: true, required: false
|
||||||
|
input "motionSensors", "capability.motionSensor",title: "Motion Sensors", multiple: true, required: false
|
||||||
|
input "musicPlayers", "capability.musicPlayer",title: "Music Players", multiple: true, required: false
|
||||||
|
input "powerMeters", "capability.powerMeter",title: "Power Meters", multiple: true, required: false
|
||||||
|
input "presenceSensors", "capability.presenceSensor",title: "Presence Sensors", multiple: true, required: false
|
||||||
|
input "relativeHumidityMeasurements", "capability.relativeHumidityMeasurement",title: "Humidity Sensors", multiple: true, required: false
|
||||||
|
input "relaySwitches", "capability.relaySwitch",title: "Relays", multiple: true, required: false
|
||||||
|
input "signalStrengths", "capability.signalStrength",title: "Signal Strengths", multiple: true, required: false
|
||||||
|
input "sleepSensors", "capability.sleepSensor",title: "Sleep Sensors", multiple: true, required: false
|
||||||
|
input "smokeDetectors", "capability.smokeDetector",title: "Smoke Detectors", multiple: true, required: false
|
||||||
|
input "speechSyntheses", "capability.speechSynthesis",title: "Speech Syntheses", multiple: true, required: false
|
||||||
|
input "stepSensors", "capability.stepSensor",title: "Step Sensors", multiple: true, required: false
|
||||||
|
input "switches", "capability.switch",title: "Switches", multiple: true, required: false
|
||||||
|
input "switchLevels", "capability.switchLevel",title: "Dimmers", multiple: true, required: false
|
||||||
|
input "temperatureMeasurements", "capability.temperatureMeasurement",title: "Temperature Sensors", multiple: true, required: false
|
||||||
|
input "thermostats", "capability.thermostat",title: "Thermostats", multiple: true, required: false
|
||||||
|
input "threeAxes", "capability.threeAxis",title: "Three axis Sensors", multiple: true, required: false
|
||||||
|
input "tones", "capability.tone",title: "Tones", multiple: true, required: false
|
||||||
|
input "touchSensors", "capability.touchSensor",title: "Touch Sensors", multiple: true, required: false
|
||||||
|
input "valves", "capability.valve",title: "Valves", multiple: true, required: false
|
||||||
|
input "waterSensors", "capability.waterSensor",title: "Water Sensors", multiple: true, required: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mappings {
|
||||||
|
path("/GetCurrentValues") {
|
||||||
|
action: [
|
||||||
|
GET: "getCurrentValues"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/GetCurrentValuesWithDisplayName") {
|
||||||
|
action: [
|
||||||
|
GET: "getCurrentValuesWithDisplayName"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
path("/ExecuteCommand") {
|
||||||
|
action: [
|
||||||
|
PUT: "executeCommand"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def getCurrentValues() {
|
||||||
|
def resp = []
|
||||||
|
|
||||||
|
accelerationSensors.each {
|
||||||
|
resp << [id: it.id, capability: "AccelerationSensor", attribute: "acceleration", value: it.currentValue("acceleration")]
|
||||||
|
}
|
||||||
|
|
||||||
|
alarms.each {
|
||||||
|
resp << [id: it.id, capability: "Alarm", attribute: "alarm", value: it.currentValue("alarm")]
|
||||||
|
}
|
||||||
|
|
||||||
|
batteries.each {
|
||||||
|
resp << [id: it.id, capability: "Battery", attribute: "battery", value: it.currentValue("battery")]
|
||||||
|
}
|
||||||
|
|
||||||
|
beacons.each {
|
||||||
|
resp << [id: it.id, capability: "Beacon", attribute: "presence", value: it.currentValue("presence")]
|
||||||
|
}
|
||||||
|
|
||||||
|
buttonGroup.each {
|
||||||
|
resp << [id: it.id, capability: "Button", attribute: "button", value: it.currentValue("button")]
|
||||||
|
}
|
||||||
|
|
||||||
|
carbonMonoxideDetectors.each {
|
||||||
|
resp << [id: it.id, capability: "CarbonMonoxideDetector", attribute: "carbonMonoxide", value: it.currentValue("carbonMonoxide")]
|
||||||
|
}
|
||||||
|
|
||||||
|
colorControls.each {
|
||||||
|
resp << [id: it.id, capability: "ColorControl", attribute: "hue", value: it.currentValue("hue")]
|
||||||
|
}
|
||||||
|
|
||||||
|
colorControls.each {
|
||||||
|
resp << [id: it.id, capability: "ColorControl", attribute: "saturation", value: it.currentValue("saturation")]
|
||||||
|
}
|
||||||
|
|
||||||
|
colorControls.each {
|
||||||
|
resp << [id: it.id, capability: "ColorControl", attribute: "color", value: it.currentValue("color")]
|
||||||
|
}
|
||||||
|
|
||||||
|
contactSensors.each {
|
||||||
|
resp << [id: it.id, capability: "ContactSensor", attribute: "contact", value: it.currentValue("contact")]
|
||||||
|
}
|
||||||
|
|
||||||
|
doorControls.each {
|
||||||
|
resp << [id: it.id, capability: "DoorControl", attribute: "door", value: it.currentValue("door")]
|
||||||
|
}
|
||||||
|
|
||||||
|
energyMeters.each {
|
||||||
|
resp << [id: it.id, capability: "EnergyMeter", attribute: "energy", value: it.currentValue("energy")]
|
||||||
|
}
|
||||||
|
|
||||||
|
illuminanceMeasurements.each {
|
||||||
|
resp << [id: it.id, capability: "IlluminanceMeasurement", attribute: "illuminance", value: it.currentValue("illuminance")]
|
||||||
|
}
|
||||||
|
|
||||||
|
imageCaptures.each {
|
||||||
|
resp << [id: it.id, capability: "ImageCapture", attribute: "image", value: it.currentValue("image")]
|
||||||
|
}
|
||||||
|
|
||||||
|
locks.each {
|
||||||
|
resp << [id: it.id, capability: "Lock", attribute: "lock", value: it.currentValue("lock")]
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaControllers.each {
|
||||||
|
resp << [id: it.id, capability: "MediaController", attribute: "activities", value: it.currentValue("activities")]
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaControllers.each {
|
||||||
|
resp << [id: it.id, capability: "MediaController", attribute: "currentActivity", value: it.currentValue("currentActivity")]
|
||||||
|
}
|
||||||
|
|
||||||
|
motionSensors.each {
|
||||||
|
resp << [id: it.id, capability: "MotionSensor", attribute: "motion", value: it.currentValue("motion")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, capability: "MusicPlayer", attribute: "status", value: it.currentValue("status")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, capability: "MusicPlayer", attribute: "level", value: it.currentValue("level")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, capability: "MusicPlayer", attribute: "trackDescription", value: it.currentValue("trackDescription")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, capability: "MusicPlayer", attribute: "trackData", value: it.currentValue("trackData")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, capability: "MusicPlayer", attribute: "mute", value: it.currentValue("mute")]
|
||||||
|
}
|
||||||
|
|
||||||
|
powerMeters.each {
|
||||||
|
resp << [id: it.id, capability: "PowerMeter", attribute: "power", value: it.currentValue("power")]
|
||||||
|
}
|
||||||
|
|
||||||
|
presenceSensors.each {
|
||||||
|
resp << [id: it.id, capability: "PresenceSensor", attribute: "presence", value: it.currentValue("presence")]
|
||||||
|
}
|
||||||
|
|
||||||
|
relativeHumidityMeasurements.each {
|
||||||
|
resp << [id: it.id, capability: "RelativeHumidityMeasurement", attribute: "humidity", value: it.currentValue("humidity")]
|
||||||
|
}
|
||||||
|
|
||||||
|
relaySwitches.each {
|
||||||
|
resp << [id: it.id, capability: "RelaySwitch", attribute: "switch", value: it.currentValue("switch")]
|
||||||
|
}
|
||||||
|
|
||||||
|
signalStrengths.each {
|
||||||
|
resp << [id: it.id, capability: "SignalStrength", attribute: "lqi", value: it.currentValue("lqi")]
|
||||||
|
}
|
||||||
|
|
||||||
|
signalStrengths.each {
|
||||||
|
resp << [id: it.id, capability: "SignalStrength", attribute: "rssi", value: it.currentValue("rssi")]
|
||||||
|
}
|
||||||
|
|
||||||
|
sleepSensors.each {
|
||||||
|
resp << [id: it.id, capability: "SleepSensor", attribute: "sleeping", value: it.currentValue("sleeping")]
|
||||||
|
}
|
||||||
|
|
||||||
|
smokeDetectors.each {
|
||||||
|
resp << [id: it.id, capability: "SmokeDetector", attribute: "smoke", value: it.currentValue("smoke")]
|
||||||
|
}
|
||||||
|
|
||||||
|
stepSensors.each {
|
||||||
|
resp << [id: it.id, capability: "StepSensor", attribute: "steps", value: it.currentValue("steps")]
|
||||||
|
}
|
||||||
|
|
||||||
|
stepSensors.each {
|
||||||
|
resp << [id: it.id, capability: "StepSensor", attribute: "goal", value: it.currentValue("goal")]
|
||||||
|
}
|
||||||
|
|
||||||
|
switches.each {
|
||||||
|
resp << [id: it.id, capability: "Switch", attribute: "switch", value: it.currentValue("switch")]
|
||||||
|
}
|
||||||
|
|
||||||
|
switchLevels.each {
|
||||||
|
resp << [id: it.id, capability: "SwitchLevel", attribute: "level", value: it.currentValue("level")]
|
||||||
|
}
|
||||||
|
|
||||||
|
temperatureMeasurements.each {
|
||||||
|
resp << [id: it.id, capability: "TemperatureMeasurement", attribute: "temperature", value: it.currentValue("temperature")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, capability: "Thermostat", attribute: "temperature", value: it.currentValue("temperature")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, capability: "Thermostat", attribute: "heatingSetpoint", value: it.currentValue("heatingSetpoint")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, capability: "Thermostat", attribute: "coolingSetpoint", value: it.currentValue("coolingSetpoint")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, capability: "Thermostat", attribute: "thermostatSetpoint", value: it.currentValue("thermostatSetpoint")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, capability: "Thermostat", attribute: "thermostatMode", value: it.currentValue("thermostatMode")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, capability: "Thermostat", attribute: "thermostatFanMode", value: it.currentValue("thermostatFanMode")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, capability: "Thermostat", attribute: "thermostatOperatingState", value: it.currentValue("thermostatOperatingState")]
|
||||||
|
}
|
||||||
|
|
||||||
|
threeAxes.each {
|
||||||
|
resp << [id: it.id, capability: "ThreeAxis", attribute: "threeAxis", value: it.currentValue("threeAxis")]
|
||||||
|
}
|
||||||
|
|
||||||
|
touchSensors.each {
|
||||||
|
resp << [id: it.id, capability: "TouchSensor", attribute: "touch", value: it.currentValue("touch")]
|
||||||
|
}
|
||||||
|
|
||||||
|
valves.each {
|
||||||
|
resp << [id: it.id, capability: "Valve", attribute: "contact", value: it.currentValue("contact")]
|
||||||
|
}
|
||||||
|
|
||||||
|
waterSensors.each {
|
||||||
|
resp << [id: it.id, capability: "WaterSensor", attribute: "water", value: it.currentValue("water")]
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
def getCurrentValuesWithDisplayName() {
|
||||||
|
def resp = []
|
||||||
|
|
||||||
|
accelerationSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "AccelerationSensor", attribute: "acceleration", value: it.currentValue("acceleration")]
|
||||||
|
}
|
||||||
|
|
||||||
|
alarms.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Alarm", attribute: "alarm", value: it.currentValue("alarm")]
|
||||||
|
}
|
||||||
|
|
||||||
|
batteries.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Battery", attribute: "battery", value: it.currentValue("battery")]
|
||||||
|
}
|
||||||
|
|
||||||
|
beacons.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Beacon", attribute: "presence", value: it.currentValue("presence")]
|
||||||
|
}
|
||||||
|
|
||||||
|
buttonGroup.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Button", attribute: "button", value: it.currentValue("button")]
|
||||||
|
}
|
||||||
|
|
||||||
|
carbonMonoxideDetectors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "CarbonMonoxideDetector", attribute: "carbonMonoxide", value: it.currentValue("carbonMonoxide")]
|
||||||
|
}
|
||||||
|
|
||||||
|
colorControls.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "ColorControl", attribute: "hue", value: it.currentValue("hue")]
|
||||||
|
}
|
||||||
|
|
||||||
|
colorControls.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "ColorControl", attribute: "saturation", value: it.currentValue("saturation")]
|
||||||
|
}
|
||||||
|
|
||||||
|
colorControls.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "ColorControl", attribute: "color", value: it.currentValue("color")]
|
||||||
|
}
|
||||||
|
|
||||||
|
contactSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "ContactSensor", attribute: "contact", value: it.currentValue("contact")]
|
||||||
|
}
|
||||||
|
|
||||||
|
doorControls.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "DoorControl", attribute: "door", value: it.currentValue("door")]
|
||||||
|
}
|
||||||
|
|
||||||
|
energyMeters.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "EnergyMeter", attribute: "energy", value: it.currentValue("energy")]
|
||||||
|
}
|
||||||
|
|
||||||
|
illuminanceMeasurements.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "IlluminanceMeasurement", attribute: "illuminance", value: it.currentValue("illuminance")]
|
||||||
|
}
|
||||||
|
|
||||||
|
imageCaptures.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "ImageCapture", attribute: "image", value: it.currentValue("image")]
|
||||||
|
}
|
||||||
|
|
||||||
|
locks.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Lock", attribute: "lock", value: it.currentValue("lock")]
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaControllers.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MediaController", attribute: "activities", value: it.currentValue("activities")]
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaControllers.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MediaController", attribute: "currentActivity", value: it.currentValue("currentActivity")]
|
||||||
|
}
|
||||||
|
|
||||||
|
motionSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MotionSensor", attribute: "motion", value: it.currentValue("motion")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "status", value: it.currentValue("status")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "level", value: it.currentValue("level")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "trackDescription", value: it.currentValue("trackDescription")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "trackData", value: it.currentValue("trackData")]
|
||||||
|
}
|
||||||
|
|
||||||
|
musicPlayers.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "MusicPlayer", attribute: "mute", value: it.currentValue("mute")]
|
||||||
|
}
|
||||||
|
|
||||||
|
powerMeters.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "PowerMeter", attribute: "power", value: it.currentValue("power")]
|
||||||
|
}
|
||||||
|
|
||||||
|
presenceSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "PresenceSensor", attribute: "presence", value: it.currentValue("presence")]
|
||||||
|
}
|
||||||
|
|
||||||
|
relativeHumidityMeasurements.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "RelativeHumidityMeasurement", attribute: "humidity", value: it.currentValue("humidity")]
|
||||||
|
}
|
||||||
|
|
||||||
|
relaySwitches.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "RelaySwitch", attribute: "switch", value: it.currentValue("switch")]
|
||||||
|
}
|
||||||
|
|
||||||
|
signalStrengths.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "SignalStrength", attribute: "lqi", value: it.currentValue("lqi")]
|
||||||
|
}
|
||||||
|
|
||||||
|
signalStrengths.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "SignalStrength", attribute: "rssi", value: it.currentValue("rssi")]
|
||||||
|
}
|
||||||
|
|
||||||
|
sleepSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "SleepSensor", attribute: "sleeping", value: it.currentValue("sleeping")]
|
||||||
|
}
|
||||||
|
|
||||||
|
smokeDetectors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "SmokeDetector", attribute: "smoke", value: it.currentValue("smoke")]
|
||||||
|
}
|
||||||
|
|
||||||
|
stepSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "StepSensor", attribute: "steps", value: it.currentValue("steps")]
|
||||||
|
}
|
||||||
|
|
||||||
|
stepSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "StepSensor", attribute: "goal", value: it.currentValue("goal")]
|
||||||
|
}
|
||||||
|
|
||||||
|
switches.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Switch", attribute: "switch", value: it.currentValue("switch")]
|
||||||
|
}
|
||||||
|
|
||||||
|
switchLevels.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "SwitchLevel", attribute: "level", value: it.currentValue("level")]
|
||||||
|
}
|
||||||
|
|
||||||
|
temperatureMeasurements.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "TemperatureMeasurement", attribute: "temperature", value: it.currentValue("temperature")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "temperature", value: it.currentValue("temperature")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "heatingSetpoint", value: it.currentValue("heatingSetpoint")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "coolingSetpoint", value: it.currentValue("coolingSetpoint")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatSetpoint", value: it.currentValue("thermostatSetpoint")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatMode", value: it.currentValue("thermostatMode")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatFanMode", value: it.currentValue("thermostatFanMode")]
|
||||||
|
}
|
||||||
|
|
||||||
|
thermostats.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Thermostat", attribute: "thermostatOperatingState", value: it.currentValue("thermostatOperatingState")]
|
||||||
|
}
|
||||||
|
|
||||||
|
threeAxes.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "ThreeAxis", attribute: "threeAxis", value: it.currentValue("threeAxis")]
|
||||||
|
}
|
||||||
|
|
||||||
|
touchSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "TouchSensor", attribute: "touch", value: it.currentValue("touch")]
|
||||||
|
}
|
||||||
|
|
||||||
|
valves.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "Valve", attribute: "contact", value: it.currentValue("contact")]
|
||||||
|
}
|
||||||
|
|
||||||
|
waterSensors.each {
|
||||||
|
resp << [id: it.id, displayName: it.displayName, capability: "WaterSensor", attribute: "water", value: it.currentValue("water")]
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
def getDevices(capability){
|
||||||
|
|
||||||
|
def result
|
||||||
|
|
||||||
|
switch (capability) {
|
||||||
|
case "Alarm":
|
||||||
|
result = alarms
|
||||||
|
break
|
||||||
|
case "ColorControl":
|
||||||
|
result = colorControls
|
||||||
|
break
|
||||||
|
case "DoorControl":
|
||||||
|
result = doorControls
|
||||||
|
break
|
||||||
|
case "ImageCapture":
|
||||||
|
result = imageCaptures
|
||||||
|
break
|
||||||
|
case "Lock":
|
||||||
|
result = locks
|
||||||
|
break
|
||||||
|
case "MediaController":
|
||||||
|
result = mediaControllers
|
||||||
|
break
|
||||||
|
case "Momentary":
|
||||||
|
result = momentaries
|
||||||
|
break
|
||||||
|
case "MusicPlayer":
|
||||||
|
result = musicPlayers
|
||||||
|
break
|
||||||
|
case "RelaySwitch":
|
||||||
|
result = relaySwitches
|
||||||
|
break
|
||||||
|
case "SpeechSynthesis":
|
||||||
|
result = speechSyntheses
|
||||||
|
break
|
||||||
|
case "Switch":
|
||||||
|
result = switches
|
||||||
|
break
|
||||||
|
case "SwitchLevel":
|
||||||
|
result = switchLevels
|
||||||
|
break
|
||||||
|
case "Thermostat":
|
||||||
|
result = thermostats
|
||||||
|
break
|
||||||
|
case "ThermostatCoolingSetpoint":
|
||||||
|
result = thermostatCoolingSetpoints
|
||||||
|
break
|
||||||
|
case "ThermostatFanMode":
|
||||||
|
result = thermostatFanModes
|
||||||
|
break
|
||||||
|
case "ThermostatHeatingSetpoint":
|
||||||
|
result = thermostatHeatingSetpoints
|
||||||
|
break
|
||||||
|
case "ThermostatMode":
|
||||||
|
result = thermostatModes
|
||||||
|
break
|
||||||
|
case "Tone":
|
||||||
|
result = tones
|
||||||
|
break
|
||||||
|
case "Valve":
|
||||||
|
result = valves
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
result = valves
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
def getDoorControlCommand(value){
|
||||||
|
def result
|
||||||
|
switch (value) {
|
||||||
|
case "closed":
|
||||||
|
result = "close"
|
||||||
|
break
|
||||||
|
case "open":
|
||||||
|
result = "open"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
result = value
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
def getLockCommand(value){
|
||||||
|
def result
|
||||||
|
switch (value) {
|
||||||
|
case "locked":
|
||||||
|
result = "lock"
|
||||||
|
break
|
||||||
|
case "unlocked":
|
||||||
|
result = "unlock"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
result = value
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
def getMuteCommand(value){
|
||||||
|
def result
|
||||||
|
switch (value) {
|
||||||
|
case "muted":
|
||||||
|
result = "mute"
|
||||||
|
break
|
||||||
|
case "unmuted":
|
||||||
|
result = "unmute"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
result = value
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
def getContactCommand(value){
|
||||||
|
def result
|
||||||
|
switch (value) {
|
||||||
|
case "closed":
|
||||||
|
result = "close"
|
||||||
|
break
|
||||||
|
case "open":
|
||||||
|
result = "open"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
result = value
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
def getThermostatFanModeCommand(value){
|
||||||
|
def result
|
||||||
|
switch (value) {
|
||||||
|
case "on":
|
||||||
|
result = "fanOn"
|
||||||
|
break
|
||||||
|
case "auto":
|
||||||
|
result = "fanAuto"
|
||||||
|
break
|
||||||
|
case "circulate":
|
||||||
|
result = "fanCirculate"
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
result = value
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
void executeCommand() {
|
||||||
|
// use the built-in request object to get the command parameter
|
||||||
|
def deviceId = request.JSON?.deviceId
|
||||||
|
def capability = request.JSON?.capability
|
||||||
|
def attribute = request.JSON?.attribute
|
||||||
|
def value = request.JSON?.value
|
||||||
|
if (deviceId) {
|
||||||
|
def devices = getDevices(capability)
|
||||||
|
def command
|
||||||
|
def valueIsParameter = false
|
||||||
|
switch (attribute) {
|
||||||
|
case "hue":
|
||||||
|
command = "setHue"
|
||||||
|
valueIsParameter = true
|
||||||
|
break
|
||||||
|
case "saturation":
|
||||||
|
command = "setSaturation"
|
||||||
|
valueIsParameter = true
|
||||||
|
break
|
||||||
|
case "color":
|
||||||
|
command = "setColor"
|
||||||
|
valueIsParameter = true
|
||||||
|
break
|
||||||
|
case "level":
|
||||||
|
command = "setLevel"
|
||||||
|
valueIsParameter = true
|
||||||
|
break
|
||||||
|
case "heatingSetpoint":
|
||||||
|
command = "setHeatingSetpoint"
|
||||||
|
valueIsParameter = true
|
||||||
|
break
|
||||||
|
case "coolingSetpoint":
|
||||||
|
command = "setCoolingSetpoint"
|
||||||
|
valueIsParameter = true
|
||||||
|
break
|
||||||
|
case "currentActivity":
|
||||||
|
command = "startActivity"
|
||||||
|
valueIsParameter = true
|
||||||
|
break
|
||||||
|
case "door":
|
||||||
|
command = getDoorControlCommand(value)
|
||||||
|
break
|
||||||
|
case "lock":
|
||||||
|
command = getLockCommand(value)
|
||||||
|
break
|
||||||
|
case "mute":
|
||||||
|
command = getMuteCommand(value)
|
||||||
|
break
|
||||||
|
case "thermostatFanMode":
|
||||||
|
command = getThermostatFanModeCommand(value)
|
||||||
|
break
|
||||||
|
case "thermostatMode":
|
||||||
|
if (value == "emergency heat") {
|
||||||
|
command = "emergencyHeat"
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "contact":
|
||||||
|
command = getContactCommand(value)
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
command = value
|
||||||
|
}
|
||||||
|
// check that the switch supports the specified command
|
||||||
|
// If not, return an error using httpError, providing a HTTP status code.
|
||||||
|
devices.each {
|
||||||
|
if (it.id == deviceId) {
|
||||||
|
if (!it.hasCommand(command)) {
|
||||||
|
httpError(501, "$command is not a valid command for all devices specified")
|
||||||
|
}
|
||||||
|
if(valueIsParameter){
|
||||||
|
it."$command"(value)
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
it."$command"()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def installed() {}
|
||||||
|
|
||||||
|
def updated() {}
|
||||||
307
smartapps/weatherbug/weatherbug-home.src/weatherbug-home.groovy
Normal file
307
smartapps/weatherbug/weatherbug-home.src/weatherbug-home.groovy
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
/**
|
||||||
|
* WeatherBug Home
|
||||||
|
*
|
||||||
|
* Copyright 2015 WeatherBug
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
definition(
|
||||||
|
name: "WeatherBug Home",
|
||||||
|
namespace: "WeatherBug",
|
||||||
|
author: "WeatherBug Home",
|
||||||
|
description: "WeatherBug Home",
|
||||||
|
category: "My Apps",
|
||||||
|
iconUrl: "http://stg.static.myenergy.enqa.co/apps/wbhc/v2/images/weatherbughomemedium.png",
|
||||||
|
iconX2Url: "http://stg.static.myenergy.enqa.co/apps/wbhc/v2/images/weatherbughomemedium.png",
|
||||||
|
iconX3Url: "http://stg.static.myenergy.enqa.co/apps/wbhc/v2/images/weatherbughome.png",
|
||||||
|
oauth: [displayName: "WeatherBug Home", displayLink: "http://weatherbughome.com/"])
|
||||||
|
|
||||||
|
|
||||||
|
preferences {
|
||||||
|
section("Select thermostats") {
|
||||||
|
input "thermostatDevice", "capability.thermostat", multiple: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mappings {
|
||||||
|
path("/appInfo") { action: [ GET: "getAppInfo" ] }
|
||||||
|
path("/getLocation") { action: [ GET: "getLoc" ] }
|
||||||
|
path("/currentReport/:id") { action: [ GET: "getCurrentReport" ] }
|
||||||
|
path("/setTemp/:temp/:id") { action: [ POST: "setTemperature", GET: "setTemperature" ] }
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This API call will be leveraged by a WeatherBug Home Service to retrieve
|
||||||
|
* data from the installed SmartApp, including the location data, and
|
||||||
|
* a list of the devices that were authorized to be accessed. The WeatherBug
|
||||||
|
* Home Service will leverage this data to represent the connected devices as well as their
|
||||||
|
* location and associated the data with a WeatherBug user account.
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
* @return Location, including id, latitude, longitude, zip code, and name, and the list of devices
|
||||||
|
*/
|
||||||
|
def getAppInfo() {
|
||||||
|
def devices = thermostatDevice
|
||||||
|
def lat = location.latitude
|
||||||
|
def lon = location.longitude
|
||||||
|
if(!(devices instanceof Collection))
|
||||||
|
{
|
||||||
|
devices = [devices]
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
Id: UUID.randomUUID().toString(),
|
||||||
|
Code: 200,
|
||||||
|
ErrorMessage: null,
|
||||||
|
Result: [ "Devices": devices,
|
||||||
|
"Location":[
|
||||||
|
"Id": location.id,
|
||||||
|
"Latitude":lat,
|
||||||
|
"Longitude":lon,
|
||||||
|
"ZipCode":location.zipCode,
|
||||||
|
"Name":location.name
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This API call will be leveraged by a WeatherBug Home Service to retrieve
|
||||||
|
* location data from the installed SmartApp. The WeatherBug
|
||||||
|
* Home Service will leverage this data to associate the location to a WeatherBug Home account
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
*
|
||||||
|
* @return Location, including id, latitude, longitude, zip code, and name
|
||||||
|
*/
|
||||||
|
def getLoc() {
|
||||||
|
return [
|
||||||
|
Id: UUID.randomUUID().toString(),
|
||||||
|
Code: 200,
|
||||||
|
ErrorMessage: null,
|
||||||
|
Result: [
|
||||||
|
"Id": location.id,
|
||||||
|
"Latitude":location.latitude,
|
||||||
|
"Longitude":location.longitude,
|
||||||
|
"ZipCode":location.zipCode,
|
||||||
|
"Name":location.name]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This API call will be leveraged by a WeatherBug Home Service to retrieve
|
||||||
|
* thermostat data and store it for display to a WeatherBug user.
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
*
|
||||||
|
* @param id The id of the device to get data for
|
||||||
|
* @return Thermostat data including temperature, set points, running modes, and operating states
|
||||||
|
*/
|
||||||
|
def getCurrentReport() {
|
||||||
|
log.debug "device id parameter=" + params.id
|
||||||
|
def unixTime = (int)((new Date().getTime() / 1000))
|
||||||
|
def device = thermostatDevice.find{ it.id == params.id}
|
||||||
|
|
||||||
|
if(device == null)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Id: UUID.randomUUID().toString(),
|
||||||
|
Code: 404,
|
||||||
|
ErrorMessage: "Device not found. id=" + params.id,
|
||||||
|
Result: null
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
Id: UUID.randomUUID().toString(),
|
||||||
|
Code: 200,
|
||||||
|
ErrorMessage: null,
|
||||||
|
Result: [
|
||||||
|
DeviceId: device.id,
|
||||||
|
LocationId: location.id,
|
||||||
|
ReportType: 2,
|
||||||
|
ReportList: [
|
||||||
|
[Key: "Temperature", Value: GetOrDefault(device, "temperature")],
|
||||||
|
[Key: "ThermostatSetpoint", Value: GetOrDefault(device, "thermostatSetpoint")],
|
||||||
|
[Key: "CoolingSetpoint", Value: GetOrDefault(device, "coolingSetpoint")],
|
||||||
|
[Key: "HeatingSetpoint", Value: GetOrDefault(device, "heatingSetpoint")],
|
||||||
|
[Key: "ThermostatMode", Value: GetOrDefault(device, "thermostatMode")],
|
||||||
|
[Key: "ThermostatFanMode", Value: GetOrDefault(device, "thermostatFanMode")],
|
||||||
|
[Key: "ThermostatOperatingState", Value: GetOrDefault(device, "thermostatOperatingState")]
|
||||||
|
],
|
||||||
|
UnixTime: unixTime
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This API call will be leveraged by a WeatherBug Home Service to set
|
||||||
|
* the thermostat setpoint.
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
*
|
||||||
|
* @param id The id of the device to set
|
||||||
|
* @return Indication of whether the operation succeeded or failed
|
||||||
|
|
||||||
|
def setTemperature() {
|
||||||
|
log.debug "device id parameter=" + params.id
|
||||||
|
def device = thermostatDevice.find{ it.id == params.id}
|
||||||
|
if(device != null)
|
||||||
|
{
|
||||||
|
def mode = device.latestState('thermostatMode').stringValue
|
||||||
|
def value = params.temp as Integer
|
||||||
|
log.trace "Suggested temperature: $value, $mode"
|
||||||
|
if ( mode == "cool")
|
||||||
|
device.setCoolingSetpoint(value)
|
||||||
|
else if ( mode == "heat")
|
||||||
|
device.setHeatingSetpoint(value)
|
||||||
|
return [
|
||||||
|
Id: UUID.randomUUID().toString(),
|
||||||
|
Code: 200,
|
||||||
|
ErrorMessage: null,
|
||||||
|
Result: null
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
Id: UUID.randomUUID().toString(),
|
||||||
|
Code : 404,
|
||||||
|
ErrorMessage: "Device not found. id=" + params.id,
|
||||||
|
Result: null
|
||||||
|
]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
log.debug "Installed with settings: ${settings}"
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The updated event will be pushed to a WeatherBug Home Service to notify the system to take appropriate action.
|
||||||
|
* Data that will be sent includes the list of devices, and location data
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
*/
|
||||||
|
def updated() {
|
||||||
|
log.debug "Updated with settings: ${settings}"
|
||||||
|
log.debug "Updated with state: ${state}"
|
||||||
|
log.debug "Updated with location ${location} ${location.id} ${location.name}"
|
||||||
|
unsubscribe()
|
||||||
|
initialize()
|
||||||
|
def postParams = [
|
||||||
|
uri: 'https://smartthingsrec.api.earthnetworks.com/api/v1/receive/smartapp/update',
|
||||||
|
body: [
|
||||||
|
"Devices": devices,
|
||||||
|
"Location":[
|
||||||
|
"Id": location.id,
|
||||||
|
"Latitude":location.latitude,
|
||||||
|
"Longitude":location.longitude,
|
||||||
|
"ZipCode":location.zipCode,
|
||||||
|
"Name":location.name
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
sendToWeatherBug(postParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Subscribe to changes on the thermostat attributes
|
||||||
|
*/
|
||||||
|
def initialize() {
|
||||||
|
log.trace "initialize enter"
|
||||||
|
subscribe(thermostatDevice, "heatingSetpoint", pushLatest)
|
||||||
|
subscribe(thermostatDevice, "coolingSetpoint", pushLatest)
|
||||||
|
subscribe(thermostatDevice, "thermostatSetpoint", pushLatest)
|
||||||
|
subscribe(thermostatDevice, "thermostatMode", pushLatest)
|
||||||
|
subscribe(thermostatDevice, "thermostatFanMode", pushLatest)
|
||||||
|
subscribe(thermostatDevice, "thermostatOperatingState", pushLatest)
|
||||||
|
subscribe(thermostatDevice, "temperature", pushLatest)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The uninstall event will be pushed to a WeatherBug Home Service to notify the system to take appropriate action.
|
||||||
|
* Data that will be sent includes the list of devices, and location data
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
*/
|
||||||
|
def uninstalled() {
|
||||||
|
log.trace "uninstall entered"
|
||||||
|
def postParams = [
|
||||||
|
uri: 'https://smartthingsrec.api.earthnetworks.com/api/v1/receive/smartapp/delete',
|
||||||
|
body: [
|
||||||
|
"Devices": devices,
|
||||||
|
"Location":[
|
||||||
|
"Id": location.id,
|
||||||
|
"Latitude":location.latitude,
|
||||||
|
"Longitude":location.longitude,
|
||||||
|
"ZipCode":location.zipCode,
|
||||||
|
"Name":location.name
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
sendToWeatherBug(postParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method will push the latest thermostat data to the WeatherBug Home Service so it can store
|
||||||
|
* and display the data to the WeatherBug user. Data pushed includes the thermostat data as well
|
||||||
|
* as location id.
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
*/
|
||||||
|
def pushLatest(evt) {
|
||||||
|
def unixTime = (int)((new Date().getTime() / 1000))
|
||||||
|
def device = thermostatDevice.find{ it.id == evt.deviceId}
|
||||||
|
def postParams = [
|
||||||
|
uri: 'https://smartthingsrec.api.earthnetworks.com/api/v1/receive',
|
||||||
|
body: [
|
||||||
|
DeviceId: evt.deviceId,
|
||||||
|
LocationId: location.id,
|
||||||
|
ReportType: 2,
|
||||||
|
ReportList: [
|
||||||
|
[Key: "Temperature", Value: GetOrDefault(device, "temperature")],
|
||||||
|
[Key: "ThermostatSetpoint", Value: GetOrDefault(device, "thermostatSetpoint")],
|
||||||
|
[Key: "CoolingSetpoint", Value: GetOrDefault(device, "coolingSetpoint")],
|
||||||
|
[Key: "HeatingSetpoint", Value: GetOrDefault(device, "heatingSetpoint")],
|
||||||
|
[Key: "ThermostatMode", Value: GetOrDefault(device, "thermostatMode")],
|
||||||
|
[Key: "ThermostatFanMode", Value: GetOrDefault(device, "thermostatFanMode")],
|
||||||
|
[Key: "ThermostatOperatingState", Value: GetOrDefault(device, "thermostatOperatingState")]
|
||||||
|
],
|
||||||
|
UnixTime: unixTime
|
||||||
|
]
|
||||||
|
]
|
||||||
|
log.debug postParams
|
||||||
|
sendToWeatherBug(postParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This method attempts to get the value of a device attribute, but if an error occurs null is returned
|
||||||
|
* @return The device attribute value, or null
|
||||||
|
*/
|
||||||
|
def GetOrDefault(device, attrib)
|
||||||
|
{
|
||||||
|
def val
|
||||||
|
try{
|
||||||
|
val = device.latestValue(attrib)
|
||||||
|
|
||||||
|
}catch(ex)
|
||||||
|
{
|
||||||
|
log.debug "Failed to get attribute " + attrib + " from device " + device
|
||||||
|
val = null
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Convenience method that sends data to WeatherBug, logging any exceptions that may occur
|
||||||
|
* Privacy Policy: http://weatherbughome.com/privacy/
|
||||||
|
*/
|
||||||
|
def sendToWeatherBug(postParams)
|
||||||
|
{
|
||||||
|
try{
|
||||||
|
log.debug postParams
|
||||||
|
httpPostJson(postParams) { resp ->
|
||||||
|
resp.headers.each {
|
||||||
|
log.debug "${it.name} : ${it.value}"
|
||||||
|
}
|
||||||
|
log.debug "response contentType: ${resp.contentType}"
|
||||||
|
log.debug "response data: ${resp.data}"
|
||||||
|
}
|
||||||
|
log.debug "Communication with WeatherBug succeeded";
|
||||||
|
|
||||||
|
}catch(ex)
|
||||||
|
{
|
||||||
|
log.debug "Communication with WeatherBug failed.\n${ex}";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user