mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-09 05:11:52 +00:00
Compare commits
11 Commits
PROD_2017.
...
MSA-1933-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13b3e8b4a8 | ||
|
|
7e8baeeb0b | ||
|
|
ad824a9dd8 | ||
|
|
980bef6879 | ||
|
|
120935f14e | ||
|
|
032f4a92d4 | ||
|
|
6d528683e6 | ||
|
|
8bcbe7b924 | ||
|
|
69dd13f333 | ||
|
|
29c7049d60 | ||
|
|
03a79b8bb5 |
2
devicetypes/osotech/plantlink.src/.st-ignore
Normal file
2
devicetypes/osotech/plantlink.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
||||
.st-ignore
|
||||
README.md
|
||||
33
devicetypes/osotech/plantlink.src/README.md
Normal file
33
devicetypes/osotech/plantlink.src/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Osotech Plant Link
|
||||
|
||||
Cloud Execution
|
||||
|
||||
Works with:
|
||||
|
||||
* [OSO Technologies PlantLink Soil Moisture Sensor](https://www.smartthings.com/works-with-smartthings/oso-technologies/oso-technologies-plantlink-soil-moisture-sensor)
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Capabilities](#capabilities)
|
||||
* [Health](#device-health)
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
|
||||
## Capabilities
|
||||
|
||||
* **Sensor** - detects sensor events
|
||||
* **Health Check** - indicates ability to get device health notifications
|
||||
|
||||
## Device Health
|
||||
|
||||
Plant Link sensor is a ZigBee sleepy device and checks in every 15 minutes.
|
||||
Device-Watch allows 2 check-in misses from device plus some lag time. So Check-in interval = (2*15 + 2)mins = 32 mins.
|
||||
|
||||
* __32min__ checkInterval
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the sensor is out of range.
|
||||
Pairing needs to be tried again by placing the sensor closer to the hub.
|
||||
Instructions related to pairing, resetting and removing the different motion sensors from SmartThings can be found in the following links
|
||||
for the different models:
|
||||
* [OSO Technologies PlantLink Soil Moisture Sensor Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/206868986-PlantLink-Soil-Moisture-Sensor)
|
||||
@@ -24,6 +24,7 @@ import groovy.json.JsonBuilder
|
||||
metadata {
|
||||
definition (name: "PlantLink", namespace: "OsoTech", author: "Oso Technologies") {
|
||||
capability "Sensor"
|
||||
capability "Health Check"
|
||||
|
||||
command "setStatusIcon"
|
||||
command "setPlantFuelLevel"
|
||||
@@ -70,6 +71,16 @@ metadata {
|
||||
}
|
||||
}
|
||||
|
||||
def updated() {
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
|
||||
def installed() {
|
||||
// Device-Watch allows 2 check-in misses from device
|
||||
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
|
||||
def setStatusIcon(value){
|
||||
def status = ''
|
||||
switch (value) {
|
||||
@@ -161,4 +172,4 @@ def parseDescriptionAsMap(description) {
|
||||
map += []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* Aeon HEM - Xively
|
||||
*
|
||||
* Copyright 2014 Dan Anghelescu
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Genesys: Based off of Aeon Smart Meter Code sample provided by SmartThings (2013-05-30), Aeon Home Energy Meter v2 by Barry A. Burke, and Xively Logger by Patrick Stuart Built on US model
|
||||
* may also work on international versions (currently reports total values only)
|
||||
*/
|
||||
|
||||
|
||||
// Automatically generated. Make future change here.
|
||||
definition (
|
||||
name: "Aeon HEM - Xively",
|
||||
namespace: "smartthings",
|
||||
author: "Dan Anghelescu",
|
||||
description: "Aeon HEM - Xively Logger",
|
||||
category: "My Apps",
|
||||
iconUrl: "https://graph.api.smartthings.com/api/devices/icons/st.Electronics.electronics13-icn?displaySize",
|
||||
iconX2Url: "https://graph.api.smartthings.com/api/devices/icons/st.Electronics.electronics13-icn?displaySize=2x")
|
||||
|
||||
preferences {
|
||||
section("Log devices...") {
|
||||
input "energymeters", "capability.EnergyMeter", title: "Energy Meter", required: false, multiple: true
|
||||
input "thermostats", "capability.thermostat", title: "Thermostat", required: false, multiple: true
|
||||
input "weatherstations", "capability.temperatureMeasurement", title: "Outside Temperature", required: false, multiple: true
|
||||
|
||||
}
|
||||
|
||||
section ("Xively Info") {
|
||||
input "xi_apikey", "text", title: "Xively API Key"
|
||||
input "xi_feed", "number", title: "Xively Feed ID"
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
unsubscribe()
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
state.clear()
|
||||
unschedule(checkSensors)
|
||||
schedule("0 */5 * * * ?", "checkSensors")
|
||||
subscribe(app, appTouch)
|
||||
}
|
||||
|
||||
def appTouch(evt) {
|
||||
log.debug "appTouch: $evt"
|
||||
checkSensors()
|
||||
}
|
||||
|
||||
|
||||
|
||||
def checkSensors() {
|
||||
|
||||
def logitems = []
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.energy", t.latestValue("energy"), "KilowattHours", "kWh"] )
|
||||
state[t.displayName + ".energy"] = t.latestValue("energy")
|
||||
}
|
||||
for (t in settings.thermostats) {
|
||||
logitems.add([t.displayName, "inside.temperature", t.latestValue("temperature"), "Farenheight", "°F"] )
|
||||
state[t.displayName + ".temperature"] = t.latestValue("temperature")
|
||||
|
||||
/*
|
||||
if ( t.currentValue("thermostatOperatingState") == "cooling") {
|
||||
logitems.add([t.displayName, "thermostatState", 1 ])
|
||||
state[t.displayName + ".thermostatOperatingState"] = 1
|
||||
}
|
||||
if ( t.currentValue("thermostatOperatingState") == "heating") {
|
||||
logitems.add([t.displayName, "thermostatState", 2 ])
|
||||
state[t.displayName + ".thermostatOperatingState"] = 2
|
||||
}
|
||||
if ( t.currentValue("thermostatOperatingState") == "idle") {
|
||||
logitems.add([t.displayName, "thermostatState", 0 ])
|
||||
state[t.displayName + ".thermostatOperatingState"] = 0
|
||||
}
|
||||
*/
|
||||
}
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.power", t.latestValue("power"), "Watts", "W"] )
|
||||
state[t.displayName + ".power"] = t.latestValue("power")
|
||||
}
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.volts", t.latestValue("volts"), "Volts", "V"] )
|
||||
state[t.displayName + ".volts"] = t.latestValue("volts")
|
||||
}
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.amps", t.latestValue("amps"), "Amps", "A"] )
|
||||
state[t.displayName + ".amps"] = t.latestValue("amps")
|
||||
}
|
||||
for (t in settings.weatherstations) {
|
||||
logitems.add([t.displayName, "outside.temperature", t.latestValue("temperature"), "Farenheight", "°F"] )
|
||||
state[t.displayName + ".temperature"] = t.latestValue("temperature")
|
||||
}
|
||||
logField2(logitems)
|
||||
|
||||
}
|
||||
|
||||
private getFieldMap(channelInfo) {
|
||||
def fieldMap = [:]
|
||||
channelInfo?.findAll { it.key?.startsWith("field") }.each { fieldMap[it.value?.trim()] = it.key }
|
||||
return fieldMap
|
||||
}
|
||||
|
||||
|
||||
private logField2(logItems) {
|
||||
def fieldvalues = ""
|
||||
log.debug logItems
|
||||
|
||||
|
||||
def xivelyinfo = ""
|
||||
logItems.eachWithIndex() { item, i ->
|
||||
def channelname = item[0].replace(" ","_") + "_" + item[1]
|
||||
xivelyinfo += "{\"id\":\"${channelname}\",\"current_value\":\"${item[2]}\",\"unit\":{\"label\":\"${item[3]}\",\"symbol\":\"${item[4]}\"}}"
|
||||
if (i.toInteger() + 1 < logItems.size())
|
||||
{
|
||||
xivelyinfo += ","
|
||||
}
|
||||
|
||||
}
|
||||
log.debug xivelyinfo
|
||||
def uri = "https://api.xively.com/v2/feeds/${xi_feed}.json"
|
||||
def json = "{\"version\":\"1.0.0\",\"datastreams\":[${xivelyinfo} ]}"
|
||||
|
||||
def headers = [
|
||||
"X-ApiKey" : "${xi_apikey}"
|
||||
]
|
||||
|
||||
def params = [
|
||||
uri: uri,
|
||||
headers: headers,
|
||||
body: json
|
||||
]
|
||||
log.debug params.body
|
||||
httpPutJson(params) {response -> parseHttpResponse(response)}
|
||||
}
|
||||
|
||||
def parseHttpResponse(response) {
|
||||
log.debug "HTTP Response: ${response}"
|
||||
}
|
||||
|
||||
def captureState(theDevice) {
|
||||
def deviceAttrValue = [:]
|
||||
for ( attr in theDevice.supportedAttributes ) {
|
||||
def attrName = "${attr}"
|
||||
def attrValue = theDevice.currentValue(attrName)
|
||||
deviceAttrValue[attrName] = attrValue
|
||||
}
|
||||
return deviceAttrValue
|
||||
}
|
||||
@@ -21,7 +21,7 @@ Works with:
|
||||
|
||||
## Device Health
|
||||
|
||||
Plant Link sensor is a Z-wave sleepy device and checks in every 15 minutes.
|
||||
Plant Link sensor is a ZigBee sleepy device and checks in every 15 minutes.
|
||||
Device-Watch allows 2 check-in misses from device plus some lag time. So Check-in interval = (2*15 + 2)mins = 32 mins.
|
||||
|
||||
* __32min__ checkInterval
|
||||
|
||||
2
devicetypes/smartthings/smartalert-siren.src/.st-ignore
Normal file
2
devicetypes/smartthings/smartalert-siren.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
||||
.st-ignore
|
||||
README.md
|
||||
39
devicetypes/smartthings/smartalert-siren.src/README.md
Normal file
39
devicetypes/smartthings/smartalert-siren.src/README.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Smartalert Siren
|
||||
|
||||
Cloud Execution
|
||||
|
||||
Works with:
|
||||
|
||||
* [FortrezZ Siren Strobe Alarm](https://www.smartthings.com/works-with-smartthings/other/fortrezz-water-valve)
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Capabilities](#capabilities)
|
||||
* [Health](#device-health)
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
|
||||
## Capabilities
|
||||
|
||||
* **Actuator** - represents that a Device has commands
|
||||
* **Switch** - can detect state (possible values: on/off)
|
||||
* **Sensor** - detects sensor events
|
||||
* **Alarm** - allows for interacting with devices that serve as alarms
|
||||
* **Health Check** - indicates ability to get device health notifications
|
||||
|
||||
## Device Health
|
||||
|
||||
FortrezZ Siren Strobe Alarm is polled by the hub.
|
||||
As of hubCore version 0.14.38 the hub sends up reports every 15 minutes regardless of whether the state changed.
|
||||
Device-Watch allows 2 check-in misses from device plus some lag time. So Check-in interval = (2*15 + 2)mins = 32 mins.
|
||||
Not to mention after going OFFLINE when the device is plugged back in, it might take a considerable amount of time for
|
||||
the device to appear as ONLINE again. This is because if this listening device does not respond to two poll requests in a row,
|
||||
it is not polled for 5 minutes by the hub. This can delay up the process of being marked ONLINE by quite some time.
|
||||
|
||||
* __32min__ checkInterval
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the device is out of range.
|
||||
Pairing needs to be tried again by placing the device closer to the hub.
|
||||
Instructions related to pairing, resetting and removing the device from SmartThings can be found in the following link:
|
||||
* [FortrezZ Siren Strobe Alarm Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/202294760-FortrezZ-Siren-Strobe-Alarm)
|
||||
@@ -21,10 +21,12 @@ metadata {
|
||||
capability "Switch"
|
||||
capability "Sensor"
|
||||
capability "Alarm"
|
||||
capability "Health Check"
|
||||
|
||||
command "test"
|
||||
|
||||
fingerprint deviceId: "0x1100", inClusters: "0x26,0x71"
|
||||
fingerprint mfr:"0084", prod:"0313", model:"010B", deviceJoinName: "FortrezZ Siren Strobe Alarm"
|
||||
}
|
||||
|
||||
simulator {
|
||||
@@ -68,6 +70,16 @@ metadata {
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
// Device-Watch simply pings if no device events received for 32min(checkInterval)
|
||||
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
|
||||
def updated() {
|
||||
// Device-Watch simply pings if no device events received for 32min(checkInterval)
|
||||
sendEvent(name: "checkInterval", value: 2 * 15 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
|
||||
def on() {
|
||||
[
|
||||
zwave.basicV1.basicSet(value: 0xFF).format(),
|
||||
@@ -149,3 +161,10 @@ def createEvents(physicalgraph.zwave.commands.basicv1.BasicReport cmd)
|
||||
def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
||||
log.warn "UNEXPECTED COMMAND: $cmd"
|
||||
}
|
||||
|
||||
/**
|
||||
* PING is used by Device-Watch in attempt to reach the Device
|
||||
* */
|
||||
def ping() {
|
||||
secure(zwave.basicV1.basicGet())
|
||||
}
|
||||
@@ -191,6 +191,10 @@ private List<Map> parseAxis(List<Map> attrData) {
|
||||
def y = hexToSignedInt(attrData.find { it.attrInt == 0x0013 }?.value)
|
||||
def z = hexToSignedInt(attrData.find { it.attrInt == 0x0014 }?.value)
|
||||
|
||||
if ([x, y ,z].any { it == null }) {
|
||||
return []
|
||||
}
|
||||
|
||||
def xyzResults = [:]
|
||||
if (device.getDataValue("manufacturer") == "SmartThings") {
|
||||
// This mapping matches the current behavior of the Device Handler for the Centralite sensors
|
||||
@@ -371,6 +375,10 @@ def updated() {
|
||||
}
|
||||
|
||||
private hexToSignedInt(hexVal) {
|
||||
if (!hexVal) {
|
||||
return null
|
||||
}
|
||||
|
||||
def unsignedVal = hexToInt(hexVal)
|
||||
unsignedVal > 32767 ? unsignedVal - 65536 : unsignedVal
|
||||
}
|
||||
|
||||
@@ -70,19 +70,27 @@ def parse(String description) {
|
||||
else {
|
||||
sendEvent(event)
|
||||
}
|
||||
}
|
||||
else {
|
||||
def cluster = zigbee.parse(description)
|
||||
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00){
|
||||
} else {
|
||||
def descMap = zigbee.parseDescriptionAsMap(description)
|
||||
if (descMap && descMap.clusterInt == 0x0006 && descMap.commandInt == 0x07) {
|
||||
if (descMap.data[0] == "00") {
|
||||
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else if (device.getDataValue("manufacturer") == "sengled" && descMap && descMap.clusterInt == 0x0008 && descMap.attrInt == 0x0000) {
|
||||
// This is being done because the sengled element touch incorrectly uses the value 0xFF for the max level.
|
||||
// Per the ZCL spec for the UINT8 data type 0xFF is an invalid value, and 0xFE should be the max. Here we
|
||||
// manually handle the invalid attribute value since it will be ignored by getEvent as an invalid value.
|
||||
// We also set the level of the bulb to 0xFE so future level reports will be 0xFE until it is changed by
|
||||
// something else.
|
||||
if (descMap.value.toUpperCase() == "FF") {
|
||||
descMap.value = "FE"
|
||||
}
|
||||
sendHubCommand(zigbee.command(zigbee.LEVEL_CONTROL_CLUSTER, 0x00, "FE0000").collect { new physicalgraph.device.HubAction(it) }, 0)
|
||||
sendEvent(zigbee.getEventFromAttrData(descMap.clusterInt, descMap.attrInt, descMap.encoding, descMap.value))
|
||||
} else {
|
||||
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
||||
log.debug zigbee.parseDescriptionAsMap(description)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Z-Wave Switch
|
||||
# Z-Wave Lock
|
||||
|
||||
Cloud Execution
|
||||
|
||||
@@ -6,7 +6,6 @@ Works with:
|
||||
|
||||
* [Yale Key Free Touchscreen Deadbolt (YRD240)](https://www.smartthings.com/works-with-smartthings/yale/yale-key-free-touchscreen-deadbolt-yrd240)
|
||||
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Capabilities](#capabilities)
|
||||
@@ -41,5 +40,3 @@ If the device doesn't pair when trying from the SmartThings mobile app, it is po
|
||||
Pairing needs to be tried again by placing the device closer to the hub.
|
||||
Instructions related to pairing, resetting and removing the device from SmartThings can be found in the following link:
|
||||
* [General Z-Wave/ZigBee Yale Lock Troubleshooting](https://support.smartthings.com/hc/en-us/articles/205138400-How-to-connect-Yale-locks)
|
||||
|
||||
|
||||
|
||||
166
smartapps/smartthings/aeon-hem-xively.src/aeon-hem-xively.groovy
Normal file
166
smartapps/smartthings/aeon-hem-xively.src/aeon-hem-xively.groovy
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* Aeon HEM - Xively
|
||||
*
|
||||
* Copyright 2014 Dan Anghelescu
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Genesys: Based off of Aeon Smart Meter Code sample provided by SmartThings (2013-05-30), Aeon Home Energy Meter v2 by Barry A. Burke, and Xively Logger by Patrick Stuart Built on US model
|
||||
* may also work on international versions (currently reports total values only)
|
||||
*/
|
||||
|
||||
|
||||
// Automatically generated. Make future change here.
|
||||
definition (
|
||||
name: "Aeon HEM - Xively",
|
||||
namespace: "smartthings",
|
||||
author: "Dan Anghelescu",
|
||||
description: "Aeon HEM - Xively Logger",
|
||||
category: "My Apps",
|
||||
iconUrl: "https://graph.api.smartthings.com/api/devices/icons/st.Electronics.electronics13-icn?displaySize",
|
||||
iconX2Url: "https://graph.api.smartthings.com/api/devices/icons/st.Electronics.electronics13-icn?displaySize=2x")
|
||||
|
||||
preferences {
|
||||
section("Log devices...") {
|
||||
input "energymeters", "capability.EnergyMeter", title: "Energy Meter", required: false, multiple: true
|
||||
input "thermostats", "capability.thermostat", title: "Thermostat", required: false, multiple: true
|
||||
input "weatherstations", "capability.temperatureMeasurement", title: "Outside Temperature", required: false, multiple: true
|
||||
|
||||
}
|
||||
|
||||
section ("Xively Info") {
|
||||
input "xi_apikey", "text", title: "Xively API Key"
|
||||
input "xi_feed", "number", title: "Xively Feed ID"
|
||||
}
|
||||
}
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
unsubscribe()
|
||||
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
state.clear()
|
||||
unschedule(checkSensors)
|
||||
schedule("0 */5 * * * ?", "checkSensors")
|
||||
subscribe(app, appTouch)
|
||||
}
|
||||
|
||||
def appTouch(evt) {
|
||||
log.debug "appTouch: $evt"
|
||||
checkSensors()
|
||||
}
|
||||
|
||||
|
||||
|
||||
def checkSensors() {
|
||||
|
||||
def logitems = []
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.energy", t.latestValue("energy"), "KilowattHours", "kWh"] )
|
||||
state[t.displayName + ".energy"] = t.latestValue("energy")
|
||||
}
|
||||
for (t in settings.thermostats) {
|
||||
logitems.add([t.displayName, "inside.temperature", t.latestValue("temperature"), "Farenheight", "°F"] )
|
||||
state[t.displayName + ".temperature"] = t.latestValue("temperature")
|
||||
|
||||
/*
|
||||
if ( t.currentValue("thermostatOperatingState") == "cooling") {
|
||||
logitems.add([t.displayName, "thermostatState", 1 ])
|
||||
state[t.displayName + ".thermostatOperatingState"] = 1
|
||||
}
|
||||
if ( t.currentValue("thermostatOperatingState") == "heating") {
|
||||
logitems.add([t.displayName, "thermostatState", 2 ])
|
||||
state[t.displayName + ".thermostatOperatingState"] = 2
|
||||
}
|
||||
if ( t.currentValue("thermostatOperatingState") == "idle") {
|
||||
logitems.add([t.displayName, "thermostatState", 0 ])
|
||||
state[t.displayName + ".thermostatOperatingState"] = 0
|
||||
}
|
||||
*/
|
||||
}
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.power", t.latestValue("power"), "Watts", "W"] )
|
||||
state[t.displayName + ".power"] = t.latestValue("power")
|
||||
}
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.volts", t.latestValue("volts"), "Volts", "V"] )
|
||||
state[t.displayName + ".volts"] = t.latestValue("volts")
|
||||
}
|
||||
for (t in settings.energymeters) {
|
||||
logitems.add([t.displayName, "energymeter.amps", t.latestValue("amps"), "Amps", "A"] )
|
||||
state[t.displayName + ".amps"] = t.latestValue("amps")
|
||||
}
|
||||
for (t in settings.weatherstations) {
|
||||
logitems.add([t.displayName, "outside.temperature", t.latestValue("temperature"), "Farenheight", "°F"] )
|
||||
state[t.displayName + ".temperature"] = t.latestValue("temperature")
|
||||
}
|
||||
logField2(logitems)
|
||||
|
||||
}
|
||||
|
||||
private getFieldMap(channelInfo) {
|
||||
def fieldMap = [:]
|
||||
channelInfo?.findAll { it.key?.startsWith("field") }.each { fieldMap[it.value?.trim()] = it.key }
|
||||
return fieldMap
|
||||
}
|
||||
|
||||
|
||||
private logField2(logItems) {
|
||||
def fieldvalues = ""
|
||||
log.debug logItems
|
||||
|
||||
|
||||
def xivelyinfo = ""
|
||||
logItems.eachWithIndex() { item, i ->
|
||||
def channelname = item[0].replace(" ","_") + "_" + item[1]
|
||||
xivelyinfo += "{\"id\":\"${channelname}\",\"current_value\":\"${item[2]}\",\"unit\":{\"label\":\"${item[3]}\",\"symbol\":\"${item[4]}\"}}"
|
||||
if (i.toInteger() + 1 < logItems.size())
|
||||
{
|
||||
xivelyinfo += ","
|
||||
}
|
||||
|
||||
}
|
||||
log.debug xivelyinfo
|
||||
def uri = "https://api.xively.com/v2/feeds/${xi_feed}.json"
|
||||
def json = "{\"version\":\"1.0.0\",\"datastreams\":[${xivelyinfo} ]}"
|
||||
|
||||
def headers = [
|
||||
"X-ApiKey" : "${xi_apikey}"
|
||||
]
|
||||
|
||||
def params = [
|
||||
uri: uri,
|
||||
headers: headers,
|
||||
body: json
|
||||
]
|
||||
log.debug params.body
|
||||
httpPutJson(params) {response -> parseHttpResponse(response)}
|
||||
}
|
||||
|
||||
def parseHttpResponse(response) {
|
||||
log.debug "HTTP Response: ${response}"
|
||||
}
|
||||
|
||||
def captureState(theDevice) {
|
||||
def deviceAttrValue = [:]
|
||||
for ( attr in theDevice.supportedAttributes ) {
|
||||
def attrName = "${attr}"
|
||||
def attrValue = theDevice.currentValue(attrName)
|
||||
deviceAttrValue[attrName] = attrValue
|
||||
}
|
||||
return deviceAttrValue
|
||||
}
|
||||
Reference in New Issue
Block a user