mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-19 05:10:51 +00:00
Compare commits
1 Commits
PROD_2017.
...
MSA-1933-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
13b3e8b4a8 |
@@ -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
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2016 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
@@ -64,7 +64,6 @@ private getATTRIBUTE_HUE() { 0x0000 }
|
|||||||
private getATTRIBUTE_SATURATION() { 0x0001 }
|
private getATTRIBUTE_SATURATION() { 0x0001 }
|
||||||
private getHUE_COMMAND() { 0x00 }
|
private getHUE_COMMAND() { 0x00 }
|
||||||
private getSATURATION_COMMAND() { 0x03 }
|
private getSATURATION_COMMAND() { 0x03 }
|
||||||
private getMOVE_TO_HUE_AND_SATURATION_COMMAND() { 0x06 }
|
|
||||||
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
||||||
|
|
||||||
// Parse incoming device messages to generate events
|
// Parse incoming device messages to generate events
|
||||||
@@ -85,11 +84,11 @@ def parse(String description) {
|
|||||||
|
|
||||||
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
||||||
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
||||||
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "hue", value: hueValue, descriptionText: "Color has changed")
|
sendEvent(name: "hue", value: hueValue, descriptionText: "Color has changed")
|
||||||
}
|
}
|
||||||
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
||||||
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,12 +123,7 @@ def ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
zigbee.onOffRefresh() +
|
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) + zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, DataType.UINT8, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, DataType.UINT8, 1, 3600, 0x01)
|
||||||
zigbee.levelRefresh() +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) +
|
|
||||||
zigbee.onOffConfig(0, 300) +
|
|
||||||
zigbee.levelConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
@@ -139,38 +133,26 @@ def configure() {
|
|||||||
sendEvent(name: "checkInterval", value: 3 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
sendEvent(name: "checkInterval", value: 3 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||||
|
|
||||||
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||||
refresh()
|
zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, DataType.UINT8, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, DataType.UINT8, 1, 3600, 0x01) + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(value) {
|
def setLevel(value) {
|
||||||
zigbee.setLevel(value)
|
zigbee.setLevel(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getScaledHue(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
private getScaledSaturation(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
def setColor(value){
|
def setColor(value){
|
||||||
log.trace "setColor($value)"
|
log.trace "setColor($value)"
|
||||||
zigbee.on() +
|
zigbee.on() + setHue(value.hue) + "delay 500" + setSaturation(value.saturation)
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_HUE_AND_SATURATION_COMMAND,
|
|
||||||
getScaledHue(value.hue), getScaledSaturation(value.saturation), "0000") +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setHue(value) {
|
def setHue(value) {
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, getScaledHue(value), "00", "0000") +
|
def scaledHueValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE)
|
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, scaledHueValue, "00", "0500") //payload-> hue value, direction (00-> shortest distance), transition time (1/10th second) (0500 in U16 reads 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setSaturation(value) {
|
def setSaturation(value) {
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, getScaledSaturation(value), "0000") +
|
def scaledSatValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, scaledSatValue, "0500") + "delay 1000" + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
def installed() {
|
def installed() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2016 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
@@ -78,7 +78,6 @@ private getATTRIBUTE_HUE() { 0x0000 }
|
|||||||
private getATTRIBUTE_SATURATION() { 0x0001 }
|
private getATTRIBUTE_SATURATION() { 0x0001 }
|
||||||
private getHUE_COMMAND() { 0x00 }
|
private getHUE_COMMAND() { 0x00 }
|
||||||
private getSATURATION_COMMAND() { 0x03 }
|
private getSATURATION_COMMAND() { 0x03 }
|
||||||
private getMOVE_TO_HUE_AND_SATURATION_COMMAND() { 0x06 }
|
|
||||||
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
||||||
private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 }
|
private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 }
|
||||||
|
|
||||||
@@ -103,11 +102,11 @@ def parse(String description) {
|
|||||||
|
|
||||||
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
||||||
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
||||||
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "hue", value: hueValue, descriptionText: "Color has changed")
|
sendEvent(name: "hue", value: hueValue, descriptionText: "Color has changed")
|
||||||
}
|
}
|
||||||
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
||||||
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,13 +141,7 @@ def ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
zigbee.onOffRefresh() +
|
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) + zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, DataType.UINT8, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, DataType.UINT8, 1, 3600, 0x01)
|
||||||
zigbee.levelRefresh() +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) +
|
|
||||||
zigbee.onOffConfig(0, 300) +
|
|
||||||
zigbee.levelConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
@@ -163,12 +156,7 @@ def configure() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
value = value as Integer
|
zigbee.setColorTemperature(value)
|
||||||
def tempInMired = (1000000 / value) as Integer
|
|
||||||
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
|
|
||||||
|
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, 0x0A, "$finalHex 0000") +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
||||||
@@ -192,31 +180,19 @@ def setLevel(value) {
|
|||||||
zigbee.setLevel(value)
|
zigbee.setLevel(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
private getScaledHue(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
private getScaledSaturation(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
def setColor(value){
|
def setColor(value){
|
||||||
log.trace "setColor($value)"
|
log.trace "setColor($value)"
|
||||||
zigbee.on() +
|
zigbee.on() + setHue(value.hue) + "delay 300" + setSaturation(value.saturation)
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_HUE_AND_SATURATION_COMMAND,
|
|
||||||
getScaledHue(value.hue), getScaledSaturation(value.saturation), "0000") +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setHue(value) {
|
def setHue(value) {
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, getScaledHue(value), "00", "0000") +
|
def scaledHueValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE)
|
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, scaledHueValue, "00", "0500") //payload-> hue value, direction (00-> shortest distance), transition time (1/10th second) (0500 in U16 reads 5)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setSaturation(value) {
|
def setSaturation(value) {
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, getScaledSaturation(value), "0000") +
|
def scaledSatValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, scaledSatValue, "0500") + "delay 1000" + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
def installed() {
|
def installed() {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
@@ -123,11 +123,7 @@ def ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
zigbee.onOffRefresh() +
|
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh() + zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.colorTemperatureConfig()
|
||||||
zigbee.levelRefresh() +
|
|
||||||
zigbee.colorTemperatureRefresh() +
|
|
||||||
zigbee.onOffConfig(0, 300) +
|
|
||||||
zigbee.levelConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
@@ -142,12 +138,7 @@ def configure() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
value = value as Integer
|
zigbee.setColorTemperature(value)
|
||||||
def tempInMired = (1000000 / value) as Integer
|
|
||||||
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
|
|
||||||
|
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, 0x0A, "$finalHex 0000") +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2016 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
@@ -55,7 +55,6 @@ private getATTRIBUTE_HUE() { 0x0000 }
|
|||||||
private getATTRIBUTE_SATURATION() { 0x0001 }
|
private getATTRIBUTE_SATURATION() { 0x0001 }
|
||||||
private getHUE_COMMAND() { 0x00 }
|
private getHUE_COMMAND() { 0x00 }
|
||||||
private getSATURATION_COMMAND() { 0x03 }
|
private getSATURATION_COMMAND() { 0x03 }
|
||||||
private getMOVE_TO_HUE_AND_SATURATION_COMMAND() { 0x06 }
|
|
||||||
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
||||||
|
|
||||||
// Parse incoming device messages to generate events
|
// Parse incoming device messages to generate events
|
||||||
@@ -73,11 +72,11 @@ def parse(String description) {
|
|||||||
|
|
||||||
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
||||||
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
||||||
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 360)
|
||||||
sendEvent(name: "hue", value: hueValue, displayed:false)
|
sendEvent(name: "hue", value: hueValue, displayed:false)
|
||||||
}
|
}
|
||||||
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
||||||
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,46 +108,28 @@ def configure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configureAttributes() {
|
def configureAttributes() {
|
||||||
zigbee.onOffConfig() +
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, DataType.UINT8, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, DataType.UINT8, 1, 3600, 0x01)
|
||||||
zigbee.levelConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refreshAttributes() {
|
def refreshAttributes() {
|
||||||
zigbee.onOffRefresh() +
|
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
zigbee.levelRefresh() +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setLevel(value) {
|
def setLevel(value) {
|
||||||
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
||||||
}
|
}
|
||||||
|
|
||||||
private getScaledHue(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
private getScaledSaturation(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
def setColor(value){
|
def setColor(value){
|
||||||
log.trace "setColor($value)"
|
log.trace "setColor($value)"
|
||||||
zigbee.on() +
|
zigbee.on() + setHue(value.hue) + ["delay 300"] + setSaturation(value.saturation) + ["delay 2000"] + refreshAttributes()
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_HUE_AND_SATURATION_COMMAND,
|
|
||||||
getScaledHue(value.hue), getScaledSaturation(value.saturation), "0000") +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setHue(value) {
|
def setHue(value) {
|
||||||
//payload-> hue value, direction (00-> shortest distance), transition time (1/10th second)
|
def scaledHueValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, getScaledHue(value), "00", "0000") +
|
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, scaledHueValue, "00", "0500") + ["delay 1500"] + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) //payload-> hue value, direction (00-> shortest distance), transition time (1/10th second) (0500 in U16 reads 5)
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setSaturation(value) {
|
def setSaturation(value) {
|
||||||
//payload-> sat value, transition time
|
def scaledSatValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, getScaledSaturation(value), "0000") +
|
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, scaledSatValue, "0500") + ["delay 1500"] + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) //payload-> sat value, transition time
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2016 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
@@ -70,7 +70,6 @@ private getATTRIBUTE_HUE() { 0x0000 }
|
|||||||
private getATTRIBUTE_SATURATION() { 0x0001 }
|
private getATTRIBUTE_SATURATION() { 0x0001 }
|
||||||
private getHUE_COMMAND() { 0x00 }
|
private getHUE_COMMAND() { 0x00 }
|
||||||
private getSATURATION_COMMAND() { 0x03 }
|
private getSATURATION_COMMAND() { 0x03 }
|
||||||
private getMOVE_TO_HUE_AND_SATURATION_COMMAND() { 0x06 }
|
|
||||||
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
||||||
private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 }
|
private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 }
|
||||||
|
|
||||||
@@ -89,11 +88,11 @@ def parse(String description) {
|
|||||||
|
|
||||||
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
if (zigbeeMap?.clusterInt == COLOR_CONTROL_CLUSTER) {
|
||||||
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
if(zigbeeMap.attrInt == ATTRIBUTE_HUE){ //Hue Attribute
|
||||||
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 360)
|
||||||
sendEvent(name: "hue", value: hueValue, displayed:false)
|
sendEvent(name: "hue", value: hueValue, displayed:false)
|
||||||
}
|
}
|
||||||
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
else if(zigbeeMap.attrInt == ATTRIBUTE_SATURATION){ //Saturation Attribute
|
||||||
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 255 * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,16 +124,11 @@ def configure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configureAttributes() {
|
def configureAttributes() {
|
||||||
zigbee.onOffConfig() +
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE, DataType.UINT8, 1, 3600, 0x01) + zigbee.configureReporting(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION, DataType.UINT8, 1, 3600, 0x01)
|
||||||
zigbee.levelConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def refreshAttributes() {
|
def refreshAttributes() {
|
||||||
zigbee.onOffRefresh() +
|
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh() + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
zigbee.levelRefresh() +
|
|
||||||
zigbee.colorTemperatureRefresh() +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
@@ -145,32 +139,17 @@ def setLevel(value) {
|
|||||||
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
zigbee.setLevel(value) + zigbee.onOffRefresh() + zigbee.levelRefresh() //adding refresh because of ZLL bulb not conforming to send-me-a-report
|
||||||
}
|
}
|
||||||
|
|
||||||
private getScaledHue(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
private getScaledSaturation(value) {
|
|
||||||
zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
|
||||||
}
|
|
||||||
|
|
||||||
def setColor(value){
|
def setColor(value){
|
||||||
log.trace "setColor($value)"
|
log.trace "setColor($value)"
|
||||||
zigbee.on() +
|
zigbee.on() + setHue(value.hue) + ["delay 300"] + setSaturation(value.saturation) + ["delay 2000"] + refreshAttributes()
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_HUE_AND_SATURATION_COMMAND,
|
|
||||||
getScaledHue(value.hue), getScaledSaturation(value.saturation), "0000") +
|
|
||||||
zigbee.onOffRefresh() +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setHue(value) {
|
def setHue(value) {
|
||||||
//payload-> hue value, direction (00-> shortest distance), transition time (1/10th second)
|
def scaledHueValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, getScaledHue(value), "00", "0000") +
|
zigbee.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, scaledHueValue, "00", "0500") + ["delay 1500"] + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) //payload-> hue value, direction (00-> shortest distance), transition time (1/10th second) (0500 in U16 reads 5)
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def setSaturation(value) {
|
def setSaturation(value) {
|
||||||
//payload-> sat value, transition time
|
def scaledSatValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, getScaledSaturation(value), "0000") +
|
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, scaledSatValue, "0500") + ["delay 1500"] + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) //payload-> sat value, transition time
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2016 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
@@ -95,14 +95,14 @@ def setLevel(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
def cmds = zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
def cmds = zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||||
|
|
||||||
// Do NOT config if the device is the Eaton Halo_LT01, it responds with "switch:off" to onOffConfig, and maybe other weird things with the others
|
// Do NOT config if the device is the Eaton Halo_LT01, it responds with "switch:off" to onOffConfig, and maybe other weird things with the others
|
||||||
if (!((device.getDataValue("manufacturer") == "Eaton") && (device.getDataValue("model") == "Halo_LT01"))) {
|
if (!((device.getDataValue("manufacturer") == "Eaton") && (device.getDataValue("model") == "Halo_LT01"))) {
|
||||||
cmds += zigbee.onOffConfig() + zigbee.levelConfig()
|
cmds = cmds + zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds
|
cmds
|
||||||
}
|
}
|
||||||
|
|
||||||
def poll() {
|
def poll() {
|
||||||
@@ -138,7 +138,7 @@ def configure() {
|
|||||||
log.debug "configure()"
|
log.debug "configure()"
|
||||||
configureHealthCheck()
|
configureHealthCheck()
|
||||||
// Implementation note: for the Eaton Halo_LT01, it responds with "switch:off" to onOffConfig, so be sure this is before the call to onOffRefresh
|
// Implementation note: for the Eaton Halo_LT01, it responds with "switch:off" to onOffConfig, so be sure this is before the call to onOffRefresh
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
@@ -148,12 +148,7 @@ def updated() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
value = value as Integer
|
zigbee.setColorTemperature(value) + ["delay 1500"] + zigbee.colorTemperatureRefresh()
|
||||||
def tempInMired = (1000000 / value) as Integer
|
|
||||||
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
|
|
||||||
|
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, 0x0A, "$finalHex 0000") +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2016 SmartThings
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
* 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:
|
* in compliance with the License. You may obtain a copy of the License at:
|
||||||
@@ -94,11 +94,7 @@ def setLevel(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
zigbee.onOffRefresh() +
|
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh() + zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig()
|
||||||
zigbee.levelRefresh() +
|
|
||||||
zigbee.colorTemperatureRefresh() +
|
|
||||||
zigbee.onOffConfig() +
|
|
||||||
zigbee.levelConfig()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def poll() {
|
def poll() {
|
||||||
@@ -133,7 +129,8 @@ def configureHealthCheck() {
|
|||||||
def configure() {
|
def configure() {
|
||||||
log.debug "configure()"
|
log.debug "configure()"
|
||||||
configureHealthCheck()
|
configureHealthCheck()
|
||||||
refresh()
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
@@ -143,12 +140,7 @@ def updated() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
value = value as Integer
|
zigbee.setColorTemperature(value) + ["delay 1500"] + zigbee.colorTemperatureRefresh()
|
||||||
def tempInMired = (1000000 / value) as Integer
|
|
||||||
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
|
|
||||||
|
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, 0x0A, "$finalHex 0000") +
|
|
||||||
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_COLOR_TEMPERATURE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
//Naming based on the wiki article here: http://en.wikipedia.org/wiki/Color_temperature
|
||||||
|
|||||||
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