Compare commits

..

20 Commits

Author SHA1 Message Date
OpenT2T
0bcde8a1f0 Modifying 'Publish a SmartApp for OpenT2T - Remove support for multiple subscriptions to a single device.' 2017-06-19 17:28:46 -07:00
OpenT2T
9d63d0bbf9 Modifying 'Publish a SmartApp for OpenT2T - Remove support for multiple subscriptions to a single device.' 2017-06-19 17:25:53 -07:00
OpenT2T
385463772b Modifying 'Publish a SmartApp for OpenT2T - Fix register all device change handler' 2017-05-12 18:23:08 -07:00
OpenT2T
284828c42f Modifying 'Publish a SmartApp for OpenT2T - HMAC support' 2017-05-01 20:10:13 -07:00
OpenT2T
bbdc8faa93 Modifying 'Publish a SmartApp for OpenT2T - Update sensor and subscriptions.' 2017-04-16 19:02:05 -07:00
OpenT2T
48ceadcdb6 Modifying 'Publish a SmartApp for OpenT2T - Update sensor and subscriptions.' 2017-04-16 19:01:30 -07:00
OpenT2T
8e59df0de5 Modifying 'Publish a SmartApp for OpenT2T - Update sensor and subscriptions.' 2017-04-16 19:01:26 -07:00
OpenT2T
d276b80c90 Modifying 'Publish a SmartApp for OpenT2T - Update event messages.' 2017-03-06 01:02:07 -08:00
OpenT2T
8d838ead33 Modifying 'Publish a SmartApp for OpenT2T - Update event messages.' 2017-03-06 01:02:05 -08:00
OpenT2T
bf23f19af5 Modifying 'Update event messages.' 2017-03-06 00:59:48 -08:00
OpenT2T
d5bce43a99 Modifying 'Update event messages.' 2017-03-06 00:59:47 -08:00
OpenT2T
08c6f143dc Modifying 'Support device status.' 2017-03-03 03:11:10 -08:00
OpenT2T
b6f4581d6d Modifying 'Publish a SmartApp for OpenT2T' 2017-03-02 05:20:53 -08:00
OpenT2T
a56cad5e03 Modifying 'Publish a SmartApp for OpenT2T' 2017-03-02 05:20:47 -08:00
OpenT2T
4ed48c8ed4 Modifying 'Publish a SmartApp for OpenT2T' 2017-02-05 19:55:22 -08:00
OpenT2T
0bfd77745e Modifying 'Publish a SmartApp for OpenT2T' 2017-02-05 19:55:17 -08:00
OpenT2T
355f641853 Modifying 'Publish a SmartApp for OpenT2T' 2017-01-09 23:06:17 -08:00
OpenT2T
aba1f48f1f Modifying 'Publish a SmartApp for OpenT2T' 2017-01-09 23:06:16 -08:00
OpenT2T
9bf39136de Modifying 'Publish a SmartApp for OpenT2T' 2017-01-09 22:39:52 -08:00
OpenT2T
97fdc03c00 MSA-1577: This SmartApp enables the end-to-end SmartThings scenarios via OpenT2T. More information on OpenT2T can be found at http://www.opentranslatorstothings.org/#/ 2016-11-14 12:08:30 -08:00
22 changed files with 791 additions and 2992 deletions

View File

@@ -1,600 +0,0 @@
/**
* Copyright 2015 Stuart Buchanan
*
* 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.
*
* Tado AC Thermostat
*
* Author: Stuart Buchanan, Based on original work by Ian M with thanks. also source for icons was from @tonesto7's excellent Nest Manager.
* Date: 2016-11-28 v3.0 Moved all data collection functions into Tado (Connect) SmartApp, huge changes to device handler, existing devices and handler will need to be uninstalled before installing this version
* Date: 2016-07-13 v2.9 Quick dirty workaround to control zones with a single account.
* Date: 2016-05-07 v2.8 Corrected issue with Fan Speed commands not working.
* Date: 2016-04-25 v2.7 Minor changes to thermostatOperatingState to Show "idle" and "fan only" state
* Date: 2016-04-25 v2.6 Minor bug fix to correct issue with reading existing set point value.
* Date: 2016-04-09 v2.5 Major bug fix exercise, found lots and lots and lots.....now 100% conforms to ST Thermostat capability. main panel now shows colour of operating state. new attributes tadoMode and tadoFanSpeed created.
* Date: 2016-04-05 v2.4 Performed Testing with Thermostat Mode Director and found some deficiencies where this would not work correctly. i have now corrected, this now works fine and has been tested.
* Date: 2016-04-05 v2.3 added device preference for default temps for some commands as requested by @mitchell_lu66, also added some additional refreshes and error control for unsupported capabilities
* Date: 2016-04-05 v2.2 Added Fan Speed & Emergency Heat (1 Hour) Controls and also a manual Mode End function to fall back to Tado Control.
Also added preference for how long manual mode runs for either ends at Tado Mode Change (TADO_MODE) or User Control (MANUAL),
please ensure the default method is Set in the device properties
* Date: 2016-04-05 v2.1 Minor Bug Fixes & improved Icons
* Date: 2016-04-05 v2.0 Further Changes to MultiAttribute Tile
* Date: 2016-04-05 v1.9 Amended Device Handler Name
* Date: 2016-04-05 v1.8 Added all thermostat related capabilities
* Date: 2016-04-05 v1.7 Amended device to be capable of both Fahrenheit and celsius and amended the Device multiattribute tile
* Date: 2016-04-05 v1.6 switched API calls to new v2 calls as the old ones had been deprecated.
* Date: 2016-02-21 v1.5 switched around thermostatOperatingState & thermostatMode to get better compatibility with Home Remote
* Date: 2016-02-21 v1.4 added HeatingSetPoint & CoolingSetPoint to make compatible with SmartTiles
* Date: 2016-02-21 v1.3 amended the read thermostat properties to match the ST Thermostat Capability
* Date: 2016-02-14 v1.2 amended the thermostat properties to match the ST Capability.Thermostat values
* Date: 2016-01-23 v1.1 fixed error in Tado Mode detection
* Date: 2016-01-22 v1.1 Add Heating & Cooling Controls (initial offering, will need to look into adding all possible commands)
* Date: 2015-12-04 v1.0 Initial Release With Temperatures & Relative Humidity
*/
import groovy.json.JsonOutput
preferences {
}
metadata {
definition (name: "Tado Cooling Thermostat", namespace: "fuzzysb", author: "Stuart Buchanan") {
capability "Actuator"
capability "Temperature Measurement"
capability "Thermostat Cooling Setpoint"
capability "Thermostat Heating Setpoint"
capability "Thermostat Mode"
capability "Thermostat Fan Mode"
capability "Thermostat Setpoint"
capability "Thermostat Operating State"
capability "Thermostat"
capability "Relative Humidity Measurement"
capability "Polling"
capability "Refresh"
attribute "tadoMode", "string"
attribute "tadoFanSpeed", "string"
command "temperatureUp"
command "temperatureDown"
command "heatingSetpointUp"
command "heatingSetpointDown"
command "coolingSetpointUp"
command "coolingSetpointDown"
command "cmdFanSpeedAuto"
command "cmdFanSpeedHigh"
command "cmdFanSpeedMid"
command "cmdFanSpeedLow"
command "dry"
command "on"
command "fan"
command "endManualControl"
command "emergencyHeat"
}
// simulator metadata
simulator {
// status messages
// reply messages
}
tiles(scale: 2){
multiAttributeTile(name: "thermostat", type:"thermostat", width:6, height:4) {
tileAttribute("device.temperature", key:"PRIMARY_CONTROL", canChangeIcon: true, canChangeBackground: true){
attributeState "default", label:'${currentValue}°', backgroundColor:"#fab907", icon:"st.Home.home1"
}
tileAttribute("device.temperature", key: "VALUE_CONTROL") {
attributeState("VALUE_UP", action: "temperatureUp")
attributeState("VALUE_DOWN", action: "temperatureDown")
}
tileAttribute("device.humidity", key: "SECONDARY_CONTROL") {
attributeState("default", label:'${currentValue}%', unit:"%")
}
tileAttribute("device.thermostatOperatingState", key: "OPERATING_STATE") {
attributeState("idle", backgroundColor:"#666666")
attributeState("heating", backgroundColor:"#ff471a")
attributeState("cooling", backgroundColor:"#1a75ff")
attributeState("emergency heat", backgroundColor:"#ff471a")
attributeState("drying", backgroundColor:"#c68c53")
attributeState("fan only", backgroundColor:"#39e600")
attributeState("heating|cooling", backgroundColor:"#ff9900")
}
tileAttribute("device.thermostatMode", key: "THERMOSTAT_MODE") {
attributeState("off", label:'${name}')
attributeState("heat", label:'${name}')
attributeState("cool", label:'${name}')
attributeState("auto", label:'${name}')
attributeState("fan", label:'${name}')
attributeState("dry", label:'${name}')
}
tileAttribute("device.heatingSetpoint", key: "HEATING_SETPOINT") {
attributeState("default", label:'${currentValue}', unit:"dF")
}
tileAttribute("device.coolingSetpoint", key: "COOLING_SETPOINT") {
attributeState("default", label:'${currentValue}', unit:"dF")
}
}
standardTile("tadoMode", "device.tadoMode", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state("SLEEP", label:'${name}', backgroundColor:"#0164a8", icon:"st.Bedroom.bedroom2")
state("HOME", label:'${name}', backgroundColor:"#fab907", icon:"st.Home.home2")
state("AWAY", label:'${name}', backgroundColor:"#62aa12", icon:"st.Outdoor.outdoor18")
state("OFF", label:'${name}', backgroundColor:"#ffffff", icon:"st.switches.switch.off", defaultState: true)
state("MANUAL", label:'${name}', backgroundColor:"#804000", icon:"st.Weather.weather1")
}
standardTile("refresh", "device.switch", inactiveLabel: false, width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
standardTile("thermostatMode", "device.thermostatMode", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state("heat", label:'HEAT', backgroundColor:"#ea2a2a", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/heat_mode_icon.png")
state("emergency heat", label:'HEAT', backgroundColor:"#ea2a2a", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/heat_mode_icon.png")
state("cool", label:'COOL', backgroundColor:"#089afb", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/cool_mode_icon.png")
state("dry", label:'DRY', icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/dry_mode_icon.png")
state("fan", label:'FAN', backgroundColor:"#ffffff", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_mode_icononly.png")
state("auto", label:'AUTO', icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/auto_mode_icon.png")
state("off", label:'', backgroundColor:"#ffffff", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/hvac_off.png", defaultState: true)
}
valueTile("thermostatSetpoint", "device.thermostatSetpoint", width: 2, height: 1, decoration: "flat") {
state "default", label: 'Set Point\r\n\${currentValue}°'
}
valueTile("heatingSetpoint", "device.heatingSetpoint", width: 2, height: 1, decoration: "flat") {
state "default", label: 'Set Point\r\n\${currentValue}°'
}
valueTile("coolingSetpoint", "device.coolingSetpoint", width: 2, height: 1, decoration: "flat") {
state "default", label: 'Set Point\r\n\${currentValue}°'
}
valueTile("outsidetemperature", "device.outsidetemperature", width: 2, height: 1, decoration: "flat") {
state "outsidetemperature", label: 'Outside Temp\r\n${currentValue}°'
}
standardTile("tadoFanSpeed", "device.tadoFanSpeed", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true, decoration: "flat") {
state("OFF", label:'', icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_off_icon.png", defaultState: true)
state("AUTO", label:'', icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_auto_icon.png")
state("HIGH", label:'', icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_high_icon.png")
state("MIDDLE", label:'', icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_med_icon.png")
state("LOW", label:'', icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_low_icon.png")
}
standardTile("setAuto", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.auto", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/hvac_auto.png"
}
standardTile("setDry", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"dry", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/hvac_dry.png"
}
standardTile("setOn", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"on", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/hvac_on.png"
}
standardTile("setOff", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.off", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/hvac_off.png"
}
standardTile("cool", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.cool", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/hvac_cool.png"
}
standardTile("heat", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.heat", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/hvac_heat.png"
}
standardTile("emergencyHeat", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.emergencyHeat", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/emergencyHeat.png"
}
standardTile("fan", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.fan", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_mode_icon.png"
}
standardTile("coolingSetpointUp", "device.coolingSetpoint", canChangeIcon: false, decoration: "flat") {
state "coolingSetpointUp", label:' ', action:"coolingSetpointUp", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/cool_arrow_up.png"
}
standardTile("coolingSetpointDown", "device.coolingSetpoint", canChangeIcon: false, decoration: "flat") {
state "coolingSetpointDown", label:' ', action:"coolingSetpointDown", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/cool_arrow_down.png"
}
standardTile("heatingSetpointUp", "device.heatingSetpoint", canChangeIcon: false, decoration: "flat") {
state "heatingSetpointUp", label:' ', action:"heatingSetpointUp", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/heat_arrow_up.png"
}
standardTile("heatingSetpointDown", "device.heatingSetpoint", canChangeIcon: false, decoration: "flat") {
state "heatingSetpointDown", label:' ', action:"heatingSetpointDown", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/heat_arrow_down.png"
}
standardTile("cmdFanSpeedAuto", "device.thermostat", width: 2, height: 1, canChangeIcon: false, canChangeBackground: true, decoration: "flat") {
state("default", label:'', action:"cmdFanSpeedAuto", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_auto_icon.png")
}
standardTile("cmdFanSpeedHigh", "device.thermostat", width: 2, height: 1, canChangeIcon: false, canChangeBackground: true, decoration: "flat") {
state("default", label:'', action:"cmdFanSpeedHigh", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_high_icon.png")
}
standardTile("cmdFanSpeedMid", "device.thermostat", width: 2, height: 1, canChangeIcon: false, canChangeBackground: true, decoration: "flat") {
state("default", label:'', action:"cmdFanSpeedMid", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_med_icon.png")
}
standardTile("cmdFanSpeedLow", "device.thermostat", width: 2, height: 1, canChangeIcon: false, canChangeBackground: true, decoration: "flat") {
state("default", label:'', action:"cmdFanSpeedLow", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/fan_low_icon.png")
}
standardTile("endManualControl", "device.thermostat", width: 2, height: 1, canChangeIcon: false, canChangeBackground: true, decoration: "flat") {
state("default", label:'', action:"endManualControl", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado-Cooling-AC.src/Images/endManual.png")
}
main(["thermostat"])
details(["thermostat","thermostatMode","coolingSetpointUp","coolingSetpointDown","autoOperation","heatingSetpointUp","heatingSetpointDown","outsidetemperature","thermostatSetpoint","tadoMode","refresh","tadoFanSpeed","setAuto","setOn","setOff","fan","cool","heat","setDry","cmdFanSpeedAuto","emergencyHeat","endManualControl","cmdFanSpeedLow","cmdFanSpeedMid","cmdFanSpeedHigh"])
}
}
def setCapabilitytadoType(value){
state.tadoType = value
log.debug("state.tadoType = ${state.tadoType}")
}
def getCapabilitytadoType() {
def map = null
map = [name: "capabilityTadoType", value: state.tadoType]
return map
}
def setCapabilitySupportsAuto(value){
state.supportsAuto = value
log.debug("state.supportsAuto = ${state.supportsAuto}")
}
def getCapabilitySupportsAuto() {
def map = null
map = [name: "capabilitySupportsAuto", value: state.supportsAuto]
return map
}
def setCapabilitySupportsCool(value){
state.supportsCool = value
log.debug("state.supportsCool = ${state.supportsCool}")
}
def getCapabilitySupportsCool() {
def map = null
map = [name: "capabilitySupportsCool", value: state.supportsCool]
return map
}
def setCapabilitySupportsCoolAutoFanSpeed(value){
state.SupportsCoolAutoFanSpeed = value
log.debug("state.SupportsCoolAutoFanSpeed = ${state.SupportsCoolAutoFanSpeed}")
}
def getCapabilitySupportsCoolAutoFanSpeed() {
def map = null
map = [name: "capabilitySupportsCoolAutoFanSpeed", value: state.supportsCoolAutoFanSpeed]
return map
}
def setCapabilitySupportsDry(value){
state.supportsDry = value
log.debug("state.supportsDry = ${state.supportsDry}")
}
def getCapabilitySupportsDry() {
def map = null
map = [name: "capabilitySupportsDry", value: state.supportsDry]
return map
}
def setCapabilitySupportsFan(value){
state.supportsFan = value
log.debug("state.supportsFan = ${state.supportsFan}")
}
def getCapabilitySupportsFan() {
def map = null
map = [name: "capabilitySupportsFan", value: state.supportsFan]
return map
}
def setCapabilitySupportsHeat(value){
state.supportsHeat = value
log.debug("state.supportsHeat = ${state.supportsHeat}")
}
def getCapabilitySupportsHeat() {
def map = null
map = [name: "capabilitySupportsHeat", value: state.supportsHeat]
return map
}
def setCapabilitySupportsHeatAutoFanSpeed(value){
state.SupportsHeatAutoFanSpeed = value
log.debug("state.SupportsHeatAutoFanSpeed = ${state.SupportsHeatAutoFanSpeed}")
}
def getCapabilitySupportsHeatAutoFanSpeed() {
def map = null
map = [name: "capabilitySupportsHeatAutoFanSpeed", value: state.SupportsHeatAutoFanSpeed]
return map
}
def setCapabilityMaxCoolTemp(value){
state.MaxCoolTemp = value
log.debug("set state.MaxCoolTemp to : " + state.MaxCoolTemp)
}
def getCapabilityMaxCoolTemp() {
def map = null
map = [name: "capabilityMaxCoolTemp", value: state.MaxCoolTemp]
return map
}
def setCapabilityMinCoolTemp(value){
state.MinCoolTemp = value
log.debug("set state.MinCoolTemp to : " + state.MinCoolTemp)
}
def getCapabilityMinCoolTemp() {
def map = null
map = [name: "capabilityMinCoolTemp", value: state.MinCoolTemp]
return map
}
def setCapabilityMaxHeatTemp(value){
state.MaxHeatTemp = value
log.debug("set state.MaxHeatTemp to : " + state.MaxHeatTemp)
}
def getCapabilityMaxHeatTemp() {
def map = null
map = [name: "capabilityMaxHeatTemp", value: state.MaxHeatTemp]
return map
}
def setCapabilityMinHeatTemp(value){
state.MinHeatTemp = value
log.debug("set state.MinHeatTemp to : " + state.MinHeatTemp)
}
def getCapabilityMinHeatTemp() {
def map = null
map = [name: "capabilityMinHeatTemp", value: state.MinHeatTemp]
return map
}
def updated(){
refresh()
}
def installed(){
refresh()
}
def poll() {
log.debug "Executing 'poll'"
refresh()
}
def refresh() {
log.debug "Executing 'refresh'"
parent.statusCommand(this)
getWeather()
}
def getWeather(){
parent.weatherStatusCommand(this)
}
def auto() {
log.debug "Executing 'auto'"
parent.autoCommand(this)
parent.statusCommand(this)
}
def on() {
log.debug "Executing 'on'"
parent.onCommand(this)
parent.statusCommand(this)
}
def off() {
log.debug "Executing 'off'"
parent.offCommand(this)
parent.statusCommand(this)
}
def dry() {
log.debug "Executing 'dry'"
parent.dryCommand(this)
parent.statusCommand(this)
}
def setThermostatMode(requiredMode){
switch (requiredMode) {
case "dry":
dry()
break
case "heat":
heat()
break
case "cool":
cool()
break
case "auto":
auto()
break
case "fan":
fan()
break
case "off":
off()
break
case "emergency heat":
emergencyHeat()
break
}
}
def thermostatFanMode(requiredMode){
switch (requiredMode) {
case "auto":
fan()
break
case "on":
fan()
break
case "circulate":
fan()
break
}
}
def setHeatingSetpoint(targetTemperature) {
log.debug "Executing 'setHeatingSetpoint'"
log.debug "Target Temperature ${targetTemperature}"
parent.setHeatingTempCommand(this,targetTemperature)
refresh()
}
def temperatureUp(){
if (device.currentValue("thermostatMode") == "heat") {
heatingSetpointUp()
} else if (device.currentValue("thermostatMode") == "cool") {
coolingSetpointUp()
} else {
log.debug ("temperature setpoint not supported in the current thermostat mode")
}
}
def temperatureDown(){
if (device.currentValue("thermostatMode") == "heat") {
heatingSetpointDown()
} else if (device.currentValue("thermostatMode") == "cool") {
coolingSetpointDown()
} else {
log.debug ("temperature setpoint not supported in the current thermostat mode")
}
}
def heatingSetpointUp(){
def capabilitysupported = state.supportsHeat
if (capabilitysupported == "true"){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if ((device.currentValue("thermostatSetpoint").toInteger() - 1 ) < state.MinHeatTemp){
log.debug("cannot decrease heat setpoint, its already at the minimum level of " + state.MinHeatTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() + 1
log.debug "Setting heatingSetpoint up to: ${newSetpoint}"
setHeatingSetpoint(newSetpoint)
}
} else {
log.debug("Sorry Heat Capability not supported by your HVAC Device")
}
}
def heatingSetpointDown(){
def capabilitysupported = state.supportsHeat
if (capabilitysupported == "true"){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if ((device.currentValue("thermostatSetpoint").toInteger() + 1 ) > state.MaxHeatTemp){
log.debug("cannot increase heat setpoint, its already at the maximum level of " + state.MaxHeatTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() - 1
log.debug "Setting heatingSetpoint down to: ${newSetpoint}"
setHeatingSetpoint(newSetpoint)
}
} else {
log.debug("Sorry Heat Capability not supported by your HVAC Device")
}
}
def setCoolingSetpoint(targetTemperature) {
log.debug "Executing 'setCoolingSetpoint'"
log.debug "Target Temperature ${targetTemperature}"
parent.setCoolingTempCommand(this,targetTemperature)
refresh()
}
def coolingSetpointUp(){
def capabilitysupported = state.supportsCool
if (capabilitysupported == "true"){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if ((device.currentValue("thermostatSetpoint").toInteger() + 1 ) > state.MaxCoolTemp){
log.debug("cannot increase cool setpoint, its already at the maximum level of " + state.MaxCoolTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() + 1
log.debug "Setting coolingSetpoint up to: ${newSetpoint}"
setCoolingSetpoint(newSetpoint)
}
} else {
log.debug("Sorry Cool Capability not supported by your HVAC Device")
}
}
def coolingSetpointDown(){
def capabilitysupported = state.supportsCool
if (capabilitysupported == "true"){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if ((device.currentValue("thermostatSetpoint").toInteger() - 1 ) < state.MinCoolTemp){
log.debug("cannot decrease cool setpoint, its already at the minimum level of " + state.MinCoolTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() - 1
log.debug "Setting coolingSetpoint down to: ${newSetpoint}"
setCoolingSetpoint(newSetpoint)
}
} else {
log.debug("Sorry Cool Capability not supported by your HVAC Device")
}
}
def fanOn(){
fan()
}
def fanCirculate(){
fan()
}
def cool(){
def capabilitysupported = state.supportsCool
if (capabilitysupported == "true"){
parent.coolCommand(this)
parent.statusCommand(this)
} else {
log.debug("Sorry Cool Capability not supported by your HVAC Device")
}
}
def heat(){
def capabilitysupported = state.supportsHeat
if (capabilitysupported == "true"){
parent.heatCommand(this)
parent.statusCommand(this)
} else {
log.debug("Sorry Heat Capability not supported by your HVAC Device")
}
}
def fan(){
parent.fanAuto(this)
refresh()
}
def emergencyHeat(){
parent.emergencyHeat(this)
}
def cmdFanSpeedAuto(){
parent.cmdFanSpeedAuto(this)
}
def cmdFanSpeedHigh(){
parent.cmdFanSpeedHigh(this)
}
def cmdFanSpeedMed(){
parent.cmdFanSpeedMed(this)
}
def cmdFanSpeedLow(){
parent.cmdFanSpeedLow(this)
}
def endManualControl(){
parent.endManualControl(this)
}

View File

@@ -1,270 +0,0 @@
/**
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* Tado Thermostat
*
* Author: Stuart Buchanan, Based on original work by Ian M with thanks. also source for icons was from @tonesto7's excellent Nest Manager.
*
* Updates:
* Date: 2016-11-28 v1.9 Moved all data collection functions into Tado (Connect) SmartApp, huge changes to device handler, existing devices and handler will need to be uninstalled before installing this version
* Date: 2016-07-13 v1.8 Quick dirty workaround to control zones with a single account.
* Date: 2016-04-25 v1.7 Finally found time to update this with the lessons learnt from the Tado Cooling Device Type. will bring better support for RM and Thermostat Director
* Date: 2016-04-08 v1.6 added statusCommand calls to refresh more frequently, also improved compatibility with Rule Machine and Thermostat Mode Director in addition also added default heating temperature where you can set the default temperature for the mode commands.
* Date: 2016-04-05 v1.5 added improved icons and also a manual Mode End function to fall back to Tado Control.
Also added preference for how long manual mode runs for either ends at Tado Mode Change (TADO_MODE) or User Control (MANUAL),
please ensure the default method is Set in the device properties
* Date: 2016-04-05 v1.4 rewrite of complete functions to support Tado API v2
* Date: 2016-01-20 v1.3 Updated hvacStatus to include include the correct HomeId for Humidity Value
* Date: 2016-01-15 v1.2 Refactored API request code and added querying/display of humidity
* Date: 2015-12-23 v1.1 Added functionality to change thermostat settings
* Date: 2015-12-04 v1.0 Initial release
*/
preferences {
input("username", "text", title: "Username", description: "Your Tado username")
input("password", "password", title: "Password", description: "Your Tado password")
input("tadoZoneId", "number", title: "Enter Tado Zone ID?", required: true)
input("manualmode", "enum", title: "Default Manual Overide Method", options: ["TADO_MODE","MANUAL"], required: false, defaultValue:"TADO_MODE")
input("defHeatingTemp", "number", title: "Default Heating Temperature?", required: false, defaultValue: 21)
}
metadata {
definition (name: "Tado Heating Thermostat", namespace: "fuzzysb", author: "Stuart Buchanan") {
capability "Actuator"
capability "Temperature Measurement"
capability "Thermostat Heating Setpoint"
capability "Thermostat Setpoint"
capability "Thermostat Mode"
capability "Thermostat Operating State"
capability "Thermostat"
capability "Relative Humidity Measurement"
capability "Polling"
capability "Refresh"
attribute "tadoMode", "string"
command "temperatureUp"
command "temperatureDown"
command "heatingSetpointUp"
command "heatingSetpointDown"
command "on"
command "endManualControl"
command "emergencyHeat"
}
// simulator metadata
simulator {
// status messages
// reply messages
}
tiles(scale: 2){
multiAttributeTile(name: "thermostat", type:"thermostat", width:6, height:4) {
tileAttribute("device.temperature", key:"PRIMARY_CONTROL", canChangeIcon: true, canChangeBackground: true){
attributeState "default", label:'${currentValue}°', backgroundColor:"#fab907", icon:"st.Home.home1"
}
tileAttribute("device.temperature", key: "VALUE_CONTROL") {
attributeState("VALUE_UP", action: "temperatureUp")
attributeState("VALUE_DOWN", action: "temperatureDown")
}
tileAttribute("device.humidity", key: "SECONDARY_CONTROL") {
attributeState("default", label:'${currentValue}%', unit:"%")
}
tileAttribute("device.thermostatOperatingState", key: "OPERATING_STATE") {
attributeState("idle", backgroundColor:"#666666")
attributeState("heating", backgroundColor:"#ff471a")
attributeState("emergency heat", backgroundColor:"#ff471a")
}
tileAttribute("device.thermostatMode", key: "THERMOSTAT_MODE") {
attributeState("off", label:'${name}')
attributeState("heat", label:'${name}')
}
tileAttribute("device.heatingSetpoint", key: "HEATING_SETPOINT") {
attributeState("default", label:'${currentValue}', unit:"dF")
}
}
valueTile("heatingSetpoint", "device.heatingSetpoint", width: 2, height: 1, decoration: "flat") {
state "default", label: 'Set Point\r\n\${currentValue}°'
}
standardTile("tadoMode", "device.tadoMode", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state("SLEEP", label:'${name}', backgroundColor:"#0164a8", icon:"st.Bedroom.bedroom2")
state("HOME", label:'${name}', backgroundColor:"#fab907", icon:"st.Home.home2")
state("AWAY", label:'${name}', backgroundColor:"#62aa12", icon:"st.Outdoor.outdoor18")
state("OFF", label:'', backgroundColor:"#ffffff", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/hvac_off.png", defaultState: true)
state("MANUAL", label:'${name}', backgroundColor:"#804000", icon:"st.Weather.weather1")
}
standardTile("thermostatMode", "device.thermostatMode", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state("heat", label:'HEAT', backgroundColor:"#ea2a2a", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/heat_mode_icon.png")
state("off", label:'', backgroundColor:"#ffffff", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/hvac_off.png", defaultState: true)
}
standardTile("refresh", "device.switch", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
standardTile("Off", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.off", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/hvac_off.png"
}
standardTile("emergencyHeat", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.emergencyHeat", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/emergencyHeat.png"
}
valueTile("outsidetemperature", "device.outsidetemperature", width: 2, height: 1, decoration: "flat") {
state "outsidetemperature", label: 'Outside Temp\r\n${currentValue}°'
}
standardTile("heat", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.heat", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/hvac_heat.png"
}
standardTile("heatingSetpointUp", "device.heatingSetpoint", width: 1, height: 1, canChangeIcon: false, decoration: "flat") {
state "heatingSetpointUp", label:'', action:"heatingSetpointUp", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/heat_arrow_up.png"
}
standardTile("heatingSetpointDown", "device.heatingSetpoint", width: 1, height: 1, canChangeIcon: false, decoration: "flat") {
state "heatingSetpointDown", label:'', action:"heatingSetpointDown", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/heat_arrow_down.png"
}
standardTile("endManualControl", "device.thermostat", width: 2, height: 1, canChangeIcon: false, canChangeBackground: true, decoration: "flat") {
state("default", label:'', action:"endManualControl", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Heating.src/Images/endManual.png")
}
main "thermostat"
details (["thermostat","thermostatMode","outsidetemperature","heatingSetpoint","refresh","heatingSetpointUp","heatingSetpointDown","tadoMode","emergencyHeat","heat","Off","endManualControl"])
}
}
def getWeather(){
parent.weatherStatusCommand(this)
}
def setCapabilitySupportsHeat(value){
state.supportsHeat = value
log.debug("state.supportsHeat = ${state.supportsHeat}")
}
def getCapabilitySupportsHeat() {
def map = null
map = [name: "capabilitySupportsHeat", value: state.supportsHeat]
return map
}
def updated(){
refresh()
}
def installed(){
refresh()
}
def poll() {
log.debug "Executing 'poll'"
refresh()
}
def refresh() {
log.debug "Executing 'refresh'"
parent.statusCommand(this)
getWeather()
}
def auto() {
log.debug "Executing 'auto'"
parent.autoCommand(this)
parent.statusCommand(this)
}
def on() {
log.debug "Executing 'on'"
parent.onCommand(this)
parent.statusCommand(this)
}
def off() {
log.debug "Executing 'off'"
parent.offCommand(this)
parent.statusCommand(this)
}
def setHeatingSetpoint(targetTemperature) {
log.debug "Executing 'setHeatingSetpoint'"
log.debug "Target Temperature ${targetTemperature}"
parent.setHeatingTempCommand(this,targetTemperature)
parent.statusCommand(this)
}
def setThermostatMode(requiredMode){
switch (requiredMode) {
case "heat":
heat()
break
case "auto":
auto()
break
case "off":
off()
break
case "emergency heat":
emergencyHeat()
break
}
}
def temperatureUp(){
if (device.currentValue("thermostatMode") == "heat") {
heatingSetpointUp()
} else {
log.debug ("temperature setpoint not supported in the current thermostat mode")
}
}
def temperatureDown(){
if (device.currentValue("thermostatMode") == "heat") {
heatingSetpointDown()
} else {
log.debug ("temperature setpoint not supported in the current thermostat mode")
}
}
def heatingSetpointUp(){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if ((device.currentValue("thermostatSetpoint").toInteger() - 1 ) < state.MinHeatTemp){
log.debug("cannot decrease heat setpoint, its already at the minimum level of " + state.MinHeatTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() + 1
log.debug "Setting heatingSetpoint up to: ${newSetpoint}"
setHeatingSetpoint(newSetpoint)
}
}
def heatingSetpointDown(){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if ((device.currentValue("thermostatSetpoint").toInteger() + 1 ) > state.MaxHeatTemp){
log.debug("cannot increase heat setpoint, its already at the maximum level of " + state.MaxHeatTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() - 1
log.debug "Setting heatingSetpoint down to: ${newSetpoint}"
setHeatingSetpoint(newSetpoint)
}
}
// Commands to device
def heat(){
parent.heatCommand(this)
parent.statusCommand(this)
}
def emergencyHeat(){
parent.emergencyHeat(this)
}
def endManualControl(){
parent.endManualControl(this)
}

View File

@@ -1,174 +0,0 @@
/**
* Copyright 2015 Stuart Buchanan
*
* 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.
*
* Tado Thermostat
*
* Author: Stuart Buchanan, Based on original work by Ian M with thanks
* Date: 2015-04-28 v1.3 changed Presence tile as this was reporting a bug
* Date: 2015-04-28 v1.2 updated API call found issue where session was closed and nothing else was returned, now add number generator to input noCache statement in the query
* Date: 2015-04-27 v1.1 updated API call and added refresh function
* Date: 2015-12-04 v1.0 Initial Release
*/
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
import java.util.Random
preferences {
input("username", "text", title: "Username", description: "Your Tado username")
input("password", "password", title: "Password", description: "Your Tado password")
input("tadouser", "text", title: "Tado User", description: "Your Tado User")
}
metadata {
definition (name: "Tado Heating User Presence", namespace: "fuzzysb", author: "Stuart Buchanan") {
capability "Presence Sensor"
capability "Sensor"
capability "Polling"
capability "Refresh"
command "arrived"
command "departed"
}
// simulator metadata
simulator {
status "present": "presence: present"
status "not present": "presence: not present"
}
tiles {
standardTile("presence", "device.presence", width: 2, height: 2, canChangeBackground: true) {
state("present", labelIcon:"st.presence.tile.mobile-present", backgroundColor:"#53a7c0")
state("not present", labelIcon:"st.presence.tile.mobile-not-present", backgroundColor:"#ffffff")
}
standardTile("refresh", "device.refresh", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
main "presence"
details (["presence","refresh"])
}
}
// Parse incoming device messages to generate events
private parseResponse(resp) {
def result
log.debug("Executing parseResponse: "+resp.data)
log.debug("Output status: "+resp.status)
if(resp.status == 200) {
log.debug("Executing parseResponse.successTrue")
def evtJson = new groovy.json.JsonOutput().toJson(resp.data)
def json = new JsonSlurper().parseText(evtJson)
def appuserarray = new groovy.json.JsonOutput().toJson(json.appUsers)
def list = new JsonSlurper().parseText(appuserarray)
list.each {
if ((it.nickname).capitalize() == (settings.tadouser).capitalize()) {
log.debug("Found Tado User : " + it.nickname)
if (it.geoTrackingEnabled == true) {
log.debug("Users GeoTracking is Enabled")
if (it.geolocationIsStale == false){
log.debug("Users Current Relative Position is : " + it.relativePosition )
if (it.relativePosition == 0) {
result = arrived()
}else{
result = departed()
}
}else{
log.debug("Geolocation is Stale Skipping")
}
}else{
log.debug("Users GeoTracking Not Enabled")
}
}
}
}else if(resp.status == 201){
log.debug("Something was created/updated")
}
return result
}
def installed() {
log.debug "Executing 'installed'"
statusCommand()
}
def updated() {
log.debug "Executing 'updated'"
statusCommand()
}
def poll() {
log.debug "Executing 'poll'"
refresh()
}
def refresh() {
log.debug "Executing 'refresh'"
statusCommand()
}
private sendCommand(method, args = []) {
def methods = [
'status': [
uri: "https://my.tado.com",
path: "/mobile/1.6/getAppUsersRelativePositions",
requestContentType: "application/json",
query: [username:settings.username, password:settings.password, noCache:args[0], webapp:1]
],
]
def request = methods.getAt(method)
log.debug "Http Params ("+request+")"
try{
log.debug "Executing 'sendCommand'"
if (method == "status"){
httpGet(request) { resp ->
parseResponse(resp)
}
}else{
httpGet(request)
}
} catch(Exception e){
log.debug("___exception: " + e)
}
}
// Commands
def statusCommand(){
log.debug "Executing 'sendCommand.statusCommand'"
Random rand = new Random()
int min = 10000
int max = 99999
int randomNum = rand.nextInt((max - min) + 1) + min
sendCommand("status",[randomNum])
}
def arrived() {
log.trace "Executing 'arrived'"
def result = sendEvent(name: "presence", value: "present")
return result
}
def departed() {
log.trace "Executing 'departed'"
def result = sendEvent(name: "presence", value: "not present")
return result
}

View File

@@ -1,280 +0,0 @@
/**
* Copyright 2015 SmartThings
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
* Tado Thermostat
*
* Author: Stuart Buchanan, Based on original work by Ian M with thanks. also source for icons was from @tonesto7's excellent Nest Manager.
* Date: 2016-11-28 v1.6 Moved all data collection functions into Tado (Connect) SmartApp, huge changes to device handler, existing devices and handler will need to be uninstalled before installing this version
* Date: 2016-07-13 v1.5 Quick dirty workaround to control zones with a single account.
* Date: 2016-04-25 v1.4 Tado Hot water does not actually return the current water temps, it only returns the Current set point temp. to get around this when the power is on for the hot water botht the temp and setpoint will both display the setpoint value, otherwise will display --
* Date: 2016-04-25 v1.3 Finally found time to update this with the lessons learnt from the Tado Cooling Device Type. will bring better support for RM and Thermostat Director
* Date: 2016-04-08 v1.2 added setThermostatMode(mode) function to work better with Rule Machine and Thermostat Mode Director
* Date: 2016-04-05 v1.1 change of default Water Heating Temps can now be defined in device preferences (default Value is 90C).
* Date: 2016-04-05 v1.0 Initial release
*/
preferences {
input("username", "text", title: "Username", description: "Your Tado username")
input("password", "password", title: "Password", description: "Your Tado password")
input("tadoZoneId", "number", title: "Enter Tado Zone ID?", required: true)
input("manualmode", "enum", title: "Default Manual Overide Method", options: ["TADO_MODE","MANUAL"], required: false, defaultValue:"TADO_MODE")
input("defWaterTemp", "number", title: "Default Water Heating Temperature", required: false, defaultValue: 90)
}
metadata {
definition (name: "Tado Hot Water Control", namespace: "fuzzysb", author: "Stuart Buchanan") {
capability "Actuator"
capability "Temperature Measurement"
capability "Thermostat Heating Setpoint"
capability "Thermostat Setpoint"
capability "Thermostat Mode"
capability "Thermostat Operating State"
capability "Thermostat"
capability "Polling"
capability "Refresh"
attribute "tadoMode", "string"
command "temperatureUp"
command "temperatureDown"
command "heatingSetpointUp"
command "heatingSetpointDown"
command "on"
command "endManualControl"
command "emergencyHeat"
}
// simulator metadata
simulator {
// status messages
// reply messages
}
tiles(scale: 2){
multiAttributeTile(name: "thermostat", type:"thermostat", width:6, height:4) {
tileAttribute("device.temperature", key:"PRIMARY_CONTROL", canChangeIcon: true, canChangeBackground: true){
attributeState "default", label:'${currentValue}°', backgroundColor:"#fab907", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/tap_icon.png"
}
tileAttribute("device.temperature", key: "VALUE_CONTROL") {
attributeState("VALUE_UP", action: "temperatureUp")
attributeState("VALUE_DOWN", action: "temperatureDown")
}
tileAttribute("device.thermostatOperatingState", key: "OPERATING_STATE") {
attributeState("idle", backgroundColor:"#666666")
attributeState("heating", backgroundColor:"#ff471a")
attributeState("emergency heat", backgroundColor:"#ff471a")
}
tileAttribute("device.thermostatMode", key: "THERMOSTAT_MODE") {
attributeState("off", label:'${name}')
attributeState("heat", label:'${name}')
}
tileAttribute("device.heatingSetpoint", key: "HEATING_SETPOINT") {
attributeState("default", label:'${currentValue}', unit:"dF")
}
}
valueTile("heatingSetpoint", "device.heatingSetpoint", width: 2, height: 1, decoration: "flat") {
state "default", label: 'Set Point\r\n\${currentValue}°'
}
standardTile("tadoMode", "device.tadoMode", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state("SLEEP", label:'${name}', backgroundColor:"#0164a8", icon:"st.Bedroom.bedroom2")
state("HOME", label:'${name}', backgroundColor:"#fab907", icon:"st.Home.home2")
state("AWAY", label:'${name}', backgroundColor:"#62aa12", icon:"st.Outdoor.outdoor18")
state("OFF", label:'', backgroundColor:"#ffffff", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/hvac_off.png", defaultState: true)
state("MANUAL", label:'${name}', backgroundColor:"#804000", icon:"st.Weather.weather1")
}
standardTile("thermostatMode", "device.thermostatMode", width: 2, height: 2, canChangeIcon: true, canChangeBackground: true) {
state("heat", label:'HEAT', backgroundColor:"#ea2a2a", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/heat_mode_icon.png")
state("off", label:'', backgroundColor:"#ffffff", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/hvac_off.png", defaultState: true)
}
standardTile("refresh", "device.switch", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"refresh.refresh", icon:"st.secondary.refresh"
}
standardTile("Off", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.off", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/hvac_off.png"
}
standardTile("emergencyHeat", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.emergencyHeat", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/emergencyHeat.png"
}
valueTile("outsidetemperature", "device.outsidetemperature", width: 2, height: 1, decoration: "flat") {
state "outsidetemperature", label: 'Outside Temp\r\n${currentValue}°'
}
standardTile("heat", "device.thermostat", width: 2, height: 1, decoration: "flat") {
state "default", label:"", action:"thermostat.heat", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/hvac_heat.png"
}
standardTile("heatingSetpointUp", "device.heatingSetpoint", width: 1, height: 1, canChangeIcon: false, decoration: "flat") {
state "heatingSetpointUp", label:'', action:"heatingSetpointUp", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/heat_arrow_up.png"
}
standardTile("heatingSetpointDown", "device.heatingSetpoint", width: 1, height: 1, canChangeIcon: false, decoration: "flat") {
state "heatingSetpointDown", label:'', action:"heatingSetpointDown", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/heat_arrow_down.png"
}
standardTile("endManualControl", "device.thermostat", width: 2, height: 1, canChangeIcon: false, canChangeBackground: true, decoration: "flat") {
state("default", label:'', action:"endManualControl", icon:"https://raw.githubusercontent.com/fuzzysb/SmartThings/master/DeviceTypes/fuzzysb/tado.Hot.Water.src/Images/endManual.png")
}
main "thermostat"
details (["thermostat","thermostatMode","outsidetemperature","heatingSetpoint","refresh","heatingSetpointUp","heatingSetpointDown","tadoMode","emergencyHeat","heat","Off","endManualControl"])
}
}
def getWeather(){
parent.weatherStatusCommand(this)
}
def setCapabilitySupportsWater(value){
state.supportsWater = value
log.debug("state.supportsWater = ${state.supportsWater}")
}
def getCapabilitySupportsWater() {
def map = null
map = [name: "capabilitySupportsWater", value: state.supportsWater]
return map
}
def setCapabilitySupportsWaterTempControl(value){
state.supportsWaterTempControl = value
log.debug("state.supportsWaterTempControl = ${state.supportsWaterTempControl}")
}
def getCapabilitySupportsWaterTempControl() {
def map = null
map = [name: "capabilitySupportsWaterTempControl", value: state.supportsWaterTempControl]
return map
}
def updated(){
refresh()
}
def installed(){
refresh()
}
def poll() {
log.debug "Executing 'poll'"
refresh()
}
def refresh() {
log.debug "Executing 'refresh'"
parent.statusCommand(this)
getWeather()
}
def auto() {
log.debug "Executing 'auto'"
parent.autoCommand(this)
parent.statusCommand(this)
}
def on() {
log.debug "Executing 'on'"
onCommand()
statusCommand()
}
def off() {
log.debug "Executing 'off'"
offCommand()
statusCommand()
}
def setHeatingSetpoint(targetTemperature) {
log.debug "Executing 'setHeatingSetpoint'"
log.debug "Target Temperature ${targetTemperature}"
setHeatingTempCommand(targetTemperature)
statusCommand()
}
def temperatureUp(){
if (device.currentValue("thermostatMode") == "heat") {
heatingSetpointUp()
} else {
log.debug ("temperature setpoint not supported in the current thermostat mode")
}
}
def temperatureDown(){
if (device.currentValue("thermostatMode") == "heat") {
heatingSetpointDown()
} else {
log.debug ("temperature setpoint not supported in the current thermostat mode")
}
}
def heatingSetpointUp(){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if(state.supportsWaterTempControl == "true"){
if ((device.currentValue("thermostatSetpoint").toInteger() - 1 ) < state.MinHeatTemp){
log.debug("cannot decrease heat setpoint, its already at the minimum level of " + state.MinHeatTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() + 1
log.debug "Setting heatingSetpoint up to: ${newSetpoint}"
setHeatingSetpoint(newSetpoint)
statusCommand()
}
} else {
log.debug "Hot Water Temperature Capability Not Supported"
}
}
def heatingSetpointDown(){
log.debug "Current SetPoint Is " + (device.currentValue("thermostatSetpoint")).toString()
if(state.supportsWaterTempControl == "true"){
if ((device.currentValue("thermostatSetpoint").toInteger() + 1 ) > state.MaxHeatTemp){
log.debug("cannot increase heat setpoint, its already at the maximum level of " + state.MaxHeatTemp)
} else {
int newSetpoint = (device.currentValue("thermostatSetpoint")).toInteger() - 1
log.debug "Setting heatingSetpoint down to: ${newSetpoint}"
setHeatingSetpoint(newSetpoint)
statusCommand()
}
} else {
log.debug "Hot Water Temperature Capability Not Supported"
}
}
// Commands to device
def setThermostatMode(requiredMode){
switch (requiredMode) {
case "heat":
heat()
break
case "auto":
auto()
break
case "off":
off()
break
case "emergency heat":
emergencyHeat()
break
}
}
def heat(){
parent.heatCommand(this)
parent.statusCommand(this)
}
def emergencyHeat(){
parent.emergencyHeat(this)
}
def endManualControl(){
parent.endManualControl(this)
}

View File

@@ -120,15 +120,6 @@ def configure() {
return cmd
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -109,15 +109,6 @@ def configure() {
return cmds
}
def installed() {
initialize()
}
def updated() {
initialize()
}
def initialize() {
sendEvent(name: "numberOfButtons", value: 4)
}

View File

@@ -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}"
}

View File

@@ -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)
}

View File

@@ -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

View File

@@ -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"
}
}

View File

@@ -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

View File

@@ -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)
}

View File

@@ -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) {

View File

@@ -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

View File

@@ -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

View File

@@ -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) {

View File

@@ -127,8 +127,8 @@ def configureHealthCheck() {
def configure() {
log.debug "configure()"
configureHealthCheck()
zigbee.onOffConfig() + zigbee.levelConfig() + zigbee.onOffRefresh() + zigbee.levelRefresh()
configureHealthCheck()
}
def updated() {

View File

@@ -27,10 +27,6 @@ metadata {
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300", outClusters: "0019"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 RGBW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 RGBW"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "PAR 16 50 RGBW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY RGBW PAR 16 50"
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Flex RGBW"
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Gardenpole RGBW-Lightify", deviceJoinName: "OSRAM LIGHTIFY Gardenpole RGBW"
fingerprint profileId: "C05E", inClusters: "0000,0003,0004,0005,0006,0008,0300,1000,FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "LIGHTIFY Outdoor Flex RGBW", deviceJoinName: "OSRAM LIGHTIFY Outdoor Flex RGBW"
}
// UI tile definitions

View File

@@ -32,7 +32,6 @@ metadata {
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"Classic A60 TW", deviceJoinName: "OSRAM LIGHTIFY LED Classic A60 Tunable White"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, FC0F", outClusters: "0019", "manufacturer":"OSRAM", "model":"PAR16 50 TW", deviceJoinName: "OSRAM LIGHTIFY LED PAR16 50 Tunable White"
fingerprint profileId: "C05E", inClusters: "0000, 0003, 0004, 0005, 0006, 0008, 0300, 1000, 0B04, FC0F", outClusters: "0019", manufacturer: "OSRAM", model: "Classic B40 TW - LIGHTIFY", deviceJoinName: "OSRAM LIGHTIFY Classic B40 Tunable White"
}
// UI tile definitions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,662 @@
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.security.InvalidKeyException;
/**
* OpenT2T SmartApp Test
*
* Copyright 2016 OpenT2T
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License
* for the specific language governing permissions and limitations under the License.
*
*/
definition(
name: "OpenT2T SmartApp Test",
namespace: "opent2t",
author: "OpenT2T",
description: "Test app to test end to end SmartThings scenarios via OpenT2T",
category: "SmartThings Labs",
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")
/** --------------------+---------------+-----------------------+------------------------------------
* Device Type | Attribute Name| Commands | Attribute Values
* --------------------+---------------+-----------------------+------------------------------------
* switches | switch | on, off | on, off
* motionSensors | motion | | active, inactive
* contactSensors | contact | | open, closed
* presenceSensors | presence | | present, 'not present'
* temperatureSensors | temperature | | <numeric, F or C according to unit>
* accelerationSensors | acceleration | | active, inactive
* waterSensors | water | | wet, dry
* lightSensors | illuminance | | <numeric, lux>
* humiditySensors | humidity | | <numeric, percent>
* locks | lock | lock, unlock | locked, unlocked
* garageDoors | door | open, close | unknown, closed, open, closing, opening
* cameras | image | take | <String>
* thermostats | thermostat | setHeatingSetpoint, | temperature, heatingSetpoint, coolingSetpoint,
* | | setCoolingSetpoint, | thermostatSetpoint, thermostatMode,
* | | off, heat, cool, auto,| thermostatFanMode, thermostatOperatingState
* | | emergencyHeat, |
* | | setThermostatMode, |
* | | fanOn, fanAuto, |
* | | fanCirculate, |
* | | setThermostatFanMode |
* --------------------+---------------+-----------------------+------------------------------------
*/
//Device Inputs
preferences {
section("Allow OpenT2T to control these things...") {
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 "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 "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 "switches", "capability.switch", title: "Which Switches and Lights?", multiple: true, required: false, hideWhenEmpty: true
input "thermostats", "capability.thermostat", title: "Which Thermostat?", multiple: true, required: false, hideWhenEmpty: true
input "waterSensors", "capability.waterSensor", title: "Which Water Leak Sensors?", multiple: true, required: false, hideWhenEmpty: true
}
}
def getInputs() {
def inputList = []
inputList += contactSensors?: []
inputList += garageDoors?: []
inputList += locks?: []
inputList += cameras?: []
inputList += motionSensors?: []
inputList += presenceSensors?: []
inputList += switches?: []
inputList += thermostats?: []
inputList += waterSensors?: []
return inputList
}
//API external Endpoints
mappings {
path("/devices") {
action: [
GET: "getDevices"
]
}
path("/devices/:id") {
action: [
GET: "getDevice"
]
}
path("/update/:id") {
action: [
PUT: "updateDevice"
]
}
path("/deviceSubscription") {
action: [
POST: "registerDeviceChange",
DELETE: "unregisterDeviceChange"
]
}
path("/locationSubscription") {
action: [
POST: "registerDeviceGraph",
DELETE: "unregisterDeviceGraph"
]
}
}
def installed() {
log.debug "Installing with settings: ${settings}"
initialize()
}
def updated() {
log.debug "Updating with settings: ${settings}"
//Initialize state variables if didn't exist.
if( state.deviceSubscriptionMap == null ){
state.deviceSubscriptionMap = [:]
log.debug "deviceSubscriptionMap created."
}
if( state.locationSubscriptionMap == null ){
state.locationSubscriptionMap = [:]
log.debug "locationSubscriptionMap created."
}
if(state.verificationKeyMap == null){
state.verificationKeyMap = [:]
log.debug "verificationKeyMap created."
}
unsubscribe()
registerAllDeviceSubscriptions()
}
def initialize() {
log.debug "Initializing with settings: ${settings}"
state.deviceSubscriptionMap = [:]
log.debug "deviceSubscriptionMap created."
state.locationSubscriptionMap = [:]
log.debug "locationSubscriptionMap created."
state.verificationKeyMap = [:]
log.debug "verificationKeyMap created."
registerAllDeviceSubscriptions()
}
/*** Subscription Functions ***/
//Subscribe events for all devices
def registerAllDeviceSubscriptions() {
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
def registerDeviceChange() {
def subscriptionEndpt = params.subscriptionURL
def deviceId = params.deviceId
def myDevice = findDevice(deviceId)
if( myDevice == null ){
httpError(404, "Cannot find device with device ID ${deviceId}.")
}
def theAtts = myDevice.supportedAttributes
try {
theAtts.each {att ->
subscribe(myDevice, att.name, deviceEventHandler)
}
log.info "Subscribing for ${myDevice.displayName}"
if(subscriptionEndpt != null){
if(state.deviceSubscriptionMap[deviceId] == null){
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
log.info "Added subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
} else if (!state.deviceSubscriptionMap[deviceId].contains(subscriptionEndpt)){
// state.deviceSubscriptionMap[deviceId] << subscriptionEndpt
// For now, we will only have one subscription endpoint per device
state.deviceSubscriptionMap.remove(deviceId)
state.deviceSubscriptionMap.put(deviceId, [subscriptionEndpt])
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) {
httpError(500, "something went wrong: $e")
}
log.info "Current subscription map is ${state.deviceSubscriptionMap}"
log.info "Current verification key map is ${state.verificationKeyMap}"
return ["succeed"]
}
//Endpoints function: Unsubscribe to events from a specific device
def unregisterDeviceChange() {
def subscriptionEndpt = params.subscriptionURL
def deviceId = params.deviceId
def myDevice = findDevice(deviceId)
if( myDevice == null ){
httpError(404, "Cannot find device with device ID ${deviceId}.")
}
try {
if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
if (state.deviceSubscriptionMap[deviceId]?.contains(subscriptionEndpt)){
if(state.deviceSubscriptionMap[deviceId].size() == 1){
state.deviceSubscriptionMap.remove(deviceId)
} else {
state.deviceSubscriptionMap[deviceId].remove(subscriptionEndpt)
}
state.verificationKeyMap.remove(subscriptionEndpt)
log.info "Removed subscription URL: ${subscriptionEndpt} for ${myDevice.displayName}"
}
} else {
state.deviceSubscriptionMap.remove(deviceId)
log.info "Unsubscriping for ${myDevice.displayName}"
}
} catch (e) {
httpError(500, "something went wrong: $e")
}
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
def registerDeviceGraph() {
def subscriptionEndpt = params.subscriptionURL
if (subscriptionEndpt != null && subscriptionEndpt != "undefined"){
subscribe(location, "DeviceCreated", locationEventHandler, [filterEvents: false])
subscribe(location, "DeviceUpdated", locationEventHandler, [filterEvents: false])
subscribe(location, "DeviceDeleted", locationEventHandler, [filterEvents: false])
if(state.locationSubscriptionMap[location.id] == null){
state.locationSubscriptionMap.put(location.id, [subscriptionEndpt])
log.info "Added subscription URL: ${subscriptionEndpt} for Location ${location.name}"
}else if (!state.locationSubscriptionMap[location.id].contains(subscriptionEndpt)){
state.locationSubscriptionMap[location.id] << subscriptionEndpt
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 verification key map is ${state.verificationKeyMap}"
return ["succeed"]
} else {
httpError(400, "missing input parameter: subscriptionURL")
}
}
//Endpoints function: Unsubscribe to events from a specific device
def unregisterDeviceGraph() {
def subscriptionEndpt = params.subscriptionURL
try {
if(subscriptionEndpt != null && subscriptionEndpt != "undefined"){
if (state.locationSubscriptionMap[location.id]?.contains(subscriptionEndpt)){
if(state.locationSubscriptionMap[location.id].size() == 1){
state.locationSubscriptionMap.remove(location.id)
} else {
state.locationSubscriptionMap[location.id].remove(subscriptionEndpt)
}
state.verificationKeyMap.remove(subscriptionEndpt)
log.info "Removed subscription URL: ${subscriptionEndpt} for Location ${location.name}"
}
}else{
httpError(400, "missing input parameter: subscriptionURL")
}
} catch (e) {
httpError(500, "something went wrong: $e")
}
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
def deviceEventHandler(evt) {
def evtDevice = evt.device
def evtDeviceType = getDeviceType(evtDevice)
def deviceData = [];
if(evt.data != null){
def evtData = parseJson(evt.data)
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
log.debug "Current subscription urls for ${evtDevice.displayName} is ${state.deviceSubscriptionMap[evtDevice.id]}"
state.deviceSubscriptionMap[evtDevice.id].each {
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 "Header: ${params.header}"
log.trace "Payload: ${params.body}"
try{
httpPostJson(params) { resp ->
log.trace "response status code: ${resp.status}"
log.trace "response data: ${resp.data}"
}
} catch (e) {
log.error "something went wrong: $e"
}
}
}
def locationEventHandler(evt) {
log.info "Received event for location ${location.name}/${location.id}, Event: ${evt.name}, description: ${evt.descriptionText}, apiServerUrl: ${apiServerUrl("")}"
switch(evt.name){
case "DeviceCreated":
case "DeviceDeleted":
def evtDevice = evt.device
def evtDeviceType = getDeviceType(evtDevice)
def params = [ body: [ eventType:evt.name, deviceId: evtDevice.id, locationId: location.id ] ]
if (evt.name == "DeviceDeleted" && state.deviceSubscriptionMap[deviceId] != null){
state.deviceSubscriptionMap.remove(evtDevice.id)
}
state.locationSubscriptionMap[location.id].each {
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 "Header: ${params.header}"
log.trace "Payload: ${params.body}"
try{
httpPostJson(params) { resp ->
log.trace "response status code: ${resp.status}"
log.trace "response data: ${resp.data}"
}
} catch (e) {
log.error "something went wrong: $e"
}
}
case "DeviceUpdated":
default:
break
}
}
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 ***/
//Endpoints function: return all device data in json format
def getDevices() {
def deviceData = []
inputs?.each {
def deviceType = getDeviceType(it)
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()]
} else {
deviceData << [name: it.displayName, id: it.id, status:it.status, deviceType:deviceType, manufacturer:it.manufacturerName, model:it.modelName, attributes: deviceAttributeList(it, deviceType)]
}
}
log.debug "getDevices, return: ${deviceData}"
return deviceData
}
//Endpoints function: get device data
def getDevice() {
def it = findDevice(params.id)
def deviceType = getDeviceType(it)
def device
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()]
} else {
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}"
return device
}
//Endpoints function: update device data
void updateDevice() {
def device = findDevice(params.id)
request.JSON.each {
def command = it.key
def value = it.value
if (command){
def commandList = mapDeviceCommands(command, value)
command = commandList[0]
value = commandList[1]
if (command == "setAwayMode") {
log.info "Setting away mode to ${value}"
if (location.modes?.find {it.name == value}) {
location.setMode(value)
}
}else if (command == "thermostatSetpoint"){
switch(device.currentThermostatMode){
case "cool":
log.info "Update: ${device.displayName}, [${command}, ${value}]"
device.setCoolingSetpoint(value)
break
case "heat":
case "emergency heat":
log.info "Update: ${device.displayName}, [${command}, ${value}]"
device.setHeatingSetpoint(value)
break
default:
httpError(501, "this mode: ${device.currentThermostatMode} does not allow changing thermostat setpoint.")
break
}
}else if (!device) {
log.error "updateDevice, Device not found"
httpError(404, "Device not found")
} else if (!device.hasCommand(command)) {
log.error "updateDevice, Device does not have the command"
httpError(404, "Device does not have such command")
} else {
if (command == "setColor") {
log.info "Update: ${device.displayName}, [${command}, ${value}]"
device."$command"(hex: value)
} else if(value.isNumber()) {
def intValue = value as Integer
log.info "Update: ${device.displayName}, [${command}, ${intValue}(int)]"
device."$command"(intValue)
} else if (value){
log.info "Update: ${device.displayName}, [${command}, ${value}]"
device."$command"(value)
} else {
log.info "Update: ${device.displayName}, [${command}]"
device."$command"()
}
}
}
}
}
/*** Private Functions ***/
//Return current location mode info
private getLocationModeInfo() {
return [mode: location.mode, supported: location.modes.name]
}
//Map each device to a type given it's capabilities
private getDeviceType(device) {
def deviceType
def capabilities = device.capabilities
log.debug "capabilities: [${device}, ${capabilities}]"
log.debug "supported commands: [${device}, ${device.supportedCommands}]"
//Loop through the device capability list to determine the device type.
capabilities.each {capability ->
switch(capability.name.toLowerCase())
{
case "switch":
deviceType = "switch"
//If the device also contains "Switch Level" capability, identify it as a "light" device.
if (capabilities.any{it.name.toLowerCase() == "switch level"}){
//If the device also contains "Power Meter" capability, identify it as a "dimmerSwitch" device.
if (capabilities.any{it.name.toLowerCase() == "power meter"}){
deviceType = "dimmerSwitch"
return deviceType
} else {
deviceType = "light"
return deviceType
}
}
break
case "garageDoorControl":
deviceType = "garageDoor"
return deviceType
case "lock":
deviceType = "lock"
return deviceType
case "video camera":
deviceType = "camera"
return deviceType
case "thermostat":
deviceType = "thermostat"
return deviceType
case "acceleration sensor":
case "contact sensor":
case "motion sensor":
case "presence sensor":
case "water sensor":
deviceType = "genericSensor"
return deviceType
default:
break
}
}
return deviceType
}
//Return a specific device give the device ID.
private findDevice(deviceId) {
return inputs?.find { it.id == deviceId }
}
//Return a list of device attributes
private deviceAttributeList(device, deviceType) {
def attributeList = [:]
def allAttributes = device.supportedAttributes
allAttributes.each { attribute ->
try {
def currentState = device.currentState(attribute.name)
if(currentState != null ){
switch(attribute.name){
case 'temperature':
attributeList.putAll([ (attribute.name): currentState.value, 'temperatureScale':location.temperatureScale ])
break;
default:
attributeList.putAll([(attribute.name): currentState.value ])
break;
}
if( deviceType == "genericSensor" ){
def key = attribute.name + "_lastUpdated"
attributeList.putAll([ (key): currentState.isoDate ])
}
} else {
attributeList.putAll([ (attribute.name): null ]);
}
} catch(e) {
attributeList.putAll([ (attribute.name): null ]);
}
}
return attributeList
}
//Map device command and value.
//input command and value are from UWP,
//returns resultCommand and resultValue that corresponds with function and value in SmartApps
private mapDeviceCommands(command, value) {
log.debug "mapDeviceCommands: [${command}, ${value}]"
def resultCommand = command
def resultValue = value
switch (command) {
case "switch":
if (value == 1 || value == "1" || value == "on") {
resultCommand = "on"
resultValue = ""
} else if (value == 0 || value == "0" || value == "off") {
resultCommand = "off"
resultValue = ""
}
break
// light attributes
case "level":
resultCommand = "setLevel"
resultValue = value
break
case "hue":
resultCommand = "setHue"
resultValue = value
break
case "saturation":
resultCommand = "setSaturation"
resultValue = value
break
case "colorTemperature":
resultCommand = "setColorTemperature"
resultValue = value
break
case "color":
resultCommand = "setColor"
resultValue = value
// thermostat attributes
case "hvacMode":
resultCommand = "setThermostatMode"
resultValue = value
break
case "fanMode":
resultCommand = "setThermostatFanMode"
resultValue = value
break
case "awayMode":
resultCommand = "setAwayMode"
resultValue = value
break
case "coolingSetpoint":
resultCommand = "setCoolingSetpoint"
resultValue = value
break
case "heatingSetpoint":
resultCommand = "setHeatingSetpoint"
resultValue = value
break
case "thermostatSetpoint":
resultCommand = "thermostatSetpoint"
resultValue = value
break
// lock attributes
case "locked":
if (value == 1 || value == "1" || value == "lock") {
resultCommand = "lock"
resultValue = ""
}
else if (value == 0 || value == "0" || value == "unlock") {
resultCommand = "unlock"
resultValue = ""
}
break
default:
break
}
return [resultCommand,resultValue]
}

View File

@@ -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"
}