mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-14 21:03:19 +00:00
Compare commits
1 Commits
MSA-1660-1
...
MSA-1588-1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbae724d9a |
@@ -1,486 +0,0 @@
|
||||
/**
|
||||
* Qubino Weatherstation
|
||||
* Device Handler
|
||||
* Version 1.0
|
||||
* Date: 16.12.2016
|
||||
* Author: Kristjan Jamšek (Kjamsek), Goap d.o.o.
|
||||
* Copyright 2016 Kristjan Jamšek
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* - DEVICE HANDLER FOR QUBINO WEATHERSTATION Z-WAVE DEVICE -
|
||||
* The handler supports all unsecure functions of the Qubino Weatherstation device. Configuration parameters and
|
||||
* association groups can be set in the device's preferences screen, but they are applied on the device only after
|
||||
* pressing the 'Set configuration' and 'Set associations' buttons on the bottom of the details view.
|
||||
*
|
||||
* This device handler supports data values that are currently not implemented as capabilities, so custom attribute
|
||||
* states are used. Please use a SmartApp that supports custom attribute monitoring with this device in your rules.
|
||||
* By default the 'Temperature Measurement' and 'Relative Humidity Measurement' capability states are mirrored from
|
||||
* the custom attribute state values 'temperatureCh1' and 'humidityCh1'.
|
||||
*
|
||||
* This device handler uses hubAction in configure() method in order to set a MultiChannel Lifeline association to the
|
||||
* device, so reports from all endpoints can be received.
|
||||
*
|
||||
*
|
||||
* CHANGELOG:
|
||||
* 0.99: Final release code cleanup and commenting
|
||||
* 1.00: Added comments to code for readability
|
||||
*/
|
||||
metadata {
|
||||
definition (name: "Qubino Weatherstation", namespace: "Goap", author: "Kristjan Jamšek") {
|
||||
capability "Configuration" //Needed for configure() function to set MultiChannel Lifeline Association Set
|
||||
capability "Temperature Measurement" //Used on main tile, needed in order to have the device appear in capabilities lists, mirrors temperatureCh1 attribute states
|
||||
capability "Relative Humidity Measurement" //Needed in order to have the device appear in capabilities lists, mirrors humidityCh1 attribute states
|
||||
capability "Sensor" // - Tagging capability
|
||||
|
||||
attribute "temperatureCh1", "number" // temperature attribute for Ch1 Temperature reported by device's endpoint 1
|
||||
attribute "windDirection", "number" // wind direction attribute for Wind Gauge - Direction reported by device's endpoint 2
|
||||
attribute "windVelocity", "number" // wind velocity attribute for Wind Gauge - Velocity reported by device's endpoint 3
|
||||
attribute "windGust", "number" // wind gust velocity attribute for Wind Gauge - Wind gust reported by device's endpoint 4
|
||||
attribute "windTemperature", "number" // wind temperature attribute for Wind Gauge - Temperature reported by device's endpoint 5
|
||||
attribute "windChillTemperature", "number" // wind chill temperature attribute for Wind Gauge - Wind Chill reported by device's endpoint 6
|
||||
attribute "rainRate", "number" // rain rate attribute for Rain Sensor data reported by device's endpoint 7
|
||||
attribute "humidityCh1", "number" // humidity attribute for Ch1 Humidity reported by device's endpoint 8
|
||||
attribute "temperatureCh2", "number" // temperature attribute for Ch2 Temperature reported by device's endpoint 9
|
||||
attribute "humidityCh2", "number" // humidity attribute for Ch2 Humidity reported by device's endpoint 10
|
||||
|
||||
attribute "setConfigParams", "string" // attribute for tile element for setConfigurationParams command
|
||||
attribute "setAssocGroups", "string" // attribute for tile element for setAssociations command
|
||||
|
||||
command "setConfigurationParams" // command to issue Configuration Set command sequence according to user's preferences
|
||||
command "setAssociations" // command to issue Association Set command sequence according to user's preferences
|
||||
|
||||
fingerprint mfr:"0159", prod:"0007", model:"0053" //Manufacturer Information values for Qubino Weatherstation
|
||||
}
|
||||
|
||||
|
||||
simulator {
|
||||
// TESTED WITH PHYSICAL DEVICE - UNNEEDED
|
||||
}
|
||||
|
||||
tiles(scale: 2) {
|
||||
valueTile("temperature", "device.temperature") {
|
||||
state("temperature", label:'${currentValue} °', unit:"°", icon: "st.Weather.weather2", backgroundColors: [
|
||||
// Celsius Color Range
|
||||
[value: 0, color: "#153591"],
|
||||
[value: 7, color: "#1e9cbb"],
|
||||
[value: 15, color: "#90d2a7"],
|
||||
[value: 23, color: "#44b621"],
|
||||
[value: 29, color: "#f1d801"],
|
||||
[value: 33, color: "#d04e00"],
|
||||
[value: 36, color: "#bc2323"],
|
||||
// Fahrenheit Color Range
|
||||
[value: 40, color: "#153591"],
|
||||
[value: 44, color: "#1e9cbb"],
|
||||
[value: 59, color: "#90d2a7"],
|
||||
[value: 74, color: "#44b621"],
|
||||
[value: 84, color: "#f1d801"],
|
||||
[value: 92, color: "#d04e00"],
|
||||
[value: 96, color: "#bc2323"]
|
||||
])
|
||||
}
|
||||
valueTile("humidity", "device.humidity") {
|
||||
state("humidity", label:'${currentValue} %', unit:"%", display:false)
|
||||
}
|
||||
standardTile("temperatureCh1", "device.temperatureCh1", width: 3, height: 3) {
|
||||
state("temperatureCh1", label:'Temperature Ch1: ${currentValue} °', unit:'°', icon: 'st.Weather.weather2')
|
||||
}
|
||||
standardTile("windDirection", "device.windDirection", width: 3, height: 3) {
|
||||
state("windDirection", label:'Wind Direction: ${currentValue} °', unit: "°", icon: 'st.Outdoor.outdoor20')
|
||||
}
|
||||
standardTile("windVelocity", "device.windVelocity", width: 3, height: 3) {
|
||||
state("windVelocity", label:'Wind Velocity: ${currentValue} m/s', unit:"m/s", icon: 'st.Weather.weather1')
|
||||
}
|
||||
standardTile("windGust", "device.windGust", width: 3, height: 3) {
|
||||
state("windGust", label:'Wind Gust: ${currentValue} m/s', unit:"m/s", icon: 'st.Weather.weather1')
|
||||
}
|
||||
standardTile("windTemperature", "device.windTemperature", width: 3, height: 3) {
|
||||
state("windTemperature", label:'Wind Temperature: ${currentValue} °', unit:'°', icon: 'st.Weather.weather2')
|
||||
}
|
||||
standardTile("windChillTemperature", "device.windChillTemperature", width: 3, height: 3) {
|
||||
state("windChillTemperature", label:'Wind Chill: ${currentValue} °', unit:'°', icon: 'st.Weather.weather2')
|
||||
}
|
||||
standardTile("rainRate", "device.rainRate", width: 3, height: 3) {
|
||||
state("rainRate", label:'Rain Sensor: ${currentValue} mm/h', unit:"mm/h", icon: 'st.Weather.weather10')
|
||||
}
|
||||
standardTile("humidityCh1", "device.humidityCh1", width: 3, height: 3) {
|
||||
state("humidityCh1", label:'Humidity Ch1: ${currentValue} %', unit:"%", icon: 'st.Weather.weather12')
|
||||
}
|
||||
standardTile("temperatureCh2", "device.temperatureCh2", width: 3, height: 3) {
|
||||
state("temperatureCh2", label:'Temperature Ch2: ${currentValue} °', unit:'°', icon: 'st.Weather.weather2')
|
||||
}
|
||||
standardTile("humidityCh2", "device.humidityCh2", width: 3, height: 3) {
|
||||
state("humidityCh2", label:'Humidity Ch2: ${currentValue} %', unit:"%", icon: 'st.Weather.weather12')
|
||||
}
|
||||
standardTile("setConfigParams", "device.setConfigParams", decoration: "flat", width: 3, height: 3) {
|
||||
state("setConfigParams", label:'Set configuration', action:'setConfigurationParams', icon: "st.secondary.tools")
|
||||
}
|
||||
standardTile("setAssocGroups", "device.setAssocGroups", decoration: "flat", width: 3, height: 3) {
|
||||
state("setAssocGroups", label:'Set associations', action:'setAssociations', icon: "st.secondary.tools")
|
||||
}
|
||||
|
||||
main("temperature")
|
||||
details(["temperatureCh1", "humidityCh1", "windDirection", "windVelocity", "windGust", "windTemperature", "windChillTemperature", "rainRate", "temperatureCh2", "humidityCh2", "setConfigParams", "setAssocGroups"])
|
||||
|
||||
}
|
||||
preferences {
|
||||
/**
|
||||
* -------- CONFIGURATION PARAMETER SECTION --------
|
||||
*/
|
||||
input name: "param1", type: "number", range: "0..8800", required: false,
|
||||
title: "1. Wind Gauge, Wind Gust Top Value. " +
|
||||
"If the Wind Gust is higher than the parameter value, the device triggers an association.\n" +
|
||||
"Available settings:\n" +
|
||||
"0 ... 8800 = value from 0,00 m/s to 88,00 m/s,\n" +
|
||||
"Default value: 1000 (10,00 m/s)."
|
||||
input name: "param2", type: "number", range: "0..30000", required: false,
|
||||
title: "2. Rain Gauge, Rain Rate Top Value. " +
|
||||
"If the Rain Sensor Rain Rate is higher than the parameter value, the device triggers an association.\n" +
|
||||
"Available settings:\n" +
|
||||
"0 ... 30000 = value from 0,00 mm/h to 300,00 mm/h,\n" +
|
||||
"Default value: 200 (2,00 mm/h)."
|
||||
input name: "param3", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "3. Wind Gauge, Wind Gust. " +
|
||||
"Available settings:\n" +
|
||||
"0 = If the Wind Gust is higher than the parameter number 1 value, then the device sends a Basic Set 0x00,\n" +
|
||||
"1 = If the Wind Gust is higher than the parameter number 1 value, then the device sends a Basic Set 0xFF,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param4", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "4. Rain Gauge, Rain Rate. " +
|
||||
"Available settings:\n" +
|
||||
"0 = If the Rain Rate is higher than the parameter number 2 value, then the device sends a Basic Set 0x00,\n" +
|
||||
"1 = If the Rain Rate is higher than the parameter number 2 value, then the device sends a Basic Set 0xFF,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param5", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "5. Endpoint 1 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param6", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "6. Endpoint 2 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param7", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "7. Endpoint 3 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param8", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "8. Endpoint 4 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param9", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "9. Endpoint 5 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param10", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "10. Endpoint 6 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param11", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "11. Endpoint 7 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param12", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "12. Endpoint 8 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param13", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "13. Endpoint 9 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param14", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "14. Endpoint 10 - Unsolicited Report enable/disable. " +
|
||||
"Available settings:\n" +
|
||||
"0 = Unsolicited Report disabled,\n" +
|
||||
"1 = Unsolicited Report enabled,\n" +
|
||||
"Default value: 1."
|
||||
input name: "param15", type: "enum", required: false,
|
||||
options: ["0" : "0",
|
||||
"1" : "1"],
|
||||
title: "15. Random ID enable/disable " +
|
||||
"Available settings:\n" +
|
||||
"0 = Random ID disabled,\n" +
|
||||
"1 = Random ID enabled,\n" +
|
||||
"Default value: 0."
|
||||
/**
|
||||
* -------- ASSOCIATION GROUP SECTION --------
|
||||
*/
|
||||
input name: "assocGroup2", type: "text", required: false,
|
||||
title: "Association group 2: \n" +
|
||||
"Basic On/Off command will be sent to associated nodes when the Wind Gust of the Wind Gauge exceeds the Configuration parameter 1 value. \n" +
|
||||
"NOTE: Insert the node Id value of the devices you wish to associate this group with. Multiple nodeIds can also be set at once by separating individual values by a comma (2,3,...)."
|
||||
|
||||
input name: "assocGroup3", type: "text", required: false,
|
||||
title: "Association group 3: \n" +
|
||||
"Basic On/Off command will be sent to associated nodes when the Rain Rate exceeds the Configuration parameter 2 value. \n" +
|
||||
"NOTE: Insert the node Id value of the devices you wish to associate this group with. Multiple nodeIds can also be set at once by separating individual values by a comma (2,3,...)."
|
||||
}
|
||||
}
|
||||
/**
|
||||
* -------- HELPER METHODS SECTION --------
|
||||
*/
|
||||
/**
|
||||
* Converts a list of String type node id values to Integer type.
|
||||
*
|
||||
* @param stringList - a list of String type node id values.
|
||||
* @return stringList - a list of Integer type node id values.
|
||||
*/
|
||||
def convertStringListToIntegerList(stringList){
|
||||
for(int i=0;i<stringList.size();i++){
|
||||
stringList[i] = stringList[i].toInteger()
|
||||
}
|
||||
return stringList
|
||||
}
|
||||
/**
|
||||
* Converts temperature values to fahrenheit or celsius scales accordign to user's setting.
|
||||
*
|
||||
* @param scaleParam user set scale parameter.
|
||||
* @param encapCmd received temperature parsed value.
|
||||
* @return String type value of the converted temperature value.
|
||||
*/
|
||||
def convertDegrees(scaleParam, encapCmd){
|
||||
switch (scaleParam) {
|
||||
default:
|
||||
break;
|
||||
case "F":
|
||||
if(encapCmd.scale == 1){
|
||||
return encapCmd.scaledSensorValue.toString()
|
||||
}else{
|
||||
return (encapCmd.scaledSensorValue * 9 / 5 + 32).toString()
|
||||
}
|
||||
break;
|
||||
case "C":
|
||||
if(encapCmd.scale == 0){
|
||||
return encapCmd.scaledSensorValue.toString()
|
||||
}else{
|
||||
return (encapCmd.scaledSensorValue * 9 / 5 + 32).toString()
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* -------- HANDLE COMMANDS SECTION --------
|
||||
*/
|
||||
/**
|
||||
* Configuration capability command handler that executes after module inclusion to remove existing singlechannel association Lifeline and replace it
|
||||
* with a multichannel Lifeline association setting for node id 1 and endpoint 1, which enables modules to report multichannel encapsulated frames.
|
||||
*
|
||||
* @param void
|
||||
* @return List of commands that will be executed in sequence with 500 ms delay inbetween.
|
||||
*/
|
||||
def configure() {
|
||||
log.debug "Qubino Weatherstation: configure()"
|
||||
/** In this method we first clear the association group 1 that is set by SmartThings automatically.
|
||||
* Afterwards we use physicalgraph.device.HubAction("8E0101000101") as a workaround for SmartThings' MultiChannel Association Command Class implementation,
|
||||
* where we cannot set a node id and endpoint id. The hardcoded parameter "8E0101000101" should be interpreted in sequence as hexadecimal byte values:
|
||||
* 8E010100 - Command class and command values, along with the field for singlechannel node id omitted
|
||||
* 0101 - These two byte values represent the multichannel node id 01 followed by the endpoint id 01 (in general this value can be left as is unless
|
||||
* multiple subordinated controllers are included in your network. In that case please adjust these two value to the correct id.
|
||||
*/
|
||||
def assocCmds = []
|
||||
assocCmds << zwave.associationV1.associationRemove(groupingIdentifier:1, nodeId:zwaveHubNodeId).format()
|
||||
assocCmds << new physicalgraph.device.HubAction("8E0101000101")
|
||||
return delayBetween(assocCmds, 500)
|
||||
}
|
||||
/**
|
||||
* setAssociations command handler that sets user selected association groups. In case no node id is insetred the group is instead cleared.
|
||||
* Lifeline association hidden from user influence by design.
|
||||
*
|
||||
* @param void
|
||||
* @return List of Association commands that will be executed in sequence with 500 ms delay inbetween.
|
||||
*/
|
||||
def setAssociations() {
|
||||
log.debug "Qubino Weatherstation: setAssociations()"
|
||||
def assocSet = []
|
||||
if(settings.assocGroup2 != null){
|
||||
def group2parsed = settings.assocGroup2.tokenize(",")
|
||||
group2parsed = convertStringListToIntegerList(group2parsed)
|
||||
assocSet << zwave.associationV1.associationSet(groupingIdentifier:2, nodeId:group2parsed).format()
|
||||
}else{
|
||||
assocSet << zwave.associationV1.associationRemove(groupingIdentifier:2, nodeId: 0).format()
|
||||
}
|
||||
if(settings.assocGroup3 != null){
|
||||
def group3parsed = settings.assocGroup3.tokenize(",")
|
||||
group3parsed = convertStringListToIntegerList(group3parsed)
|
||||
assocSet << zwave.associationV1.associationSet(groupingIdentifier:3, nodeId:group3parsed).format()
|
||||
}else{
|
||||
assocSet << zwave.associationV1.associationRemove(groupingIdentifier:3, nodeId: 0).format()
|
||||
}
|
||||
return delayBetween(assocSet, 500)
|
||||
|
||||
}
|
||||
/**
|
||||
* setConfigurationParams command handler that sets user selected configuration parameters on the device.
|
||||
* In case no value is set for a specific parameter the method skips setting that parameter.
|
||||
* Secure mdoe setting hidden from user influence by design.
|
||||
*
|
||||
* @param void
|
||||
* @return List of Configuration Set commands that will be executed in sequence with 500 ms delay inbetween.
|
||||
*/
|
||||
def setConfigurationParams() {
|
||||
log.debug "Qubino Weatherstation: setConfigurationParams()"
|
||||
def configSequence = []
|
||||
if(settings.param1 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 1, size: 2, scaledConfigurationValue: settings.param1.toInteger()).format()
|
||||
}
|
||||
if(settings.param2 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 2, size: 2, scaledConfigurationValue: settings.param2.toInteger()).format()
|
||||
}
|
||||
if(settings.param3 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 3, size: 1, scaledConfigurationValue: settings.param3.toInteger()).format()
|
||||
}
|
||||
if(settings.param4 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 4, size: 1, scaledConfigurationValue: settings.param4.toInteger()).format()
|
||||
}
|
||||
if(settings.param5 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 5, size: 1, scaledConfigurationValue: settings.param5.toInteger()).format()
|
||||
}
|
||||
if(settings.param6 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 6, size: 1, scaledConfigurationValue: settings.param6.toInteger()).format()
|
||||
}
|
||||
if(settings.param7 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 7, size: 1, scaledConfigurationValue: settings.param7.toInteger()).format()
|
||||
}
|
||||
if(settings.param8 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 8, size: 1, scaledConfigurationValue: settings.param8.toInteger()).format()
|
||||
}
|
||||
if(settings.param9 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 9, size: 1, scaledConfigurationValue: settings.param9.toInteger()).format()
|
||||
}
|
||||
if(settings.param10 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 10, size: 1, scaledConfigurationValue: settings.param10.toInteger()).format()
|
||||
}
|
||||
if(settings.param11 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 11, size: 1, scaledConfigurationValue: settings.param11.toInteger()).format()
|
||||
}
|
||||
if(settings.param12 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 12, size: 1, scaledConfigurationValue: settings.param12.toInteger()).format()
|
||||
}
|
||||
if(settings.param13 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 13, size: 1, scaledConfigurationValue: settings.param13.toInteger()).format()
|
||||
}
|
||||
if(settings.param14 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 14, size: 1, scaledConfigurationValue: settings.param14.toInteger()).format()
|
||||
}
|
||||
if(settings.param15 != null){
|
||||
configSequence << zwave.configurationV1.configurationSet(parameterNumber: 15, size: 1, scaledConfigurationValue: settings.param15.toInteger()).format()
|
||||
}
|
||||
return delayBetween(configSequence, 500)
|
||||
}
|
||||
/*
|
||||
* -------- EVENT PARSER SECTION --------
|
||||
*/
|
||||
/**
|
||||
* parse function takes care of parsing received bytes and passing them on to event methods.
|
||||
*
|
||||
* @param description String type value of the received bytes.
|
||||
* @return Parsed result of the received bytes.
|
||||
*/
|
||||
def parse(String description) {
|
||||
log.debug "Qubino Weatherstation: Parsing '${description}'"
|
||||
def result = null
|
||||
def cmd = zwave.parse(description)
|
||||
if (cmd) {
|
||||
result = zwaveEvent(cmd)
|
||||
log.debug "Parsed ${cmd} to ${result.inspect()}"
|
||||
} else {
|
||||
log.debug "Non-parsed event: ${description}"
|
||||
}
|
||||
return result
|
||||
}
|
||||
/**
|
||||
* Event method for MultiChannelCmdEncap encapsulation frames.
|
||||
*
|
||||
* @param cmd Type physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap received command.
|
||||
* @return List of events that will update UI elements for data display.
|
||||
*/
|
||||
def zwaveEvent(physicalgraph.zwave.commands.multichannelv3.MultiChannelCmdEncap cmd) {
|
||||
def encapsulatedCommand = cmd.encapsulatedCommand([0x30: 1, 0x31: 1])
|
||||
def tempScale = location.temperatureScale
|
||||
def resultEvents = []
|
||||
switch (cmd.sourceEndPoint) {
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
resultEvents << createEvent(name:"temperatureCh1", value: convertDegrees(tempScale,encapsulatedCommand), unit:"°"+location.temperatureScale, descriptionText: "Temperature Ch1: "+convertDegrees(tempScale,encapsulatedCommand)+"°"+location.temperatureScale)
|
||||
resultEvents << createEvent(name:"temperature", value: convertDegrees(tempScale,encapsulatedCommand), unit:"°"+location.temperatureScale, descriptionText: "Temperature Ch1: "+convertDegrees(tempScale,encapsulatedCommand)+"°"+location.temperatureScale, displayed: false)
|
||||
break;
|
||||
case 2:
|
||||
resultEvents << createEvent(name:"windDirection", value: encapsulatedCommand.scaledSensorValue.toString(), unit:"°", descriptionText: "Wind Direction: "+encapsulatedCommand.scaledSensorValue.toString()+" °")
|
||||
break;
|
||||
case 3:
|
||||
resultEvents << createEvent(name:"windVelocity", value: encapsulatedCommand.scaledSensorValue.toString(), unit:"m/s", descriptionText: "Wind Velocity: "+encapsulatedCommand.scaledSensorValue.toString()+" m/s")
|
||||
break;
|
||||
case 4:
|
||||
resultEvents << createEvent(name:"windGust", value: encapsulatedCommand.scaledSensorValue.toString(), unit:"m/s", descriptionText: "Wind Gust: "+encapsulatedCommand.scaledSensorValue.toString()+" m/s")
|
||||
break;
|
||||
case 5:
|
||||
resultEvents << createEvent(name:"windTemperature", value: convertDegrees(tempScale,encapsulatedCommand), unit:"°"+location.temperatureScale, descriptionText: "Wind Temperature: "+convertDegrees(tempScale,encapsulatedCommand)+" °"+location.temperatureScale)
|
||||
break;
|
||||
case 6:
|
||||
resultEvents << createEvent(name:"windChillTemperature", value: convertDegrees(tempScale,encapsulatedCommand), unit:"°"+location.temperatureScale, descriptionText: "Wind Chill: "+convertDegrees(tempScale,encapsulatedCommand)+" °"+location.temperatureScale)
|
||||
break;
|
||||
case 7:
|
||||
resultEvents << createEvent(name:"rainRate", value: encapsulatedCommand.scaledSensorValue.toString(), unit:"mm/h", descriptionText: "Rain Sensor: "+encapsulatedCommand.scaledSensorValue.toString()+" mm/h")
|
||||
break;
|
||||
case 8:
|
||||
resultEvents << createEvent(name:"humidity", value: encapsulatedCommand.scaledSensorValue.toString(), unit:"%", descriptionText: "Humidity Ch1: "+encapsulatedCommand.scaledSensorValue.toString()+" %", displayed: false)
|
||||
resultEvents << createEvent(name:"humidityCh1", value: encapsulatedCommand.scaledSensorValue.toString(), unit:"%", descriptionText: "Humidity Ch1: "+encapsulatedCommand.scaledSensorValue.toString()+" %")
|
||||
break;
|
||||
case 9:
|
||||
resultEvents << createEvent(name:"temperatureCh2", value: convertDegrees(tempScale,encapsulatedCommand), unit:"°"+location.temperatureScale, descriptionText: "Temperature Ch2: "+convertDegrees(tempScale,encapsulatedCommand)+" °"+location.temperatureScale)
|
||||
break;
|
||||
case 10:
|
||||
resultEvents << createEvent(name:"humidityCh2", value: encapsulatedCommand.scaledSensorValue.toString(), unit:"%", descriptionText: "Humidity Ch2: "+encapsulatedCommand.scaledSensorValue.toString()+" %")
|
||||
break;
|
||||
}
|
||||
return resultEvents
|
||||
}
|
||||
@@ -0,0 +1,360 @@
|
||||
/**
|
||||
* LANnouncer Alerter (Formerly LANdroid - but Google didn't like that much.)
|
||||
*
|
||||
* Requires the LANnouncer android app; https://play.google.com/store/apps/details?id=com.keybounce.lannouncer
|
||||
* See http://www.keybounce.com/LANdroidHowTo/LANdroid.html for full downloads and instructions.
|
||||
* SmartThings thread: https://community.smartthings.com/t/android-as-a-speech-alarm-device-released/30282/12
|
||||
*
|
||||
* Note: Only Siren and Strobe from the U.I. or Alarm capabilities default to continuous.
|
||||
*
|
||||
* Version 1.25 22 July 2016
|
||||
*
|
||||
*
|
||||
* Copyright 2015-2016 Tony McNamara
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License. You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
|
||||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing permissions and limitations under the License.
|
||||
*
|
||||
* To Do: Add string return to Image Capture attribute
|
||||
*
|
||||
*/
|
||||
|
||||
metadata {
|
||||
definition (name: "LANnouncer Alerter", namespace: "KeyBounce", author: "Tony McNamara") {
|
||||
capability "Alarm"
|
||||
capability "Speech Synthesis"
|
||||
capability "Notification"
|
||||
capability "Tone"
|
||||
capability "Image Capture"
|
||||
attribute "LANdroidSMS","string"
|
||||
/* Per http://docs.smartthings.com/en/latest/device-type-developers-guide/overview.html#actuator-and-sensor */
|
||||
capability "Sensor"
|
||||
capability "Actuator"
|
||||
|
||||
// Custom Commands
|
||||
/** Retrieve image, formatted for SmartThings, from camera by name. */
|
||||
command "chime"
|
||||
command "doorbell"
|
||||
command "ipCamSequence", ["number"]
|
||||
command "retrieveAndWait", ["string"]
|
||||
command "retrieveFirstAndWait"
|
||||
command "retrieveSecondAndWait"
|
||||
}
|
||||
preferences {
|
||||
input("DeviceLocalLan", "string", title:"Android IP Address", description:"Please enter your tablet's I.P. address", defaultValue:"" , required: false, displayDuringSetup: true)
|
||||
input("DevicePort", "string", title:"Android Port", description:"Port the Android device listens on", defaultValue:"1035", required: false, displayDuringSetup: true)
|
||||
input("ReplyOnEmpty", "bool", title:"Say Nothing", description:"When no speech is found, announce LANdroid? (Needed for the speech and notify tiles to work)", defaultValue: true, displayDuringSetup: true)
|
||||
input("AlarmContinuous", "bool", title:"Continuous Alarm (vs 10 sec.)", description: "When on, the alarm will sound until Stop is issued.", defaultValue: false, displayDuringSetup: true)
|
||||
}
|
||||
|
||||
simulator {
|
||||
// reply messages
|
||||
["strobe","siren","both","off"].each
|
||||
{
|
||||
reply "$it": "alarm:$it"
|
||||
}
|
||||
}
|
||||
|
||||
tiles {
|
||||
standardTile("alarm", "device.alarm", width: 2, height: 2) {
|
||||
state "off", label:'off', action:'alarm.both', icon:"st.alarm.alarm.alarm", backgroundColor:"#ffffff"
|
||||
state "strobe", label:'strobe!', action:'alarm.off', icon:"st.Lighting.light11", backgroundColor:"#e86d13"
|
||||
state "siren", label:'siren!', action:'alarm.off', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
|
||||
state "both", label:'alarm!', action:'alarm.off', icon:"st.alarm.alarm.alarm", backgroundColor:"#e86d13"
|
||||
}
|
||||
standardTile("strobe", "device.alarm", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:'', action:"alarm.strobe", icon:"st.secondary.strobe"
|
||||
}
|
||||
|
||||
standardTile("siren", "device.alarm", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:'', action:"alarm.siren", icon:"st.secondary.siren"
|
||||
}
|
||||
standardTile("off", "device.alarm", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:'Off', action:"alarm.off", icon:"st.quirky.spotter.quirky-spotter-sound-off"
|
||||
}
|
||||
|
||||
/* Apparently can't show image attributes on tiles. */
|
||||
standardTile("take", "device.image", width: 1, height: 1, canChangeIcon: false, canChangeBackground: false)
|
||||
{
|
||||
state "take", label: "Take", action: "Image Capture.take", icon: "st.camera.camera", backgroundColor: "#FFFFFF", nextState:"taking"
|
||||
state "taking", label:'Taking', action: "", icon: "st.camera.take-photo", backgroundColor: "#53a7c0"
|
||||
state "image", label: "Take", action: "Image Capture.take", icon: "st.camera.camera", backgroundColor: "#FFFFFF", nextState:"taking"
|
||||
}
|
||||
|
||||
|
||||
standardTile("speak", "device.speech", inactiveLabel: false, decoration: "flat")
|
||||
{
|
||||
state "default", label:'Speak', action:"Speech Synthesis.speak", icon:"st.Electronics.electronics13"
|
||||
}
|
||||
standardTile("toast", "device.notification", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:'Notify', action:"notification.deviceNotification", icon:"st.Kids.kids1"
|
||||
}
|
||||
standardTile("beep", "device.tone", inactiveLabel: false, decoration: "flat") {
|
||||
state "default", label:'Tone', action:"tone.beep", icon:"st.Entertainment.entertainment2"
|
||||
}
|
||||
carouselTile("cameraDetails", "device.image", width: 3, height: 2) { }
|
||||
|
||||
main (["alarm", "take"]);
|
||||
details(["alarm","strobe","siren","off","speak", "take","toast","beep", "cameraDetails"]);
|
||||
}
|
||||
}
|
||||
|
||||
/** Generally matches TTSServer/app/build.gradle */
|
||||
String getVersion() {return "24 built July 2016";}
|
||||
|
||||
|
||||
/** Alarm Capability, Off.
|
||||
* Turns off both the strobe and the alarm.
|
||||
* Necessary when in continuous mode.
|
||||
*/
|
||||
def off() {
|
||||
log.debug "Executing 'off'"
|
||||
sendEvent(name:"alarm", value:"off")
|
||||
def command="&ALARM=STOP&FLASH=STOP&"+getDoneString();
|
||||
return sendCommands(command)
|
||||
}
|
||||
|
||||
/** Alarm Capability: Strobe
|
||||
* Flashes the camera light, if any.
|
||||
*/
|
||||
def strobe() {
|
||||
log.debug "Executing 'strobe'"
|
||||
// For illustration, switch to siren and sendEvent after.
|
||||
def command= (AlarmContinuous?"&FLASH=CONTINUOUS&":"&FLASH=STROBE&")+getDoneString();
|
||||
// def command=(AlarmContinuous?"&ALARM=SIREN:CONTINUOUS&":"&ALARM=SIREN&")+getDoneString();
|
||||
def hubAction = sendCommands(command)
|
||||
sendEvent(name:"alarm", value:"strobe")
|
||||
return hubAction;
|
||||
}
|
||||
|
||||
/** Alarm Capability: Siren
|
||||
* Sounds the siren, either continuous or for a brief period, depending on setting.
|
||||
* If continuous, Stop should be called later.
|
||||
*/
|
||||
def siren() {
|
||||
log.debug "Executing 'siren'"
|
||||
sendEvent(name:"alarm", value:"siren")
|
||||
def command=(AlarmContinuous?"&ALARM=SIREN:CONTINUOUS&":"&ALARM=SIREN&")+getDoneString();
|
||||
return sendCommands(command);
|
||||
}
|
||||
|
||||
/** Tone Capability: Beep
|
||||
* Sounds a short beep
|
||||
*/
|
||||
def beep() {
|
||||
log.debug "Executing 'beep'"
|
||||
def command="&ALARM=CHIME&"+getDoneString()
|
||||
return sendCommands(command);
|
||||
}
|
||||
|
||||
def both() {
|
||||
log.debug "Executing 'both'"
|
||||
sendEvent(name:"alarm", value:"both")
|
||||
def command="&ALARM=ON&FLASH=ON&"+getDoneString()
|
||||
if (AlarmContinuous)
|
||||
{
|
||||
command="&ALARM=SIREN:CONTINUOUS&FLASH=CONTINUOUS&"+getDoneString()
|
||||
}
|
||||
return sendCommands(command);
|
||||
}
|
||||
|
||||
/** speechSynthesis Capability: Speak
|
||||
*/
|
||||
def speak(toSay) {
|
||||
log.debug "Executing 'speak'"
|
||||
if (!toSay?.trim()) {
|
||||
if (ReplyOnEmpty) {
|
||||
toSay = "LANnouncer Version ${version}"
|
||||
}
|
||||
}
|
||||
|
||||
if (toSay?.trim()) {
|
||||
def command="&SPEAK="+toSay+"&"+getDoneString()
|
||||
return sendCommands(command)
|
||||
}
|
||||
}
|
||||
|
||||
/** Notification capability: deviceNotification
|
||||
*/
|
||||
def deviceNotification(toToast) {
|
||||
log.debug "Executing notification with "+toToast
|
||||
if (!toToast?.trim()) {
|
||||
if (ReplyOnEmpty) {
|
||||
toToast = "LANnouncer Version ${version}";
|
||||
}
|
||||
}
|
||||
if (toToast?.trim()) {
|
||||
def command="&TOAST="+toToast+"&"+getDoneString()
|
||||
return sendCommands(command)
|
||||
}
|
||||
}
|
||||
|
||||
def chime() {
|
||||
log.debug "Executing 'chime'"
|
||||
// TODO: handle 'siren' command
|
||||
def command="&ALARM=CHIME&"+getDoneString()
|
||||
return sendCommands(command)
|
||||
}
|
||||
|
||||
def doorbell() {
|
||||
log.debug "Executing 'doorbell'"
|
||||
// TODO: handle 'siren' command
|
||||
def command="&ALARM=DOORBELL&"+getDoneString()
|
||||
return sendCommands(command)
|
||||
}
|
||||
|
||||
def ipCamSequence(cameraNumber) {
|
||||
def camera = (cameraNumber==1?"FIRST":"SECOND");
|
||||
def command="&RETRIEVESEQ="+cameraNumber+"&"+getDoneString()
|
||||
return sendIPCommand(command, true)
|
||||
}
|
||||
|
||||
|
||||
def retrieveFirstAndWait() {
|
||||
retrieveAndWait("FIRST");
|
||||
}
|
||||
def retrieveSecondAndWait() {
|
||||
retrieveAndWait("SECOND");
|
||||
}
|
||||
def retrieveAndWait(cameraName) {
|
||||
log.info("Requesting image from camera ${cameraName}");
|
||||
def command="&RETRIEVE="+cameraName+"&STSHRINK=TRUE&"+getDoneString()
|
||||
return sendIPCommand(command, true)
|
||||
}
|
||||
|
||||
|
||||
def take() {
|
||||
// This won't result in received file. Can't handle large or binaries in hub.
|
||||
log.debug "Executing 'take'"
|
||||
def command="&PHOTO=BACK&STSHRINK=TRUE&"+getDoneString()
|
||||
return sendIPCommand(command, true)
|
||||
}
|
||||
|
||||
/** Send to IP and to SMS as appropriate
|
||||
* The caller MUST return the value, which is the hubAction.
|
||||
* As of version 1.25, does not "send" the command so much as
|
||||
* request that the calling service send it.
|
||||
*/
|
||||
private sendCommands(command) {
|
||||
log.info "Command request: "+command
|
||||
sendSMSCommand(command)
|
||||
return sendIPCommand(command)
|
||||
}
|
||||
|
||||
/** Prepares the hubAction to be executed.
|
||||
* Pre-V25, this was executed in-line.
|
||||
* Now it is returned, not executed, and must be returned up the calling chain.
|
||||
*/
|
||||
private sendIPCommand(commandString, sendToS3 = false) {
|
||||
log.info "Sending command "+ commandString+" to "+DeviceLocalLan+":"+DevicePort
|
||||
if (DeviceLocalLan?.trim()) {
|
||||
def hosthex = convertIPtoHex(DeviceLocalLan)
|
||||
def porthex = convertPortToHex(DevicePort)
|
||||
device.deviceNetworkId = "$hosthex:$porthex"
|
||||
|
||||
def headers = [:]
|
||||
headers.put("HOST", "$DeviceLocalLan:$DevicePort")
|
||||
|
||||
def method = "GET"
|
||||
|
||||
def hubAction = new physicalgraph.device.HubAction(
|
||||
method: method,
|
||||
path: "/"+commandString,
|
||||
headers: headers
|
||||
);
|
||||
if (sendToS3 == true)
|
||||
{
|
||||
hubAction.options = [outputMsgToS3:true];
|
||||
}
|
||||
log.debug hubAction
|
||||
return hubAction;
|
||||
}
|
||||
}
|
||||
|
||||
private sendSMSCommand(commandString) {
|
||||
def preface = "+@TTSSMS@+"
|
||||
def smsValue = preface+"&"+commandString
|
||||
state.lastsmscommand = smsValue
|
||||
sendEvent(name: "LANdroidSMS", value: smsValue, isStateChange: true)
|
||||
/*
|
||||
if (SMSPhone?.trim()) {
|
||||
sendSmsMessage(SMSPhone, preface+"&"+commandString)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
private String getDoneString() {
|
||||
return "@DONE@"
|
||||
}
|
||||
|
||||
def parse(String description) {
|
||||
log.debug "Parsing '${description}'"
|
||||
def map = parseLanMessage(description);
|
||||
log.debug "As LAN: " + map;
|
||||
if ((map.headers) && (map.headers.'Content-Type' != null) && (map.headers.'Content-Type'.contains("image/jpeg")) )
|
||||
{ // Store the file
|
||||
if(map.body)
|
||||
{
|
||||
storeImage(getPictureName(), map.body);
|
||||
}
|
||||
}
|
||||
/* 'index:0F, mac:0073E023A13A, ip:C0A80114, port:040B, requestId:f9036fb2-9637-40b8-b2c5-71ba5a09fd3e, bucket:smartthings-device-conn-temp, key:fc8e3dfd-5035-40a2-8adc-a312926f9034' */
|
||||
|
||||
else if (map.bucket && map.key)
|
||||
{ // S3 pointer; retrieve image from it to store.
|
||||
try {
|
||||
def s3ObjectContent; // Needed for scope of try-catch
|
||||
def imageBytes = getS3Object(map.bucket, map.key + ".jpg")
|
||||
|
||||
if(imageBytes)
|
||||
{
|
||||
log.info ("Got image bytes; saving them.")
|
||||
s3ObjectContent = imageBytes.getObjectContent()
|
||||
def bytes = new ByteArrayInputStream(s3ObjectContent.bytes)
|
||||
storeImage(getPictureName(), bytes)
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
log.error e
|
||||
}
|
||||
finally {
|
||||
//explicitly close the stream
|
||||
if (s3ObjectContent) { s3ObjectContent.close() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Image Capture handling
|
||||
/* Note that images are stored in https://graph.api.smartthings.com/api/s3/smartthings-smartsense-camera/[IMAGE-ID4],
|
||||
* where [IMAGE-ID] is listed in the IDE under My Devices > [Camera] > Current States: Image. That page is updated as pictures are taken.
|
||||
*/
|
||||
|
||||
|
||||
private getPictureName() {
|
||||
def pictureUuid = java.util.UUID.randomUUID().toString().replaceAll('-', '')
|
||||
log.debug pictureUuid
|
||||
def picName = device.deviceNetworkId.replaceAll(':', '') + "_$pictureUuid" + ".jpg"
|
||||
return picName
|
||||
}
|
||||
|
||||
|
||||
private String convertIPtoHex(ipAddress) {
|
||||
String hex = ipAddress.tokenize( '.' ).collect { String.format( '%02X', it.toInteger() ) }.join()
|
||||
log.debug "IP address entered is $ipAddress and the converted hex code is $hex"
|
||||
return hex
|
||||
|
||||
}
|
||||
|
||||
private String convertPortToHex(port) {
|
||||
String hexport = port.toString().format( '%04X', port.toInteger() )
|
||||
log.debug hexport
|
||||
return hexport
|
||||
}
|
||||
@@ -120,15 +120,6 @@ def configure() {
|
||||
return cmd
|
||||
}
|
||||
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
sendEvent(name: "numberOfButtons", value: 4)
|
||||
}
|
||||
|
||||
@@ -109,15 +109,6 @@ def configure() {
|
||||
return cmds
|
||||
}
|
||||
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
sendEvent(name: "numberOfButtons", value: 4)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ metadata {
|
||||
capability "Switch"
|
||||
capability "Refresh"
|
||||
capability "Music Player"
|
||||
capability "Health Check"
|
||||
capability "Polling"
|
||||
|
||||
/**
|
||||
* Define all commands, ie, if you have a custom action not
|
||||
@@ -236,33 +236,7 @@ def parse(String event) {
|
||||
* @return action(s) to take or null
|
||||
*/
|
||||
def installed() {
|
||||
// Notify health check about this device with timeout interval 12 minutes
|
||||
sendEvent(name: "checkInterval", value: 12 * 60, data: [protocol: "lan", hubHardwareId: device.hub.hardwareID], displayed: false)
|
||||
startPoll()
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by health check if no events been generated in the last 12 minutes
|
||||
* If device doesn't respond it will be marked offline (not available)
|
||||
*/
|
||||
def ping() {
|
||||
TRACE("ping")
|
||||
boseSendGetNowPlaying()
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a 2 minute poll of the device to refresh the
|
||||
* tiles so the user gets the correct information.
|
||||
*/
|
||||
def startPoll() {
|
||||
TRACE("startPoll")
|
||||
unschedule()
|
||||
// Schedule 2 minute polling of speaker status (song average length is 3-4 minutes)
|
||||
def sec = Math.round(Math.floor(Math.random() * 60))
|
||||
//def cron = "$sec 0/5 * * * ?" // every 5 min
|
||||
def cron = "$sec 0/2 * * * ?" // every 2 min
|
||||
log.debug "schedule('$cron', boseSendGetNowPlaying)"
|
||||
schedule(cron, boseSendGetNowPlaying)
|
||||
onAction("refresh")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,6 +316,14 @@ def onAction(String user, data=null) {
|
||||
return actions
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every so often (every 5 minutes actually) to refresh the
|
||||
* tiles so the user gets the correct information.
|
||||
*/
|
||||
def poll() {
|
||||
return boseRefreshNowPlaying()
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins this speaker into the everywhere zone
|
||||
*/
|
||||
@@ -855,10 +837,6 @@ def boseRefreshNowPlaying(delay=0) {
|
||||
return boseGET("/now_playing")
|
||||
}
|
||||
|
||||
def boseSendGetNowPlaying() {
|
||||
sendHubCommand(boseGET("/now_playing"))
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the list of presets
|
||||
*
|
||||
@@ -1036,8 +1014,4 @@ def boseGetDeviceID() {
|
||||
*/
|
||||
def getDeviceIP() {
|
||||
return parent.resolveDNI2Address(device.deviceNetworkId)
|
||||
}
|
||||
|
||||
def TRACE(text) {
|
||||
log.trace "${text}"
|
||||
}
|
||||
@@ -183,15 +183,6 @@ def updateState(String name, String value) {
|
||||
device.updateDataValue(name, value)
|
||||
}
|
||||
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
sendEvent(name: "numberOfButtons", value: 3)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ metadata {
|
||||
void installed() {
|
||||
// The device refreshes every 5 minutes by default so if we miss 2 refreshes we can consider it offline
|
||||
// Using 12 minutes because in testing, device health team found that there could be "jitter"
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "cloud"], displayed: false)
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, data: [protocol: "cloud", hubHardwareId: device.hub.hardwareID], displayed: false)
|
||||
}
|
||||
|
||||
// Device Watch will ping the device to proactively determine if the device has gone offline
|
||||
|
||||
@@ -39,7 +39,7 @@ metadata {
|
||||
}
|
||||
|
||||
def generatePresenceEvent(boolean present) {
|
||||
log.info "Life360 generatePresenceEvent($present)"
|
||||
log.debug "Here in generatePresenceEvent!"
|
||||
def value = formatValue(present)
|
||||
def linkText = getLinkText(device)
|
||||
def descriptionText = formatDescriptionText(linkText, present)
|
||||
|
||||
@@ -71,7 +71,7 @@ def parse(String description) {
|
||||
|
||||
def event = [:]
|
||||
def finalResult = isKnownDescription(description)
|
||||
if (finalResult) {
|
||||
if (finalResult != "false") {
|
||||
log.info finalResult
|
||||
if (finalResult.type == "update") {
|
||||
log.info "$device updates: ${finalResult.value}"
|
||||
@@ -212,16 +212,13 @@ def isKnownDescription(description) {
|
||||
else if (descMap.cluster == "0B04" || descMap.clusterId == "0B04"){
|
||||
isDescriptionPower(descMap)
|
||||
}
|
||||
else {
|
||||
return [:]
|
||||
}
|
||||
}
|
||||
else if(description?.startsWith("on/off:")) {
|
||||
def switchValue = description?.endsWith("1") ? "on" : "off"
|
||||
return [type: "switch", value : switchValue]
|
||||
}
|
||||
else {
|
||||
return [:]
|
||||
return "false"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +252,7 @@ def isDescriptionOnOff(descMap) {
|
||||
return [type: "switch", value : switchValue]
|
||||
}
|
||||
else {
|
||||
return [:]
|
||||
return "false"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -282,9 +279,10 @@ def isDescriptionLevel(descMap) {
|
||||
|
||||
if (dimmerValue != -1){
|
||||
return [type: "level", value : dimmerValue]
|
||||
|
||||
}
|
||||
else {
|
||||
return [:]
|
||||
return "false"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +304,7 @@ def isDescriptionPower(descMap) {
|
||||
return [type: "power", value : powerValue]
|
||||
}
|
||||
else {
|
||||
return [:]
|
||||
return "false"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00){
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
|
||||
@@ -132,7 +132,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00) {
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
|
||||
@@ -57,7 +57,6 @@ def parse(String description) {
|
||||
|
||||
private Map parseBasicMessage(description) {
|
||||
def name = parseName(description)
|
||||
def results = [:]
|
||||
if (name != null) {
|
||||
def value = parseValue(description)
|
||||
def linkText = getLinkText(device)
|
||||
@@ -65,7 +64,7 @@ private Map parseBasicMessage(description) {
|
||||
def handlerName = value
|
||||
def isStateChange = isStateChange(device, name, value)
|
||||
|
||||
results = [
|
||||
def results = [
|
||||
name : name,
|
||||
value : value,
|
||||
linkText : linkText,
|
||||
@@ -74,6 +73,8 @@ private Map parseBasicMessage(description) {
|
||||
isStateChange : isStateChange,
|
||||
displayed : displayed(description, isStateChange)
|
||||
]
|
||||
} else {
|
||||
results = [:]
|
||||
}
|
||||
log.debug "Parse returned $results.descriptionText"
|
||||
return results
|
||||
|
||||
@@ -161,7 +161,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if(cluster.data[0] == 0x00) {
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
@@ -339,7 +339,7 @@ private Map getContactResult(value) {
|
||||
log.debug "Contact: ${device.displayName} value = ${value}"
|
||||
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
|
||||
sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
|
||||
return [name: 'status', value: value, descriptionText: descriptionText, translatable: true]
|
||||
sendEvent(name: 'status', value: value, descriptionText: descriptionText, translatable: true)
|
||||
}
|
||||
|
||||
private getAccelerationResult(numValue) {
|
||||
|
||||
@@ -119,7 +119,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07){
|
||||
if (cluster.data[0] == 0x00) {
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
|
||||
@@ -103,7 +103,7 @@ private Map parseCatchAllMessage(String description) {
|
||||
if (cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00){
|
||||
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
|
||||
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
else {
|
||||
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
|
||||
@@ -126,15 +126,6 @@ private hold(button) {
|
||||
sendEvent(name: "button", value: "held", data: [buttonNumber: button], descriptionText: "$device.displayName button $button was held", isStateChange: true)
|
||||
}
|
||||
|
||||
|
||||
def installed() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
initialize()
|
||||
}
|
||||
|
||||
def initialize() {
|
||||
sendEvent(name: "numberOfButtons", value: 4)
|
||||
}
|
||||
|
||||
@@ -23,11 +23,9 @@ metadata {
|
||||
|
||||
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart A19 Soft White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 ON/OFF/DIM", deviceJoinName: "OSRAM LIGHTIFY LED Smart Connected Light"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FF00", outClusters: "0019", manufacturer: "MRVL", model: "MZ100", deviceJoinName: "Wemo Bulb"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B05", outClusters: "0019", manufacturer: "OSRAM SYLVANIA", model: "iQBR30", deviceJoinName: "Sylvania Ultra iQ"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY PAR38 ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart PAR38 Soft White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR ON/OFF/DIM", deviceJoinName: "SYLVANIA Smart BR30 Soft White"
|
||||
}
|
||||
|
||||
tiles(scale: 2) {
|
||||
|
||||
@@ -28,8 +28,8 @@ metadata {
|
||||
capability "Switch Level"
|
||||
capability "Health Check"
|
||||
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Gardenspot RGB", deviceJoinName: "SYLVANIA Smart Gardenspot mini RGB"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenspot RGB", deviceJoinName: "OSRAM LIGHTIFY Gardenspot mini RGB"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Gardenspot RGB", deviceJoinName: "OSRAM LIGHTIFY Gardenspot mini RGB"
|
||||
}
|
||||
|
||||
// UI tile definitions
|
||||
|
||||
@@ -32,12 +32,11 @@ metadata {
|
||||
attribute "colorName", "string"
|
||||
command "setGenericName"
|
||||
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Flex RGBW", deviceJoinName: "SYLVANIA Smart Flex RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Flex RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 RGBW", deviceJoinName: "SYLVANIA Smart A19 RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR RGBW", deviceJoinName: "SYLVANIA Smart BR30 RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT RGBW", deviceJoinName: "SYLVANIA Smart RT5/6 RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY FLEX OUTDOOR RGBW", deviceJoinName: "SYLVANIA Smart Outdoor RGBW Flex"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY LED FLEXIBLE STRIP RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY LED FLEXIBLE STRIP RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED A19 RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR RGBW", deviceJoinName: "OSRAM LIGHTIFY LED BR30 RGBW"
|
||||
fingerprint profileId: "0104", inClusters: "0000,0003,0004,0005,0006,0008,0300,0B04,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT RGBW", deviceJoinName: "OSRAM LIGHTIFY LED RT 5/6 RGBW"
|
||||
}
|
||||
|
||||
// UI tile definitions
|
||||
|
||||
@@ -32,12 +32,11 @@ metadata {
|
||||
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04", outClusters: "0019"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR Tunable White", deviceJoinName: "SYLVANIA Smart BR30 Tunable White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "SYLVANIA Smart RT5/6 Tunable White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "SYLVANIA Smart A19 Tunable White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY BR Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Flood BR30 Tunable White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY RT Tunable White", deviceJoinName: "OSRAM LIGHTIFY RT5/6 Tunable White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY A19 Tunable White", deviceJoinName: "OSRAM LIGHTIFY LED Tunable White 60W"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
|
||||
fingerprint profileId: "0104", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0702, 0B05", outClusters: "0019", manufacturer: "sengled", model: "Z01-A19NAE26", deviceJoinName: "Sengled Element plus"
|
||||
}
|
||||
|
||||
// UI tile definitions
|
||||
@@ -84,24 +83,105 @@ def parse(String description) {
|
||||
}
|
||||
}
|
||||
else {
|
||||
def cluster = zigbee.parse(description)
|
||||
Map bindingTable = parseBindingTableResponse(description)
|
||||
if (bindingTable) {
|
||||
List<String> cmds = []
|
||||
bindingTable.table_entries.inject(cmds) { acc, entry ->
|
||||
// The binding entry is not for our hub and should be deleted
|
||||
if (entry["dstAddr"] != zigbeeEui) {
|
||||
acc.addAll(removeBinding(entry.clusterId, entry.srcAddr, entry.srcEndpoint, entry.dstAddr, entry.dstEndpoint))
|
||||
}
|
||||
acc
|
||||
}
|
||||
// There are more entries that we haven't examined yet
|
||||
if (bindingTable.numTableEntries > bindingTable.startIndex + bindingTable.numEntriesReturned) {
|
||||
def startPos
|
||||
if (cmds) {
|
||||
log.warn "Removing binding entries for other devices: $cmds"
|
||||
// Since we are removing some entries, we should start in the same spot as we just read since values
|
||||
// will fill in the newly vacated spots
|
||||
startPos = bindingTable.startIndex
|
||||
} else {
|
||||
// Since we aren't removing anything we move forward to the next set of table entries
|
||||
startPos = bindingTable.startIndex + bindingTable.numEntriesReturned
|
||||
}
|
||||
cmds.addAll(requestBindingTable(startPos))
|
||||
}
|
||||
sendHubCommand(cmds.collect { it ->
|
||||
new physicalgraph.device.HubAction(it)
|
||||
}, 2000)
|
||||
} else {
|
||||
def cluster = zigbee.parse(description)
|
||||
|
||||
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00) {
|
||||
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
if (cluster && cluster.clusterId == 0x0006 && cluster.command == 0x07) {
|
||||
if (cluster.data[0] == 0x00) {
|
||||
log.debug "ON/OFF REPORTING CONFIG RESPONSE: " + cluster
|
||||
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
}
|
||||
else {
|
||||
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.warn "ON/OFF REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
|
||||
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
||||
log.debug "${cluster}"
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.warn "DID NOT PARSE MESSAGE for description : $description"
|
||||
log.debug "${cluster}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def parseBindingTableResponse(description) {
|
||||
Map descMap = zigbee.parseDescriptionAsMap(description)
|
||||
if (descMap["clusterInt"] == 0x8033) {
|
||||
def header_field_lengths = ["transactionSeqNo": 1, "status": 1, "numTableEntries": 1, "startIndex": 1, "numEntriesReturned": 1]
|
||||
def field_values = [:]
|
||||
def data = descMap["data"]
|
||||
header_field_lengths.each { k, v ->
|
||||
field_values[k] = Integer.parseInt(data.take(v).join(""), 16);
|
||||
data = data.drop(v);
|
||||
}
|
||||
|
||||
List<Map> table = []
|
||||
if (field_values.numEntriesReturned) {
|
||||
def table_entry_lengths = ["srcAddr": 8, "srcEndpoint": 1, "clusterId": 2, "dstAddrMode": 1]
|
||||
for (def i : 0..(field_values.numEntriesReturned - 1)) {
|
||||
def entryMap = [:]
|
||||
table_entry_lengths.each { k, v ->
|
||||
def val = data.take(v).reverse().join("")
|
||||
entryMap[k] = val.length() < 8 ? Integer.parseInt(val, 16) : val
|
||||
data = data.drop(v)
|
||||
}
|
||||
|
||||
switch (entryMap.dstAddrMode) {
|
||||
case 0x01:
|
||||
entryMap["dstAddr"] = data.take(2).reverse().join("")
|
||||
data = data.drop(2)
|
||||
break
|
||||
case 0x03:
|
||||
entryMap["dstAddr"] = data.take(8).reverse().join("")
|
||||
data = data.drop(8)
|
||||
entryMap["dstEndpoint"] = Integer.parseInt(data.take(1).join(""), 16)
|
||||
data = data.drop(1)
|
||||
break
|
||||
}
|
||||
table << entryMap
|
||||
}
|
||||
}
|
||||
field_values["table_entries"] = table
|
||||
return field_values
|
||||
}
|
||||
return [:]
|
||||
}
|
||||
|
||||
def requestBindingTable(startPos=0) {
|
||||
return ["zdo mgmt-bind 0x${zigbee.deviceNetworkId} $startPos"]
|
||||
}
|
||||
|
||||
def removeBinding(cluster, srcAddr, srcEndpoint, destAddr, destEndpoint) {
|
||||
return ["zdo unbind unicast 0x${zigbee.deviceNetworkId} {${srcAddr}} $srcEndpoint $cluster {${destAddr}} $destEndpoint"]
|
||||
}
|
||||
|
||||
|
||||
def off() {
|
||||
zigbee.off()
|
||||
}
|
||||
@@ -131,8 +211,7 @@ def configure() {
|
||||
// enrolls with default periodic reporting until newer 5 min interval is confirmed
|
||||
sendEvent(name: "checkInterval", value: 2 * 10 * 60 + 1 * 60, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
|
||||
|
||||
// OnOff minReportTime 0 seconds, maxReportTime 5 min. Reporting interval if no activity
|
||||
refresh()
|
||||
refresh() + requestBindingTable(0) + ["delay 2000"]
|
||||
}
|
||||
|
||||
def setColorTemperature(value) {
|
||||
|
||||
@@ -127,8 +127,8 @@ def configureHealthCheck() {
|
||||
|
||||
def configure() {
|
||||
log.debug "configure()"
|
||||
configureHealthCheck()
|
||||
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
|
||||
configureHealthCheck()
|
||||
}
|
||||
|
||||
def updated() {
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
author: "SmartThings",
|
||||
description: "Control your Bose SoundTouch speakers",
|
||||
category: "SmartThings Labs",
|
||||
iconUrl: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon.png",
|
||||
iconX2Url: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon@2x.png",
|
||||
iconX3Url: "https://d3azp77rte0gip.cloudfront.net/smartapps/fcf1d93a-ba0b-4324-b96f-e5b5487dfaf5/images/BoseST_icon@2x-1.png",
|
||||
iconUrl: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png",
|
||||
iconX2Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
||||
iconX3Url: "https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience@2x.png",
|
||||
singleInstance: true
|
||||
)
|
||||
|
||||
@@ -104,7 +104,7 @@ def deviceDiscovery()
|
||||
|
||||
return dynamicPage(name:"deviceDiscovery", title:"Discovery Started!", nextPage:"", refreshInterval:refreshInterval, install:true, uninstall: true) {
|
||||
section("Please wait while we discover your ${getDeviceName()}. Discovery can take five minutes or more, so sit back and relax! Select your device below once discovered.") {
|
||||
input "selecteddevice", "enum", required:false, title:"Select ${getDeviceName()} (${numFound} found)", multiple:true, options:devices, submitOnChange: true
|
||||
input "selecteddevice", "enum", required:false, title:"Select ${getDeviceName()} (${numFound} found)", multiple:true, options:devices
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,8 +196,6 @@ def addDevice(){
|
||||
d = addChildDevice(getNameSpace(), getDeviceName(), dni, newDevice?.value.hub, [label:"${deviceName}"])
|
||||
d.boseSetDeviceID(newDevice.value.deviceID)
|
||||
log.trace "Created ${d.displayName} with id $dni"
|
||||
// sync DTH with device, done here as it currently don't work from the DTH's installed() method
|
||||
d.refresh()
|
||||
} else {
|
||||
log.trace "${d.displayName} with id $dni already exists"
|
||||
}
|
||||
|
||||
@@ -289,12 +289,12 @@ def initializeLife360Connection() {
|
||||
state.life360AccessToken = result.data.access_token
|
||||
return true;
|
||||
}
|
||||
log.info "Life360 initializeLife360Connection, response=${result.data}"
|
||||
log.debug "Response=${result.data}"
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (e) {
|
||||
log.error "Life360 initializeLife360Connection, error: $e"
|
||||
log.debug e
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@ def generateInitialEvent (member, childDevice) {
|
||||
|
||||
try { // we are going to just ignore any errors
|
||||
|
||||
log.info "Life360 generateInitialEvent($member, $childDevice)"
|
||||
log.debug "Generate Initial Event for New Device for Member = ${member.id}"
|
||||
|
||||
def place = state.places.find{it.id==settings.place}
|
||||
|
||||
@@ -677,8 +677,6 @@ def generateInitialEvent (member, childDevice) {
|
||||
// log.debug "Distance Away = ${distanceAway}"
|
||||
|
||||
boolean isPresent = (distanceAway <= placeRadius)
|
||||
|
||||
log.info "Life360 generateInitialEvent, member: ($memberLatitude, $memberLongitude), place: ($placeLatitude, $placeLongitude), radius: $placeRadius, dist: $distanceAway, present: $isPresent"
|
||||
|
||||
// log.debug "External Id=${app.id}:${member.id}"
|
||||
|
||||
@@ -720,7 +718,7 @@ def haversine(lat1, lon1, lat2, lon2) {
|
||||
|
||||
def placeEventHandler() {
|
||||
|
||||
log.info "Life360 placeEventHandler: params=$params, settings.place=$settings.place"
|
||||
log.debug "In placeEventHandler method."
|
||||
|
||||
// the POST to this end-point will look like:
|
||||
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
|
||||
@@ -731,6 +729,8 @@ def placeEventHandler() {
|
||||
def direction = params?.direction
|
||||
def timestamp = params?.timestamp
|
||||
|
||||
log.debug "Life360 Event: Circle: ${circleId}, Place: ${placeId}, User: ${userId}, Direction: ${direction}"
|
||||
|
||||
if (placeId == settings.place) {
|
||||
|
||||
def presenceState = (direction=="in")
|
||||
@@ -745,10 +745,10 @@ def placeEventHandler() {
|
||||
|
||||
if (deviceWrapper) {
|
||||
deviceWrapper.generatePresenceEvent(presenceState)
|
||||
log.debug "Life360 event raised on child device: ${externalId}"
|
||||
log.debug "Event raised on child device: ${externalId}"
|
||||
}
|
||||
else {
|
||||
log.warn "Life360 couldn't find child device associated with inbound Life360 event."
|
||||
log.debug "Couldn't find child device associated with inbound Life360 event."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user