mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-17 21:03:30 +00:00
Compare commits
26 Commits
MSA-1918-2
...
PROD_2017.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abc5683ed3 | ||
|
|
a3e9f1d2c1 | ||
|
|
8bfc3f0c1c | ||
|
|
93544c4f60 | ||
|
|
7527fdd1bb | ||
|
|
b552bcc6f0 | ||
|
|
10f51945f5 | ||
|
|
5816fe8a1e | ||
|
|
e763dde6aa | ||
|
|
ff8fd3d1a9 | ||
|
|
7e8baeeb0b | ||
|
|
8ab71f72b0 | ||
|
|
62991f8d23 | ||
|
|
11f2775568 | ||
|
|
83b65c0d87 | ||
|
|
e641759a47 | ||
|
|
7820b39b2b | ||
|
|
6a76a8ee39 | ||
|
|
c864fc521e | ||
|
|
016425b7c8 | ||
|
|
c164b201ca | ||
|
|
030dd47b69 | ||
|
|
cc68534b47 | ||
|
|
5e07494dff | ||
|
|
573630232f | ||
|
|
fc32031555 |
2
devicetypes/drzwave/ezmultipli.src/.st-ignore
Normal file
2
devicetypes/drzwave/ezmultipli.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
44
devicetypes/drzwave/ezmultipli.src/README.md
Normal file
44
devicetypes/drzwave/ezmultipli.src/README.md
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
# Express Controls EZMultiPli
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Express Controls EZMultiPli](https://www.smartthings.com/works-with-smartthings/)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Release Notes](#release-notes)
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Troubleshooting](#troubleshooting)
|
||||||
|
|
||||||
|
## Release Notes
|
||||||
|
|
||||||
|
* **2017-04-19** - _dkirker_ - Update default config values in config value range check functions, use lux if lum option is null, fix NullPointerException on initial pairing when color data has not been set (and set the default color data!)
|
||||||
|
* **2017-04-10** - _DrZwave_ (with help from Donald Kirker) - changed fingerprint to the new format, lowered the OnTime and other parameters to be "more in line with ST user expectations", get the luminance in LUX so it reports in lux all the time.
|
||||||
|
* **2016-10-06** - _erocm1231_ - Added "updated" method to run when configuration options are changed. Depending on model of unit, luminance is being reported as a relative percentace or as a lux value. Added the option to configure this in the handler.
|
||||||
|
* **2016-01-28** - _erocm1231_ - Changed the configuration method to use scaledConfiguration so that it properly formatted negative numbers. Also, added configurationGet and a configurationReport method so that config values can be verified.
|
||||||
|
* **2015-12-04** - _erocm1231_ - added range value to preferences as suggested by @Dela-Rick.
|
||||||
|
* **2015-11-26** - _erocm1231_ - Fixed null condition error when adding as a new device.
|
||||||
|
* **2015-11-24** - _erocm1231_ - Added refresh command. Made a few changes to how the handler maps colors to the LEDs. Fixed the device not having its on/off status updated when colors are changed.
|
||||||
|
* **2015-11-23** - _erocm1231_ - Changed the look to match SmartThings v2 devices.
|
||||||
|
* **2015-11-21** - _erocm1231_ - Made code much more efficient. Also made it compatible when setColor is passed a hex value. Mapping of special colors: Soft White - Default - Yellow, White - Concentrate - White, Daylight - Energize - Teal, Warm White - Relax - Yellow
|
||||||
|
* **2015-11-19** - _erocm1231_ - Fixed a couple incorrect colors, changed setColor to be more compatible with other apps
|
||||||
|
* **2015-11-18** - _erocm1231_ - Added to setColor for compatibility with Smart Lighting
|
||||||
|
* **v0.1.0** - _DrZWave_ - chose better icons, Got color LED to work - first fully functional version
|
||||||
|
* **v0.0.9** - _jrs_ - got the temp and luminance to work. Motion works. Debugging the color wheel.
|
||||||
|
* **v0.0.8** - _DrZWave_ 2/25/2015 - change the color control to be tiles since there are only 8 colors.
|
||||||
|
* **v0.0.7** - _jrs_ - 02/23/2015 - Jim Sulin
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Actuator** - represents that a Device has commands
|
||||||
|
* **Sensor** - detects sensor events
|
||||||
|
* **Motion Sensor** - can detect motion
|
||||||
|
* **Temperature Measurement** - defines device measures current temperature
|
||||||
|
* **Illuminance Measurement** - gives the illuminance reading from devices that support it
|
||||||
|
* **Switch** - can detect state (possible values: on/off)
|
||||||
|
* **Color Control** - represents that the color attributes of a device can be controlled (hue, saturation, color value
|
||||||
|
* **Configuration** - configure() command called when device is installed or device preferences updated
|
||||||
|
* **Refresh** - refresh() command for status updates
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
@@ -2,27 +2,6 @@
|
|||||||
// Motion Sensor - Temperature - Light level - 8 Color Indicator LED - Z-Wave Range Extender - Wall Powered
|
// Motion Sensor - Temperature - Light level - 8 Color Indicator LED - Z-Wave Range Extender - Wall Powered
|
||||||
// driver for SmartThings
|
// driver for SmartThings
|
||||||
// The EZMultiPli is also known as the HSM200 from HomeSeer.com
|
// The EZMultiPli is also known as the HSM200 from HomeSeer.com
|
||||||
//
|
|
||||||
// 2017-04-10 - DrZwave (with help from Don Kirker) - changed fingerprint to the new format, lowered the OnTime
|
|
||||||
// and other parameters to be "more in line with ST user expectations", get the luminance in LUX so it reports in lux all the time.
|
|
||||||
// 2016-10-06 - erocm1231 - Added "updated" method to run when configuration options are changed. Depending on model of unit, luminance is being
|
|
||||||
// reported as a relative percentace or as a lux value. Added the option to configure this in the handler.
|
|
||||||
// 2016-01-28 - erocm1231 - Changed the configuration method to use scaledConfiguration so that it properly formatted negative numbers.
|
|
||||||
// Also, added configurationGet and a configurationReport method so that config values can be verified.
|
|
||||||
// 2015-12-04 - erocm1231 - added range value to preferences as suggested by @Dela-Rick.
|
|
||||||
// 2015-11-26 - erocm1231 - Fixed null condition error when adding as a new device.
|
|
||||||
// 2015-11-24 - erocm1231 - Added refresh command. Made a few changes to how the handler maps colors to the LEDs. Fixed
|
|
||||||
// the device not having its on/off status updated when colors are changed.
|
|
||||||
// 2015-11-23 - erocm1231 - Changed the look to match SmartThings v2 devices.
|
|
||||||
// 2015-11-21 - erocm1231 - Made code much more efficient. Also made it compatible when setColor is passed a hex value.
|
|
||||||
// Mapping of special colors: Soft White - Default - Yellow, White - Concentrate - White,
|
|
||||||
// Daylight - Energize - Teal, Warm White - Relax - Yellow
|
|
||||||
// 2015-11-19 - erocm1231 - Fixed a couple incorrect colors, changed setColor to be more compatible with other apps
|
|
||||||
// 2015-11-18 - erocm1231 - Added to setColor for compatibility with Smart Lighting
|
|
||||||
// v0.1.0 - DrZWave - chose better icons, Got color LED to work - first fully functional version
|
|
||||||
// v0.0.9 - jrs - got the temp and luminance to work. Motion works. Debugging the color wheel.
|
|
||||||
// v0.0.8 - DrZWave 2/25/2015 - change the color control to be tiles since there are only 8 colors.
|
|
||||||
// v0.0.7 - jrs - 02/23/2015 - Jim Sulin
|
|
||||||
|
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "EZmultiPli", namespace: "DrZWave", author: "Eric Ryherd", oauth: true) {
|
definition (name: "EZmultiPli", namespace: "DrZWave", author: "Eric Ryherd", oauth: true) {
|
||||||
@@ -131,7 +110,6 @@ metadata {
|
|||||||
|
|
||||||
} // end metadata
|
} // end metadata
|
||||||
|
|
||||||
|
|
||||||
// Parse incoming device messages from device to generate events
|
// Parse incoming device messages from device to generate events
|
||||||
def parse(String description){
|
def parse(String description){
|
||||||
//log.debug "==> New Zwave Event: ${description}"
|
//log.debug "==> New Zwave Event: ${description}"
|
||||||
@@ -145,7 +123,7 @@ def parse(String description){
|
|||||||
|
|
||||||
def statusTextmsg = ""
|
def statusTextmsg = ""
|
||||||
if (device.currentState('temperature') != null && device.currentState('illuminance') != null) {
|
if (device.currentState('temperature') != null && device.currentState('illuminance') != null) {
|
||||||
statusTextmsg = "${device.currentState('temperature').value} ° - ${device.currentState('illuminance').value} ${(lum == "" || lum == null || lum == 1) ? "%" : "LUX"}"
|
statusTextmsg = "${device.currentState('temperature').value} ° - ${device.currentState('illuminance').value} ${(lum == 1) ? "%" : "LUX"}"
|
||||||
sendEvent("name":"statusText", "value":statusTextmsg, displayed:false)
|
sendEvent("name":"statusText", "value":statusTextmsg, displayed:false)
|
||||||
}
|
}
|
||||||
if (result != [null] && result != []) log.debug "Parse returned ${result}"
|
if (result != [null] && result != []) log.debug "Parse returned ${result}"
|
||||||
@@ -168,7 +146,7 @@ def zwaveEvent(physicalgraph.zwave.commands.sensormultilevelv5.SensorMultilevelR
|
|||||||
break;
|
break;
|
||||||
case 0x03 : // SENSOR_TYPE_LUMINANCE_VERSION_1
|
case 0x03 : // SENSOR_TYPE_LUMINANCE_VERSION_1
|
||||||
map.value = cmd.scaledSensorValue.toInteger().toString()
|
map.value = cmd.scaledSensorValue.toInteger().toString()
|
||||||
if(lum == "" || lum == null || lum == 1) map.unit = "%"
|
if(lum == 1) map.unit = "%"
|
||||||
else map.unit = "lux"
|
else map.unit = "lux"
|
||||||
map.name = "illuminance"
|
map.name = "illuminance"
|
||||||
log.debug "Luminance report"
|
log.debug "Luminance report"
|
||||||
@@ -203,7 +181,8 @@ def zwaveEvent(physicalgraph.zwave.commands.notificationv3.NotificationReport cm
|
|||||||
}
|
}
|
||||||
|
|
||||||
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
|
def zwaveEvent(physicalgraph.zwave.commands.basicv1.BasicReport cmd) {
|
||||||
if (cmd.value == 0 && device.latestState("color").value != "#ffffff") {
|
// The EZMultiPli sets the color back to #ffffff on "off" or at init, so update the ST device to reflect this.
|
||||||
|
if (device.latestState("color") == null || (cmd.value == 0 && device.latestState("color").value != "#ffffff")) {
|
||||||
sendEvent(name: "color", value: "#ffffff", displayed: true)
|
sendEvent(name: "color", value: "#ffffff", displayed: true)
|
||||||
}
|
}
|
||||||
[name: "switch", value: cmd.value ? "on" : "off", type: "digital"]
|
[name: "switch", value: cmd.value ? "on" : "off", type: "digital"]
|
||||||
@@ -296,12 +275,12 @@ def zwaveEvent(physicalgraph.zwave.Command cmd) {
|
|||||||
// ensure we are passing acceptable param values for LiteMin & TempMin configs
|
// ensure we are passing acceptable param values for LiteMin & TempMin configs
|
||||||
def checkLiteTempInput(value) {
|
def checkLiteTempInput(value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
value=60
|
value=6
|
||||||
}
|
}
|
||||||
def liteTempVal = value.toInteger()
|
def liteTempVal = value.toInteger()
|
||||||
switch (liteTempVal) {
|
switch (liteTempVal) {
|
||||||
case { it < 0 }:
|
case { it < 0 }:
|
||||||
return 60 // bad value, set to default
|
return 6 // bad value, set to default
|
||||||
break
|
break
|
||||||
case { it > 127 }:
|
case { it > 127 }:
|
||||||
return 127 // bad value, greater then MAX, set to MAX
|
return 127 // bad value, greater then MAX, set to MAX
|
||||||
@@ -314,12 +293,12 @@ def checkLiteTempInput(value) {
|
|||||||
// ensure we are passing acceptable param value for OnTime config
|
// ensure we are passing acceptable param value for OnTime config
|
||||||
def checkOnTimeInput(value) {
|
def checkOnTimeInput(value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
value=10
|
value=2
|
||||||
}
|
}
|
||||||
def onTimeVal = value.toInteger()
|
def onTimeVal = value.toInteger()
|
||||||
switch (onTimeVal) {
|
switch (onTimeVal) {
|
||||||
case { it < 0 }:
|
case { it < 0 }:
|
||||||
return 10 // bad value set to default
|
return 2 // bad value set to default
|
||||||
break
|
break
|
||||||
case { it > 127 }:
|
case { it > 127 }:
|
||||||
return 127 // bad value, greater then MAX, set to MAX
|
return 127 // bad value, greater then MAX, set to MAX
|
||||||
|
|||||||
2
devicetypes/smartthings/arrival-sensor-ha.src/.st-ignore
Normal file
2
devicetypes/smartthings/arrival-sensor-ha.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
50
devicetypes/smartthings/arrival-sensor-ha.src/README.md
Normal file
50
devicetypes/smartthings/arrival-sensor-ha.src/README.md
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Arrival Sensor HA (2016+ Model)
|
||||||
|
|
||||||
|
Cloud Execution
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Samsung SmartThings Arrival Sensor](https://support.smartthings.com/hc/en-us/articles/212417083-Samsung-SmartThings-Arrival-Sensor)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
* [Battery](#battery)
|
||||||
|
* [Troubleshooting](#troubleshooting)
|
||||||
|
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Tone** - beep command to allow an audible tone
|
||||||
|
* **Actuator** - device has commands
|
||||||
|
* **Presence Sensor** - device tells presence with enum - {present, not present}
|
||||||
|
* **Sensor** - device has attributes
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Configuration** - _configure()_ command called when device is installed or device preferences updated
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
Arrival Sensor ZigBee is an untracked device. Sends broadcast of battery level every 20 seconds.
|
||||||
|
Disconnects when Hub goes OFFLINE.
|
||||||
|
|
||||||
|
|
||||||
|
## Battery
|
||||||
|
|
||||||
|
Uses 1 CR2032 Battery
|
||||||
|
|
||||||
|
* [Changing the Battery](https://support.smartthings.com/hc/en-us/articles/200907400-How-to-change-the-battery-in-the-SmartSense-Presence-Sensor-and-Samsung-SmartThings-Arrival-Sensor)
|
||||||
|
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the arrival sensor is out of range.
|
||||||
|
Pairing needs to be tried again by placing the sensor closer to the hub.
|
||||||
|
|
||||||
|
* [Samsung SmartThings Arrival Sensor Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/205382134-Samsung-SmartThings-Arrival-Sensor-2015-model-)
|
||||||
|
|
||||||
|
If the arrival sensor doesn't update its status, here are a few things you can try to debug.
|
||||||
|
|
||||||
|
* [Troubleshooting: Samsung SmartThings Arrival Sensor won't update its status](https://support.smartthings.com/hc/en-us/articles/200846514-Troubleshooting-Samsung-SmartThings-Arrival-Sensor-won-t-update-its-status)
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2017 SmartThings
|
* Copyright 2017 SmartThings
|
||||||
*
|
*
|
||||||
@@ -19,6 +21,7 @@ metadata {
|
|||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Battery"
|
capability "Battery"
|
||||||
capability "Configuration"
|
capability "Configuration"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
fingerprint inClusters: "0000,0001,0003,000F,0020", outClusters: "0003,0019",
|
fingerprint inClusters: "0000,0001,0003,000F,0020", outClusters: "0003,0019",
|
||||||
manufacturer: "SmartThings", model: "tagv4", deviceJoinName: "Arrival Sensor"
|
manufacturer: "SmartThings", model: "tagv4", deviceJoinName: "Arrival Sensor"
|
||||||
@@ -58,6 +61,11 @@ def updated() {
|
|||||||
startTimer()
|
startTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
// Arrival sensors only goes OFFLINE when Hub is off
|
||||||
|
sendEvent(name: "DeviceWatch-Enroll", value: JsonOutput.toJson([protocol: "zigbee", scheme:"untracked"]), displayed: false)
|
||||||
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
def cmds = zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) + zigbee.batteryConfig(20, 20, 0x01)
|
def cmds = zigbee.readAttribute(zigbee.POWER_CONFIGURATION_CLUSTER, 0x0020) + zigbee.batteryConfig(20, 20, 0x01)
|
||||||
log.debug "configure -- cmds: ${cmds}"
|
log.debug "configure -- cmds: ${cmds}"
|
||||||
|
|||||||
2
devicetypes/smartthings/arrival-sensor.src/.st-ignore
Normal file
2
devicetypes/smartthings/arrival-sensor.src/.st-ignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.st-ignore
|
||||||
|
README.md
|
||||||
49
devicetypes/smartthings/arrival-sensor.src/README.md
Normal file
49
devicetypes/smartthings/arrival-sensor.src/README.md
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
# Arrival Sensor (2015 Model)
|
||||||
|
|
||||||
|
Cloud Execution
|
||||||
|
|
||||||
|
Works with:
|
||||||
|
|
||||||
|
* [Arrival Sensor](https://www.smartthings.com/products/samsung-smartthings-arrival-sensor)
|
||||||
|
|
||||||
|
## Table of contents
|
||||||
|
|
||||||
|
* [Capabilities](#capabilities)
|
||||||
|
* [Health](#device-health)
|
||||||
|
* [Battery](#battery)
|
||||||
|
* [Troubleshooting](#troubleshooting)
|
||||||
|
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
* **Tone** - beep command to allow an audible tone
|
||||||
|
* **Actuator** - device has commands
|
||||||
|
* **Signal Strength** - device can read the strength of signal- lqi: Link Quality Indication, rssi: Received Signal Strength Indication
|
||||||
|
* **Presence Sensor** - device tells presence with enum - {present, not present}
|
||||||
|
* **Sensor** - device has attributes
|
||||||
|
* **Battery** - defines device uses a battery
|
||||||
|
* **Health Check** - indicates ability to get device health notifications
|
||||||
|
|
||||||
|
|
||||||
|
## Device Health
|
||||||
|
|
||||||
|
Arrival Sensor ZigBee is an untracked device. Disconnects when Hub goes OFFLINE.
|
||||||
|
|
||||||
|
|
||||||
|
## Battery
|
||||||
|
|
||||||
|
Uses 1 CR2032 Battery
|
||||||
|
|
||||||
|
* [Changing the Battery](https://support.smartthings.com/hc/en-us/articles/200907400-How-to-change-the-battery-in-the-SmartSense-Presence-Sensor-and-Samsung-SmartThings-Arrival-Sensor)
|
||||||
|
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
If the device doesn't pair when trying from the SmartThings mobile app, it is possible that the arrival sensor is out of range.
|
||||||
|
Pairing needs to be tried again by placing the sensor closer to the hub.
|
||||||
|
|
||||||
|
* [Samsung SmartThings Arrival Sensor Troubleshooting Tips](https://support.smartthings.com/hc/en-us/articles/205382134-Samsung-SmartThings-Arrival-Sensor-2015-model-)
|
||||||
|
|
||||||
|
If the arrival sensor doesn't update its status, here are a few things you can try to debug.
|
||||||
|
|
||||||
|
* [Troubleshooting: Samsung SmartThings Arrival Sensor won't update its status](https://support.smartthings.com/hc/en-us/articles/200846514-Troubleshooting-Samsung-SmartThings-Arrival-Sensor-won-t-update-its-status)
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2015 SmartThings
|
||||||
*
|
*
|
||||||
@@ -19,6 +21,7 @@ metadata {
|
|||||||
capability "Presence Sensor"
|
capability "Presence Sensor"
|
||||||
capability "Sensor"
|
capability "Sensor"
|
||||||
capability "Battery"
|
capability "Battery"
|
||||||
|
capability "Health Check"
|
||||||
|
|
||||||
fingerprint profileId: "FC01", deviceId: "019A"
|
fingerprint profileId: "FC01", deviceId: "019A"
|
||||||
fingerprint profileId: "FC01", deviceId: "0131", inClusters: "0000,0003", outClusters: "0003"
|
fingerprint profileId: "FC01", deviceId: "0131", inClusters: "0000,0003", outClusters: "0003"
|
||||||
@@ -111,6 +114,11 @@ def beep() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def installed() {
|
||||||
|
// Arrival sensors only goes OFFLINE when Hub is off
|
||||||
|
sendEvent(name: "DeviceWatch-Enroll", value: JsonOutput.toJson([protocol: "zigbee", scheme:"untracked"]), displayed: false)
|
||||||
|
}
|
||||||
|
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
def results
|
def results
|
||||||
if (isBatteryMessage(description)) {
|
if (isBatteryMessage(description)) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "Dimmer Switch", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.switch") {
|
definition (name: "Dimmer Switch", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.light") {
|
||||||
capability "Switch Level"
|
capability "Switch Level"
|
||||||
capability "Actuator"
|
capability "Actuator"
|
||||||
capability "Indicator"
|
capability "Indicator"
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ metadata {
|
|||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3320"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3320"
|
||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3321"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3321"
|
||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3321-S", deviceJoinName: "Multipurpose Sensor"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05,FC02", outClusters: "0019", manufacturer: "CentraLite", model: "3321-S", deviceJoinName: "Multipurpose Sensor"
|
||||||
fingerprint inClusters: "0000,0001,0003,0020,0402,0500,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3323-G", deviceJoinName: "Centralite Micro Door Sensor"
|
|
||||||
fingerprint inClusters: "0000,0001,0003,000F,0020,0402,0500,FC02", outClusters: "0019", manufacturer: "SmartThings", model: "multiv4", deviceJoinName: "Multipurpose Sensor"
|
fingerprint inClusters: "0000,0001,0003,000F,0020,0402,0500,FC02", outClusters: "0019", manufacturer: "SmartThings", model: "multiv4", deviceJoinName: "Multipurpose Sensor"
|
||||||
|
|
||||||
attribute "status", "string"
|
attribute "status", "string"
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ metadata {
|
|||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300-S"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300-S"
|
||||||
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300"
|
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3300"
|
||||||
fingerprint inClusters: "0000,0001,0003,0020,0402,0500,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3320-L", deviceJoinName: "Iris Contact Sensor"
|
fingerprint inClusters: "0000,0001,0003,0020,0402,0500,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3320-L", deviceJoinName: "Iris Contact Sensor"
|
||||||
|
fingerprint inClusters: "0000,0001,0003,0020,0402,0500,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3323-G", deviceJoinName: "Centralite Micro Door Sensor"
|
||||||
}
|
}
|
||||||
|
|
||||||
simulator {
|
simulator {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2016 SmartThings
|
* Copyright 2017 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,6 +64,7 @@ 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
|
||||||
@@ -84,11 +85,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) / 255 * 100)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 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) / 255 * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +124,12 @@ def ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
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.onOffRefresh() +
|
||||||
|
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() {
|
||||||
@@ -133,26 +139,38 @@ 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
|
||||||
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)
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
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() + setHue(value.hue) + "delay 500" + setSaturation(value.saturation)
|
zigbee.on() +
|
||||||
|
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) {
|
||||||
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") //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) {
|
||||||
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 1000" + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
def installed() {
|
def installed() {
|
||||||
@@ -161,4 +179,4 @@ def installed() {
|
|||||||
sendEvent(name: "level", value: 100)
|
sendEvent(name: "level", value: 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2016 SmartThings
|
* Copyright 2017 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,6 +78,7 @@ 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 }
|
||||||
|
|
||||||
@@ -102,11 +103,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) / 255 * 100)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 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) / 255 * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
sendEvent(name: "saturation", value: saturationValue, descriptionText: "Color has changed", displayed: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +142,13 @@ def ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
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.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()
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
@@ -156,7 +163,12 @@ def configure() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
zigbee.setColorTemperature(value)
|
value = value as Integer
|
||||||
|
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
|
||||||
@@ -180,19 +192,31 @@ 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() + setHue(value.hue) + "delay 300" + setSaturation(value.saturation)
|
zigbee.on() +
|
||||||
|
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) {
|
||||||
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") //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) {
|
||||||
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 1000" + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
def installed() {
|
def installed() {
|
||||||
@@ -201,4 +225,4 @@ def installed() {
|
|||||||
sendEvent(name: "level", value: 100)
|
sendEvent(name: "level", value: 100)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2015 SmartThings
|
* Copyright 2017 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:
|
||||||
@@ -71,6 +71,11 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Globals
|
||||||
|
private getMOVE_TO_COLOR_TEMPERATURE_COMMAND() { 0x0A }
|
||||||
|
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
||||||
|
private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 }
|
||||||
|
|
||||||
// Parse incoming device messages to generate events
|
// Parse incoming device messages to generate events
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
log.debug "description is $description"
|
log.debug "description is $description"
|
||||||
@@ -123,7 +128,11 @@ def ping() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh() + zigbee.onOffConfig(0, 300) + zigbee.levelConfig() + zigbee.colorTemperatureConfig()
|
zigbee.onOffRefresh() +
|
||||||
|
zigbee.levelRefresh() +
|
||||||
|
zigbee.colorTemperatureRefresh() +
|
||||||
|
zigbee.onOffConfig(0, 300) +
|
||||||
|
zigbee.levelConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
def configure() {
|
def configure() {
|
||||||
@@ -138,7 +147,12 @@ def configure() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
zigbee.setColorTemperature(value)
|
value = value as Integer
|
||||||
|
def tempInMired = (1000000 / value) as Integer
|
||||||
|
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
|
||||||
|
|
||||||
|
zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$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 2016 SmartThings
|
* Copyright 2017 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,6 +55,7 @@ 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
|
||||||
@@ -72,11 +73,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) / 255 * 360)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
||||||
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) / 255 * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,28 +109,46 @@ def configure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configureAttributes() {
|
def configureAttributes() {
|
||||||
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.onOffConfig() +
|
||||||
|
zigbee.levelConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
def refreshAttributes() {
|
def refreshAttributes() {
|
||||||
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
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.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() + setHue(value.hue) + ["delay 300"] + setSaturation(value.saturation) + ["delay 2000"] + refreshAttributes()
|
zigbee.on() +
|
||||||
|
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) {
|
||||||
def scaledHueValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
//payload-> hue value, direction (00-> shortest distance), transition time (1/10th second)
|
||||||
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.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, getScaledHue(value), "00", "0000") +
|
||||||
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setSaturation(value) {
|
def setSaturation(value) {
|
||||||
def scaledSatValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
//payload-> sat value, transition time
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, scaledSatValue, "0500") + ["delay 1500"] + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) //payload-> sat value, transition time
|
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, getScaledSaturation(value), "0000") +
|
||||||
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2016 SmartThings
|
* Copyright 2017 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,6 +70,7 @@ 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 }
|
||||||
|
|
||||||
@@ -88,11 +89,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) / 255 * 360)
|
def hueValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
||||||
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) / 255 * 100)
|
def saturationValue = Math.round(zigbee.convertHexToInt(zigbeeMap.value) / 0xfe * 100)
|
||||||
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
sendEvent(name: "saturation", value: saturationValue, displayed:false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -124,11 +125,16 @@ def configure() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def configureAttributes() {
|
def configureAttributes() {
|
||||||
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.onOffConfig() +
|
||||||
|
zigbee.levelConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
def refreshAttributes() {
|
def refreshAttributes() {
|
||||||
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh() + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
zigbee.onOffRefresh() +
|
||||||
|
zigbee.levelRefresh() +
|
||||||
|
zigbee.colorTemperatureRefresh() +
|
||||||
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE) +
|
||||||
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
@@ -139,17 +145,32 @@ 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() + setHue(value.hue) + ["delay 300"] + setSaturation(value.saturation) + ["delay 2000"] + refreshAttributes()
|
zigbee.on() +
|
||||||
|
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) {
|
||||||
def scaledHueValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
//payload-> hue value, direction (00-> shortest distance), transition time (1/10th second)
|
||||||
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.command(COLOR_CONTROL_CLUSTER, HUE_COMMAND, getScaledHue(value), "00", "0000") +
|
||||||
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_HUE)
|
||||||
}
|
}
|
||||||
|
|
||||||
def setSaturation(value) {
|
def setSaturation(value) {
|
||||||
def scaledSatValue = zigbee.convertToHexString(Math.round(value * 0xfe / 100.0), 2)
|
//payload-> sat value, transition time
|
||||||
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, scaledSatValue, "0500") + ["delay 1500"] + zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION) //payload-> sat value, transition time
|
zigbee.command(COLOR_CONTROL_CLUSTER, SATURATION_COMMAND, getScaledSaturation(value), "0000") +
|
||||||
|
zigbee.readAttribute(COLOR_CONTROL_CLUSTER, ATTRIBUTE_SATURATION)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright 2016 SmartThings
|
* Copyright 2017 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:
|
||||||
@@ -66,6 +66,11 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Globals
|
||||||
|
private getMOVE_TO_COLOR_TEMPERATURE_COMMAND() { 0x0A }
|
||||||
|
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
||||||
|
private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 }
|
||||||
|
|
||||||
// Parse incoming device messages to generate events
|
// Parse incoming device messages to generate events
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
log.debug "description is $description"
|
log.debug "description is $description"
|
||||||
@@ -95,14 +100,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 = cmds + zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig()
|
cmds += zigbee.onOffConfig() + zigbee.levelConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
cmds
|
cmds
|
||||||
}
|
}
|
||||||
|
|
||||||
def poll() {
|
def poll() {
|
||||||
@@ -138,7 +143,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.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
@@ -148,7 +153,12 @@ def updated() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
zigbee.setColorTemperature(value) + ["delay 1500"] + zigbee.colorTemperatureRefresh()
|
value = value as Integer
|
||||||
|
def tempInMired = (1000000 / value) as Integer
|
||||||
|
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
|
||||||
|
|
||||||
|
zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$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 2016 SmartThings
|
* Copyright 2017 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:
|
||||||
@@ -68,6 +68,11 @@ metadata {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Globals
|
||||||
|
private getMOVE_TO_COLOR_TEMPERATURE_COMMAND() { 0x0A }
|
||||||
|
private getCOLOR_CONTROL_CLUSTER() { 0x0300 }
|
||||||
|
private getATTRIBUTE_COLOR_TEMPERATURE() { 0x0007 }
|
||||||
|
|
||||||
// Parse incoming device messages to generate events
|
// Parse incoming device messages to generate events
|
||||||
def parse(String description) {
|
def parse(String description) {
|
||||||
log.debug "description is $description"
|
log.debug "description is $description"
|
||||||
@@ -94,7 +99,11 @@ def setLevel(value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def refresh() {
|
def refresh() {
|
||||||
zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh() + zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig()
|
zigbee.onOffRefresh() +
|
||||||
|
zigbee.levelRefresh() +
|
||||||
|
zigbee.colorTemperatureRefresh() +
|
||||||
|
zigbee.onOffConfig() +
|
||||||
|
zigbee.levelConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
def poll() {
|
def poll() {
|
||||||
@@ -129,8 +138,7 @@ def configureHealthCheck() {
|
|||||||
def configure() {
|
def configure() {
|
||||||
log.debug "configure()"
|
log.debug "configure()"
|
||||||
configureHealthCheck()
|
configureHealthCheck()
|
||||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.colorTemperatureConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.colorTemperatureRefresh()
|
refresh()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
@@ -140,7 +148,12 @@ def updated() {
|
|||||||
|
|
||||||
def setColorTemperature(value) {
|
def setColorTemperature(value) {
|
||||||
setGenericName(value)
|
setGenericName(value)
|
||||||
zigbee.setColorTemperature(value) + ["delay 1500"] + zigbee.colorTemperatureRefresh()
|
value = value as Integer
|
||||||
|
def tempInMired = (1000000 / value) as Integer
|
||||||
|
def finalHex = zigbee.swapEndianHex(zigbee.convertToHexString(tempInMired, 4))
|
||||||
|
|
||||||
|
zigbee.command(COLOR_CONTROL_CLUSTER, MOVE_TO_COLOR_TEMPERATURE_COMMAND, "$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
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
metadata {
|
metadata {
|
||||||
definition (name: "Z-Wave Metering Dimmer", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.switch") {
|
definition (name: "Z-Wave Metering Dimmer", namespace: "smartthings", author: "SmartThings", ocfDeviceType: "oic.d.light") {
|
||||||
capability "Switch"
|
capability "Switch"
|
||||||
capability "Polling"
|
capability "Polling"
|
||||||
capability "Power Meter"
|
capability "Power Meter"
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
import javax.crypto.Mac;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.security.InvalidKeyException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OpenT2T SmartApp Test
|
* OpenT2T SmartApp Test
|
||||||
*
|
*
|
||||||
@@ -39,7 +43,7 @@ definition(
|
|||||||
* garageDoors | door | open, close | unknown, closed, open, closing, opening
|
* garageDoors | door | open, close | unknown, closed, open, closing, opening
|
||||||
* cameras | image | take | <String>
|
* cameras | image | take | <String>
|
||||||
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
|
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
|
||||||
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
|
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
|
||||||
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
|
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
|
||||||
* | | emergencyHeat, |
|
* | | emergencyHeat, |
|
||||||
* | | setThermostatMode, |
|
* | | setThermostatMode, |
|
||||||
@@ -55,7 +59,7 @@ preferences {
|
|||||||
input "contactSensors", "capability.contactSensor", title: "Which Contact Sensors", multiple: true, required: false, hideWhenEmpty: true
|
input "contactSensors", "capability.contactSensor", title: "Which Contact Sensors", multiple: true, required: false, hideWhenEmpty: true
|
||||||
input "garageDoors", "capability.garageDoorControl", title: "Which Garage Doors?", multiple: true, required: false, hideWhenEmpty: true
|
input "garageDoors", "capability.garageDoorControl", title: "Which Garage Doors?", multiple: true, required: false, hideWhenEmpty: true
|
||||||
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false, hideWhenEmpty: true
|
input "locks", "capability.lock", title: "Which Locks?", multiple: true, required: false, hideWhenEmpty: true
|
||||||
input "cameras", "capability.videoCapture", title: "Which Cameras?", multiple: true, required: false, hideWhenEmpty: true
|
input "cameras", "capability.videoCapture", title: "Which Cameras?", multiple: true, required: false, hideWhenEmpty: true
|
||||||
input "motionSensors", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false, hideWhenEmpty: true
|
input "motionSensors", "capability.motionSensor", title: "Which Motion Sensors?", multiple: true, required: false, hideWhenEmpty: true
|
||||||
input "presenceSensors", "capability.presenceSensor", title: "Which Presence Sensors", multiple: true, required: false, hideWhenEmpty: true
|
input "presenceSensors", "capability.presenceSensor", title: "Which Presence Sensors", multiple: true, required: false, hideWhenEmpty: true
|
||||||
input "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false, hideWhenEmpty: true
|
input "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false, hideWhenEmpty: true
|
||||||
@@ -66,44 +70,49 @@ preferences {
|
|||||||
|
|
||||||
def getInputs() {
|
def getInputs() {
|
||||||
def inputList = []
|
def inputList = []
|
||||||
inputList += contactSensors?: []
|
inputList += contactSensors ?: []
|
||||||
inputList += garageDoors?: []
|
inputList += garageDoors ?: []
|
||||||
inputList += locks?: []
|
inputList += locks ?: []
|
||||||
inputList += cameras?: []
|
inputList += cameras ?: []
|
||||||
inputList += motionSensors?: []
|
inputList += motionSensors ?: []
|
||||||
inputList += presenceSensors?: []
|
inputList += presenceSensors ?: []
|
||||||
inputList += switches?: []
|
inputList += switches ?: []
|
||||||
inputList += thermostats?: []
|
inputList += thermostats ?: []
|
||||||
inputList += waterSensors?: []
|
inputList += waterSensors ?: []
|
||||||
return inputList
|
return inputList
|
||||||
}
|
}
|
||||||
|
|
||||||
//API external Endpoints
|
//API external Endpoints
|
||||||
mappings {
|
mappings {
|
||||||
path("/devices") {
|
path("/devices") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
GET: "getDevices"
|
GET: "getDevices"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/devices/:id") {
|
path("/devices/:id") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
GET: "getDevice"
|
GET: "getDevice"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/update/:id") {
|
path("/update/:id") {
|
||||||
action: [
|
action:
|
||||||
|
[
|
||||||
PUT: "updateDevice"
|
PUT: "updateDevice"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/deviceSubscription") {
|
path("/deviceSubscription") {
|
||||||
action: [
|
action:
|
||||||
POST: "registerDeviceChange",
|
[
|
||||||
|
POST : "registerDeviceChange",
|
||||||
DELETE: "unregisterDeviceChange"
|
DELETE: "unregisterDeviceChange"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
path("/locationSubscription") {
|
path("/locationSubscription") {
|
||||||
action: [
|
action:
|
||||||
POST: "registerDeviceGraph",
|
[
|
||||||
|
POST : "registerDeviceGraph",
|
||||||
DELETE: "unregisterDeviceGraph"
|
DELETE: "unregisterDeviceGraph"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -116,14 +125,21 @@ def installed() {
|
|||||||
|
|
||||||
def updated() {
|
def updated() {
|
||||||
log.debug "Updating with settings: ${settings}"
|
log.debug "Updating with settings: ${settings}"
|
||||||
if(state.deviceSubscriptionMap == null){
|
|
||||||
|
//Initialize state variables if didn't exist.
|
||||||
|
if (state.deviceSubscriptionMap == null) {
|
||||||
state.deviceSubscriptionMap = [:]
|
state.deviceSubscriptionMap = [:]
|
||||||
log.debug "deviceSubscriptionMap created."
|
log.debug "deviceSubscriptionMap created."
|
||||||
}
|
}
|
||||||
if( state.locationSubscriptionMap == null){
|
if (state.locationSubscriptionMap == null) {
|
||||||
state.locationSubscriptionMap = [:]
|
state.locationSubscriptionMap = [:]
|
||||||
log.debug "locationSubscriptionMap created."
|
log.debug "locationSubscriptionMap created."
|
||||||
}
|
}
|
||||||
|
if (state.verificationKeyMap == null) {
|
||||||
|
state.verificationKeyMap = [:]
|
||||||
|
log.debug "verificationKeyMap created."
|
||||||
|
}
|
||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
registerAllDeviceSubscriptions()
|
registerAllDeviceSubscriptions()
|
||||||
}
|
}
|
||||||
@@ -132,9 +148,11 @@ def initialize() {
|
|||||||
log.debug "Initializing with settings: ${settings}"
|
log.debug "Initializing with settings: ${settings}"
|
||||||
state.deviceSubscriptionMap = [:]
|
state.deviceSubscriptionMap = [:]
|
||||||
log.debug "deviceSubscriptionMap created."
|
log.debug "deviceSubscriptionMap created."
|
||||||
registerAllDeviceSubscriptions()
|
|
||||||
state.locationSubscriptionMap = [:]
|
state.locationSubscriptionMap = [:]
|
||||||
log.debug "locationSubscriptionMap created."
|
log.debug "locationSubscriptionMap created."
|
||||||
|
state.verificationKeyMap = [:]
|
||||||
|
log.debug "verificationKeyMap created."
|
||||||
|
registerAllDeviceSubscriptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** Subscription Functions ***/
|
/*** Subscription Functions ***/
|
||||||
@@ -144,47 +162,43 @@ def registerAllDeviceSubscriptions() {
|
|||||||
registerChangeHandler(inputs)
|
registerChangeHandler(inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Subscribe to events from a list of devices
|
|
||||||
def registerChangeHandler(myList) {
|
|
||||||
myList.each { myDevice ->
|
|
||||||
def theAtts = myDevice.supportedAttributes
|
|
||||||
theAtts.each {att ->
|
|
||||||
subscribe(myDevice, att.name, deviceEventHandler)
|
|
||||||
log.info "Registering for ${myDevice.displayName}.${att.name}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Endpoints function: Subscribe to events from a specific device
|
//Endpoints function: Subscribe to events from a specific device
|
||||||
def registerDeviceChange() {
|
def registerDeviceChange() {
|
||||||
def subscriptionEndpt = params.subscriptionURL
|
def subscriptionEndpt = params.subscriptionURL
|
||||||
def deviceId = params.deviceId
|
def deviceId = params.deviceId
|
||||||
def myDevice = findDevice(deviceId)
|
def myDevice = findDevice(deviceId)
|
||||||
if( myDevice == null ){
|
|
||||||
|
if (myDevice == null) {
|
||||||
httpError(404, "Cannot find device with device ID ${deviceId}.")
|
httpError(404, "Cannot find device with device ID ${deviceId}.")
|
||||||
}
|
}
|
||||||
|
|
||||||
def theAtts = myDevice.supportedAttributes
|
def theAtts = myDevice.supportedAttributes
|
||||||
try {
|
try {
|
||||||
theAtts.each {att ->
|
theAtts.each { att ->
|
||||||
subscribe(myDevice, att.name, deviceEventHandler)
|
subscribe(myDevice, att.name, deviceEventHandler)
|
||||||
}
|
}
|
||||||
log.info "Subscribing for ${myDevice.displayName}"
|
log.info "Subscribing for ${myDevice.displayName}"
|
||||||
|
|
||||||
if(subscriptionEndpt != null){
|
if (subscriptionEndpt != null) {
|
||||||
if(state.deviceSubscriptionMap[deviceId] == null){
|
if (state.deviceSubscriptionMap[deviceId] == null) {
|
||||||
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
|
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
||||||
} else if (!state.deviceSubscriptionMap[deviceId].contains(subscriptionEndpt)){
|
} else if (!state.deviceSubscriptionMap[deviceId].contains(subscriptionEndpt)) {
|
||||||
state.deviceSubscriptionMap[deviceId] << subscriptionEndpt
|
state.deviceSubscriptionMap[deviceId] << subscriptionEndpt
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.key != null) {
|
||||||
|
state.verificationKeyMap[subscriptionEndpt] = params.key
|
||||||
|
log.info "Added verification key: ${params.key} for ${subscriptionEndpt}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
httpError(500, "something went wrong: $e")
|
httpError(500, "something went wrong: $e")
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
|
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
|
||||||
|
log.info "Current verification key map is ${state.verificationKeyMap}"
|
||||||
return ["succeed"]
|
return ["succeed"]
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,18 +208,19 @@ def unregisterDeviceChange() {
|
|||||||
def deviceId = params.deviceId
|
def deviceId = params.deviceId
|
||||||
def myDevice = findDevice(deviceId)
|
def myDevice = findDevice(deviceId)
|
||||||
|
|
||||||
if( myDevice == null ){
|
if (myDevice == null) {
|
||||||
httpError(404, "Cannot find device with device ID ${deviceId}.")
|
httpError(404, "Cannot find device with device ID ${deviceId}.")
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
|
if (subscriptionEndpt != null && subscriptionEndpt != "undefined") {
|
||||||
if (state.deviceSubscriptionMap[deviceId]?.contains(subscriptionEndpt)){
|
if (state.deviceSubscriptionMap[deviceId]?.contains(subscriptionEndpt)) {
|
||||||
if(state.deviceSubscriptionMap[deviceId].size() == 1){
|
if (state.deviceSubscriptionMap[deviceId].size() == 1) {
|
||||||
state.deviceSubscriptionMap.remove(deviceId)
|
state.deviceSubscriptionMap.remove(deviceId)
|
||||||
} else {
|
} else {
|
||||||
state.deviceSubscriptionMap[deviceId].remove(subscriptionEndpt)
|
state.deviceSubscriptionMap[deviceId].remove(subscriptionEndpt)
|
||||||
}
|
}
|
||||||
|
state.verificationKeyMap.remove(subscriptionEndpt)
|
||||||
log.info "Removed subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
log.info "Removed subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -217,25 +232,33 @@ def unregisterDeviceChange() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
|
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
|
||||||
|
log.info "Current verification key map is ${state.verificationKeyMap}"
|
||||||
}
|
}
|
||||||
|
|
||||||
//Endpoints function: Subscribe to device additiona/removal updated in a location
|
//Endpoints function: Subscribe to device additiona/removal updated in a location
|
||||||
def registerDeviceGraph() {
|
def registerDeviceGraph() {
|
||||||
def subscriptionEndpt = params.subscriptionURL
|
def subscriptionEndpt = params.subscriptionURL
|
||||||
|
|
||||||
if (subscriptionEndpt != null && subscriptionEndpt != "undefined"){
|
if (subscriptionEndpt != null && subscriptionEndpt != "undefined") {
|
||||||
subscribe(location, "DeviceCreated", locationEventHandler, [filterEvents: false])
|
subscribe(location, "DeviceCreated", locationEventHandler, [filterEvents: false])
|
||||||
subscribe(location, "DeviceUpdated", locationEventHandler, [filterEvents: false])
|
subscribe(location, "DeviceUpdated", locationEventHandler, [filterEvents: false])
|
||||||
subscribe(location, "DeviceDeleted", locationEventHandler, [filterEvents: false])
|
subscribe(location, "DeviceDeleted", locationEventHandler, [filterEvents: false])
|
||||||
|
|
||||||
if(state.locationSubscriptionMap[location.id] == null){
|
if (state.locationSubscriptionMap[location.id] == null) {
|
||||||
state.locationSubscriptionMap.put(location.id, [subscriptionEndpt])
|
state.locationSubscriptionMap.put(location.id, [subscriptionEndpt])
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
||||||
} else if (!state.locationSubscriptionMap[location.id].contains(subscriptionEndpt)){
|
} else if (!state.locationSubscriptionMap[location.id].contains(subscriptionEndpt)) {
|
||||||
state.locationSubscriptionMap[location.id] << subscriptionEndpt
|
state.locationSubscriptionMap[location.id] << subscriptionEndpt
|
||||||
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (params.key != null) {
|
||||||
|
state.verificationKeyMap[subscriptionEndpt] = params.key
|
||||||
|
log.info "Added verification key: ${params.key} for ${subscriptionEndpt}"
|
||||||
|
}
|
||||||
|
|
||||||
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
|
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
|
||||||
|
log.info "Current verification key map is ${state.verificationKeyMap}"
|
||||||
return ["succeed"]
|
return ["succeed"]
|
||||||
} else {
|
} else {
|
||||||
httpError(400, "missing input parameter: subscriptionURL")
|
httpError(400, "missing input parameter: subscriptionURL")
|
||||||
@@ -247,16 +270,17 @@ def unregisterDeviceGraph() {
|
|||||||
def subscriptionEndpt = params.subscriptionURL
|
def subscriptionEndpt = params.subscriptionURL
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
|
if (subscriptionEndpt != null && subscriptionEndpt != "undefined") {
|
||||||
if (state.locationSubscriptionMap[location.id]?.contains(subscriptionEndpt)){
|
if (state.locationSubscriptionMap[location.id]?.contains(subscriptionEndpt)) {
|
||||||
if(state.locationSubscriptionMap[location.id].size() == 1){
|
if (state.locationSubscriptionMap[location.id].size() == 1) {
|
||||||
state.locationSubscriptionMap.remove(location.id)
|
state.locationSubscriptionMap.remove(location.id)
|
||||||
} else {
|
} else {
|
||||||
state.locationSubscriptionMap[location.id].remove(subscriptionEndpt)
|
state.locationSubscriptionMap[location.id].remove(subscriptionEndpt)
|
||||||
}
|
}
|
||||||
|
state.verificationKeyMap.remove(subscriptionEndpt)
|
||||||
log.info "Removed subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
log.info "Removed subscription URL: ${subscriptionEndpt} for Location ${location.name}"
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
httpError(400, "missing input parameter: subscriptionURL")
|
httpError(400, "missing input parameter: subscriptionURL")
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -264,28 +288,40 @@ def unregisterDeviceGraph() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
|
log.info "Current location subscription map is ${state.locationSubscriptionMap}"
|
||||||
|
log.info "Current verification key map is ${state.verificationKeyMap}"
|
||||||
}
|
}
|
||||||
|
|
||||||
//When events are triggered, send HTTP post to web socket servers
|
//When events are triggered, send HTTP post to web socket servers
|
||||||
def deviceEventHandler(evt) {
|
def deviceEventHandler(evt) {
|
||||||
def evt_device = evt.device
|
def evtDevice = evt.device
|
||||||
def evt_deviceType = getDeviceType(evt_device)
|
def evtDeviceType = getDeviceType(evtDevice)
|
||||||
def deviceInfo
|
def deviceData = [];
|
||||||
|
|
||||||
def params = [ body: [deviceName: evt_device.displayName, deviceId: evt_device.id, locationId: location.id] ]
|
if (evt.data != null) {
|
||||||
|
|
||||||
if(evt.data != null){
|
|
||||||
def evtData = parseJson(evt.data)
|
def evtData = parseJson(evt.data)
|
||||||
log.info "Received event for ${evt_device.displayName}, data: ${evtData}, description: ${evt.descriptionText}"
|
log.info "Received event for ${evtDevice.displayName}, data: ${evtData}, description: ${evt.descriptionText}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (evtDeviceType == "thermostat") {
|
||||||
|
deviceData = [name: evtDevice.displayName, id: evtDevice.id, status: evtDevice.status, deviceType: evtDeviceType, manufacturer: evtDevice.manufacturerName, model: evtDevice.modelName, attributes: deviceAttributeList(evtDevice, evtDeviceType), locationMode: getLocationModeInfo(), locationId: location.id]
|
||||||
|
} else {
|
||||||
|
deviceData = [name: evtDevice.displayName, id: evtDevice.id, status: evtDevice.status, deviceType: evtDeviceType, manufacturer: evtDevice.manufacturerName, model: evtDevice.modelName, attributes: deviceAttributeList(evtDevice, evtDeviceType), locationId: location.id]
|
||||||
|
}
|
||||||
|
|
||||||
|
def params = [body: deviceData]
|
||||||
|
|
||||||
//send event to all subscriptions urls
|
//send event to all subscriptions urls
|
||||||
log.debug "Current subscription urls for ${evt_device.displayName} is ${state.deviceSubscriptionMap[evt_device.id]}"
|
log.debug "Current subscription urls for ${evtDevice.displayName} is ${state.deviceSubscriptionMap[evtDevice.id]}"
|
||||||
state.deviceSubscriptionMap[evt_device.id].each {
|
state.deviceSubscriptionMap[evtDevice.id].each {
|
||||||
params.uri = "${it}"
|
params.uri = "${it}"
|
||||||
|
if (state.verificationKeyMap[it] != null) {
|
||||||
|
def key = state.verificationKeyMap[it]
|
||||||
|
params.header = [Signature: ComputHMACValue(key, groovy.json.JsonOutput.toJson(params.body))]
|
||||||
|
}
|
||||||
log.trace "POST URI: ${params.uri}"
|
log.trace "POST URI: ${params.uri}"
|
||||||
|
log.trace "Header: ${params.header}"
|
||||||
log.trace "Payload: ${params.body}"
|
log.trace "Payload: ${params.body}"
|
||||||
try{
|
try {
|
||||||
httpPostJson(params) { resp ->
|
httpPostJson(params) { resp ->
|
||||||
log.trace "response status code: ${resp.status}"
|
log.trace "response status code: ${resp.status}"
|
||||||
log.trace "response data: ${resp.data}"
|
log.trace "response data: ${resp.data}"
|
||||||
@@ -298,20 +334,27 @@ def deviceEventHandler(evt) {
|
|||||||
|
|
||||||
def locationEventHandler(evt) {
|
def locationEventHandler(evt) {
|
||||||
log.info "Received event for location ${location.name}/${location.id}, Event: ${evt.name}, description: ${evt.descriptionText}, apiServerUrl: ${apiServerUrl("")}"
|
log.info "Received event for location ${location.name}/${location.id}, Event: ${evt.name}, description: ${evt.descriptionText}, apiServerUrl: ${apiServerUrl("")}"
|
||||||
switch(evt.name){
|
switch (evt.name) {
|
||||||
case "DeviceCreated":
|
case "DeviceCreated":
|
||||||
case "DeviceDeleted":
|
case "DeviceDeleted":
|
||||||
def evt_device = evt.device
|
def evtDevice = evt.device
|
||||||
def evt_deviceType = getDeviceType(evt_device)
|
def evtDeviceType = getDeviceType(evtDevice)
|
||||||
log.info "DeviceName: ${evt_device.displayName}, DeviceID: ${evt_device.id}, deviceType: ${evt_deviceType}"
|
def params = [body: [eventType: evt.name, deviceId: evtDevice.id, locationId: location.id]]
|
||||||
|
|
||||||
def params = [ body: [ eventType:evt.name, deviceId: evt_device.id, locationId: location.id ] ]
|
if (evt.name == "DeviceDeleted" && state.deviceSubscriptionMap[deviceId] != null) {
|
||||||
|
state.deviceSubscriptionMap.remove(evtDevice.id)
|
||||||
|
}
|
||||||
|
|
||||||
state.locationSubscriptionMap[location.id].each {
|
state.locationSubscriptionMap[location.id].each {
|
||||||
params.uri = "${it}"
|
params.uri = "${it}"
|
||||||
|
if (state.verificationKeyMap[it] != null) {
|
||||||
|
def key = state.verificationKeyMap[it]
|
||||||
|
params.header = [Signature: ComputHMACValue(key, groovy.json.JsonOutput.toJson(params.body))]
|
||||||
|
}
|
||||||
log.trace "POST URI: ${params.uri}"
|
log.trace "POST URI: ${params.uri}"
|
||||||
|
log.trace "Header: ${params.header}"
|
||||||
log.trace "Payload: ${params.body}"
|
log.trace "Payload: ${params.body}"
|
||||||
try{
|
try {
|
||||||
httpPostJson(params) { resp ->
|
httpPostJson(params) { resp ->
|
||||||
log.trace "response status code: ${resp.status}"
|
log.trace "response status code: ${resp.status}"
|
||||||
log.trace "response data: ${resp.data}"
|
log.trace "response data: ${resp.data}"
|
||||||
@@ -326,6 +369,23 @@ def locationEventHandler(evt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ComputHMACValue(key, data) {
|
||||||
|
try {
|
||||||
|
SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1")
|
||||||
|
Mac mac = Mac.getInstance("HmacSHA1")
|
||||||
|
mac.init(secretKeySpec)
|
||||||
|
byte[] digest = mac.doFinal(data.getBytes("UTF-8"))
|
||||||
|
return byteArrayToString(digest)
|
||||||
|
} catch (InvalidKeyException e) {
|
||||||
|
log.error "Invalid key exception while converting to HMac SHA1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private def byteArrayToString(byte[] data) {
|
||||||
|
BigInteger bigInteger = new BigInteger(1, data)
|
||||||
|
String hash = bigInteger.toString(16)
|
||||||
|
return hash
|
||||||
|
}
|
||||||
|
|
||||||
/*** Device Query/Update Functions ***/
|
/*** Device Query/Update Functions ***/
|
||||||
|
|
||||||
@@ -334,10 +394,10 @@ def getDevices() {
|
|||||||
def deviceData = []
|
def deviceData = []
|
||||||
inputs?.each {
|
inputs?.each {
|
||||||
def deviceType = getDeviceType(it)
|
def deviceType = getDeviceType(it)
|
||||||
if(deviceType == "thermostat") {
|
if (deviceType == "thermostat") {
|
||||||
deviceData << [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType), locationMode: getLocationModeInfo()]
|
deviceData << [name: it.displayName, id: it.id, status: it.status, deviceType: deviceType, manufacturer: it.manufacturerName, model: it.modelName, attributes: deviceAttributeList(it, deviceType), locationMode: getLocationModeInfo()]
|
||||||
} else {
|
} else {
|
||||||
deviceData << [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType)]
|
deviceData << [name: it.displayName, id: it.id, status: it.status, deviceType: deviceType, manufacturer: it.manufacturerName, model: it.modelName, attributes: deviceAttributeList(it, deviceType)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,10 +410,10 @@ def getDevice() {
|
|||||||
def it = findDevice(params.id)
|
def it = findDevice(params.id)
|
||||||
def deviceType = getDeviceType(it)
|
def deviceType = getDeviceType(it)
|
||||||
def device
|
def device
|
||||||
if(deviceType == "thermostat") {
|
if (deviceType == "thermostat") {
|
||||||
device = [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it,deviceType), locationMode: getLocationModeInfo()]
|
device = [name: it.displayName, id: it.id, status: it.status, deviceType: deviceType, manufacturer: it.manufacturerName, model: it.modelName, attributes: deviceAttributeList(it, deviceType), locationMode: getLocationModeInfo()]
|
||||||
} else {
|
} else {
|
||||||
device = [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType)]
|
device = [name: it.displayName, id: it.id, status: it.status, deviceType: deviceType, manufacturer: it.manufacturerName, model: it.modelName, attributes: deviceAttributeList(it, deviceType)]
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug "getDevice, return: ${device}"
|
log.debug "getDevice, return: ${device}"
|
||||||
@@ -366,18 +426,18 @@ void updateDevice() {
|
|||||||
request.JSON.each {
|
request.JSON.each {
|
||||||
def command = it.key
|
def command = it.key
|
||||||
def value = it.value
|
def value = it.value
|
||||||
if (command){
|
if (command) {
|
||||||
def commandList = mapDeviceCommands(command, value)
|
def commandList = mapDeviceCommands(command, value)
|
||||||
command = commandList[0]
|
command = commandList[0]
|
||||||
value = commandList[1]
|
value = commandList[1]
|
||||||
|
|
||||||
if (command == "setAwayMode") {
|
if (command == "setAwayMode") {
|
||||||
log.info "Setting away mode to ${value}"
|
log.info "Setting away mode to ${value}"
|
||||||
if (location.modes?.find {it.name == value}) {
|
if (location.modes?.find { it.name == value }) {
|
||||||
location.setMode(value)
|
location.setMode(value)
|
||||||
}
|
}
|
||||||
}else if (command == "thermostatSetpoint"){
|
} else if (command == "thermostatSetpoint") {
|
||||||
switch(device.currentThermostatMode){
|
switch (device.currentThermostatMode) {
|
||||||
case "cool":
|
case "cool":
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||||
device.setCoolingSetpoint(value)
|
device.setCoolingSetpoint(value)
|
||||||
@@ -391,7 +451,7 @@ void updateDevice() {
|
|||||||
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
|
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}else if (!device) {
|
} else if (!device) {
|
||||||
log.error "updateDevice, Device not found"
|
log.error "updateDevice, Device not found"
|
||||||
httpError(404, "Device not found")
|
httpError(404, "Device not found")
|
||||||
} else if (!device.hasCommand(command)) {
|
} else if (!device.hasCommand(command)) {
|
||||||
@@ -401,11 +461,11 @@ void updateDevice() {
|
|||||||
if (command == "setColor") {
|
if (command == "setColor") {
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||||
device."$command"(hex: value)
|
device."$command"(hex: value)
|
||||||
} else if(value.isNumber()) {
|
} else if (value.isNumber()) {
|
||||||
def intValue = value as Integer
|
def intValue = value as Integer
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
|
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
|
||||||
device."$command"(intValue)
|
device."$command"(intValue)
|
||||||
} else if (value){
|
} else if (value) {
|
||||||
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
log.info "Update: ${device.displayName}, [${command}, ${value}]"
|
||||||
device."$command"(value)
|
device."$command"(value)
|
||||||
} else {
|
} else {
|
||||||
@@ -432,17 +492,16 @@ private getDeviceType(device) {
|
|||||||
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
|
||||||
|
|
||||||
//Loop through the device capability list to determine the device type.
|
//Loop through the device capability list to determine the device type.
|
||||||
capabilities.each {capability ->
|
capabilities.each { capability ->
|
||||||
switch(capability.name.toLowerCase())
|
switch (capability.name.toLowerCase()) {
|
||||||
{
|
|
||||||
case "switch":
|
case "switch":
|
||||||
deviceType = "switch"
|
deviceType = "switch"
|
||||||
|
|
||||||
//If the device also contains "Switch Level" capability, identify it as a "light" device.
|
//If the device also contains "Switch Level" capability, identify it as a "light" device.
|
||||||
if (capabilities.any{it.name.toLowerCase() == "switch level"}){
|
if (capabilities.any { it.name.toLowerCase() == "switch level" }) {
|
||||||
|
|
||||||
//If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device.
|
//If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device.
|
||||||
if (capabilities.any{it.name.toLowerCase() == "power meter"}){
|
if (capabilities.any { it.name.toLowerCase() == "power meter" }) {
|
||||||
deviceType = "dimmerSwitch"
|
deviceType = "dimmerSwitch"
|
||||||
return deviceType
|
return deviceType
|
||||||
} else {
|
} else {
|
||||||
@@ -489,24 +548,24 @@ private deviceAttributeList(device, deviceType) {
|
|||||||
allAttributes.each { attribute ->
|
allAttributes.each { attribute ->
|
||||||
try {
|
try {
|
||||||
def currentState = device.currentState(attribute.name)
|
def currentState = device.currentState(attribute.name)
|
||||||
if(currentState != null ){
|
if (currentState != null) {
|
||||||
switch(attribute.name){
|
switch (attribute.name) {
|
||||||
case 'temperature':
|
case 'temperature':
|
||||||
attributeList.putAll([ (attribute.name): currentState.value, 'temperatureScale':location.temperatureScale ])
|
attributeList.putAll([(attribute.name): currentState.value, 'temperatureScale': location.temperatureScale])
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
attributeList.putAll([(attribute.name): currentState.value ])
|
attributeList.putAll([(attribute.name): currentState.value])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if( deviceType == "genericSensor" ){
|
if (deviceType == "genericSensor") {
|
||||||
def key = attribute.name + "_lastUpdated"
|
def key = attribute.name + "_lastUpdated"
|
||||||
attributeList.putAll([ (key): currentState.isoDate ])
|
attributeList.putAll([(key): currentState.isoDate])
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
attributeList.putAll([ (attribute.name): null ]);
|
attributeList.putAll([(attribute.name): null]);
|
||||||
}
|
}
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
attributeList.putAll([ (attribute.name): null ]);
|
attributeList.putAll([(attribute.name): null]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return attributeList
|
return attributeList
|
||||||
@@ -579,8 +638,7 @@ private mapDeviceCommands(command, value) {
|
|||||||
if (value == 1 || value == "1" || value == "lock") {
|
if (value == 1 || value == "1" || value == "lock") {
|
||||||
resultCommand = "lock"
|
resultCommand = "lock"
|
||||||
resultValue = ""
|
resultValue = ""
|
||||||
}
|
} else if (value == 0 || value == "0" || value == "unlock") {
|
||||||
else if (value == 0 || value == "0" || value == "unlock") {
|
|
||||||
resultCommand = "unlock"
|
resultCommand = "unlock"
|
||||||
resultValue = ""
|
resultValue = ""
|
||||||
}
|
}
|
||||||
@@ -589,5 +647,5 @@ private mapDeviceCommands(command, value) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
return [resultCommand,resultValue]
|
return [resultCommand, resultValue]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,10 +136,20 @@ def getDataForChild(child, startDate, endDate) {
|
|||||||
|
|
||||||
def wattvisionURL = wattvisionURL(child.deviceNetworkId, startDate, endDate)
|
def wattvisionURL = wattvisionURL(child.deviceNetworkId, startDate, endDate)
|
||||||
if (wattvisionURL) {
|
if (wattvisionURL) {
|
||||||
httpGet(uri: wattvisionURL) { response ->
|
try {
|
||||||
def json = new org.json.JSONObject(response.data.toString())
|
httpGet(uri: wattvisionURL) { response ->
|
||||||
child.addWattvisionData(json)
|
def json = new org.json.JSONObject(response.data.toString())
|
||||||
return "success"
|
child.addWattvisionData(json)
|
||||||
|
return "success"
|
||||||
|
}
|
||||||
|
} catch (groovyx.net.http.HttpResponseException httpE) {
|
||||||
|
log.error "Wattvision getDataForChild HttpResponseException: ${httpE} -> ${httpE.response.data}"
|
||||||
|
//log.debug "wattvisionURL = ${wattvisionURL}"
|
||||||
|
return "fail"
|
||||||
|
} catch (e) {
|
||||||
|
log.error "Wattvision getDataForChild General Exception: ${e}"
|
||||||
|
//log.debug "wattvisionURL = ${wattvisionURL}"
|
||||||
|
return "fail"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,9 +174,14 @@ def wattvisionURL(senorId, startDate, endDate) {
|
|||||||
if (diff > 259200000) { // 3 days in milliseconds
|
if (diff > 259200000) { // 3 days in milliseconds
|
||||||
// Wattvision only allows pulling 3 hours of data at a time
|
// Wattvision only allows pulling 3 hours of data at a time
|
||||||
startDate = new Date(hours: endDate.hours - 3)
|
startDate = new Date(hours: endDate.hours - 3)
|
||||||
|
} else if (diff < 10000) { // 10 seconds in milliseconds
|
||||||
|
// Wattvision throws errors when the difference between start_time and end_time is 5 seconds or less
|
||||||
|
// So we are going to make sure that we have a few more seconds of breathing room
|
||||||
|
use (groovy.time.TimeCategory) {
|
||||||
|
startDate = endDate - 10.seconds
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def params = [
|
def params = [
|
||||||
"sensor_id" : senorId,
|
"sensor_id" : senorId,
|
||||||
"api_id" : wattvisionApiAccess.id,
|
"api_id" : wattvisionApiAccess.id,
|
||||||
@@ -480,4 +495,3 @@ def connectionSuccessful(deviceName, iconSrc) {
|
|||||||
|
|
||||||
render contentType: 'text/html', data: html
|
render contentType: 'text/html', data: html
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user