Compare commits

..

2 Commits

18 changed files with 2963 additions and 107 deletions

View File

@@ -0,0 +1,600 @@
/**
* 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

@@ -0,0 +1,270 @@
/**
* 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

@@ -0,0 +1,174 @@
/**
* 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

@@ -0,0 +1,280 @@
/**
* 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

@@ -99,7 +99,7 @@ def parse(String description) {
def poll() {
def refreshCmds = [
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 2000"
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 500"
]
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh()
@@ -197,7 +197,7 @@ def off() {
def refresh() {
def refreshCmds = [
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 2000"
"st wattr 0x${device.deviceNetworkId} 1 8 0x10 0x21 {${state?.dOnOff ?: '0000'}}", "delay 500"
]
return refreshCmds + zigbee.onOffRefresh() + zigbee.levelRefresh() + zigbee.onOffConfig()

View File

@@ -39,7 +39,7 @@ metadata {
}
def generatePresenceEvent(boolean present) {
log.info "Life360 generatePresenceEvent($present)"
log.debug "Here in generatePresenceEvent!"
def value = formatValue(present)
def linkText = getLinkText(device)
def descriptionText = formatDescriptionText(linkText, present)

View File

@@ -128,9 +128,9 @@ def setLevel(value) {
def refresh() {
[
"st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 2000",
"st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 2000",
"st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0B04 0x050B", "delay 2000"
"st rattr 0x${device.deviceNetworkId} ${endpointId} 6 0", "delay 500",
"st rattr 0x${device.deviceNetworkId} ${endpointId} 8 0", "delay 500",
"st rattr 0x${device.deviceNetworkId} ${endpointId} 0x0B04 0x050B", "delay 500"
]
}
@@ -313,9 +313,9 @@ def isDescriptionPower(descMap) {
def onOffConfig() {
[
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 6 {${device.zigbeeId}} {}", "delay 2000",
"zcl global send-me-a-report 6 0 0x10 0 600 {01}", "delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 6 {${device.zigbeeId}} {}", "delay 200",
"zcl global send-me-a-report 6 0 0x10 0 600 {01}",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 1500"
]
}
@@ -323,9 +323,9 @@ def onOffConfig() {
//min level change is 01
def levelConfig() {
[
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 8 {${device.zigbeeId}} {}", "delay 2000",
"zcl global send-me-a-report 8 0 0x20 5 3600 {01}", "delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 8 {${device.zigbeeId}} {}", "delay 200",
"zcl global send-me-a-report 8 0 0x20 5 3600 {01}",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 1500"
]
}
@@ -333,10 +333,9 @@ def levelConfig() {
//min change in value is 05
def powerConfig() {
[
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 2000",
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 200",
"zcl global send-me-a-report 0x0B04 0x050B 0x29 1 600 {05 00}", //The send-me-a-report is custom to the attribute type for CentraLite
"delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500"
]
}
@@ -345,10 +344,7 @@ def setLevelWithRate(level, rate) {
rate = "0000"
}
level = convertToHexString(level * 255 / 100) //Converting the 0-100 range to 0-FF range in hex
[
"st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {$level $rate}",
"delay 2000"
]
"st cmd 0x${device.deviceNetworkId} ${endpointId} 8 4 {$level $rate}"
}
String convertToHexString(value, width=2) {

View File

@@ -51,7 +51,7 @@ def on() {
'zcl on-off on',
'delay 200',
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
'delay 2000'
'delay 500'
]
@@ -62,6 +62,6 @@ def off() {
'zcl on-off off',
'delay 200',
"send 0x${zigbee.deviceNetworkId} 0x01 0x${zigbee.endpointId}",
'delay 2000'
'delay 500'
]
}

View File

@@ -157,10 +157,9 @@ def configure() {
//min change in value is 01
def powerConfig() {
[
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 2000",
"zdo bind 0x${device.deviceNetworkId} 1 ${endpointId} 0x0B04 {${device.zigbeeId}} {}", "delay 200",
"zcl global send-me-a-report 0x0B04 0x050B 0x29 1 600 {05 00}", //The send-me-a-report is custom to the attribute type for CentraLite
"delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000"
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500"
]
}

View File

@@ -29,10 +29,9 @@ metadata {
command "enrollResponse"
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-S", deviceJoinName: "Water Leak Sensor"
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315"
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-Seu", deviceJoinName: "Water Leak Sensor"
fingerprint inClusters: "0000,0001,0003,0020,0402,0500,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-L", deviceJoinName: "Iris Smart Water Sensor"
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-S", deviceJoinName: "Water Leak Sensor"
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315"
fingerprint inClusters: "0000,0001,0003,0402,0500,0020,0B05", outClusters: "0019", manufacturer: "CentraLite", model: "3315-Seu", deviceJoinName: "Water Leak Sensor"
fingerprint inClusters: "0000,0001,0003,000F,0020,0402,0500", outClusters: "0019", manufacturer: "SmartThings", model: "moisturev4", deviceJoinName: "Water Leak Sensor"
}
@@ -129,7 +128,7 @@ private Map parseCatchAllMessage(String description) {
if (cluster.command == 0x07) {
if (cluster.data[0] == 0x00){
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
@@ -286,8 +285,8 @@ def ping() {
def refresh() {
log.debug "Refreshing Temperature and Battery"
def refreshCmds = [
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
]
return refreshCmds + enrollResponse()
@@ -309,10 +308,10 @@ def enrollResponse() {
[
//Resending the CIE in case the enroll request is sent before CIE is written
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
//Enroll Response
"raw 0x500 {01 23 00 00 00}", "delay 200",
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
"raw 0x500 {01 23 00 00 00}",
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
]
}

View File

@@ -132,7 +132,7 @@ private Map parseCatchAllMessage(String description) {
if (cluster.command == 0x07) {
if (cluster.data[0] == 0x00) {
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
@@ -298,8 +298,8 @@ def ping() {
def refresh() {
log.debug "refresh called"
def refreshCmds = [
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
]
return refreshCmds + enrollResponse()
@@ -321,10 +321,10 @@ def enrollResponse() {
[
//Resending the CIE in case the enroll request is sent before CIE is written
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
//Enroll Response
"raw 0x500 {01 23 00 00 00}", "delay 200",
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
"raw 0x500 {01 23 00 00 00}",
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
]
}

View File

@@ -161,7 +161,7 @@ private Map parseCatchAllMessage(String description) {
if (cluster.command == 0x07) {
if(cluster.data[0] == 0x00) {
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
@@ -339,7 +339,7 @@ private Map getContactResult(value) {
log.debug "Contact: ${device.displayName} value = ${value}"
def descriptionText = value == 'open' ? '{{ device.displayName }} was opened' : '{{ device.displayName }} was closed'
sendEvent(name: 'contact', value: value, descriptionText: descriptionText, displayed: false, translatable: true)
return [name: 'status', value: value, descriptionText: descriptionText, translatable: true]
sendEvent(name: 'status', value: value, descriptionText: descriptionText, translatable: true)
}
private getAccelerationResult(numValue) {
@@ -428,10 +428,10 @@ def enrollResponse() {
[
//Resending the CIE in case the enroll request is sent before CIE is written
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
//Enroll Response
"raw 0x500 {01 23 00 00 00}", "delay 200",
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
]
}

View File

@@ -119,7 +119,7 @@ private Map parseCatchAllMessage(String description) {
if (cluster.command == 0x07){
if (cluster.data[0] == 0x00) {
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
@@ -252,8 +252,8 @@ def ping() {
def refresh() {
log.debug "Refreshing Temperature and Battery"
def refreshCmds = [
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 2000",
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 2000"
"st rattr 0x${device.deviceNetworkId} 1 0x402 0", "delay 200",
"st rattr 0x${device.deviceNetworkId} 1 1 0x20", "delay 200"
]
return refreshCmds + enrollResponse()
@@ -277,10 +277,10 @@ def enrollResponse() {
[
//Resending the CIE in case the enroll request is sent before CIE is written
"zcl global write 0x500 0x10 0xf0 {${zigbeeEui}}", "delay 200",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 2000",
"send 0x${device.deviceNetworkId} 1 ${endpointId}", "delay 500",
//Enroll Response
"raw 0x500 {01 23 00 00 00}", "delay 200",
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
"raw 0x500 {01 23 00 00 00}",
"send 0x${device.deviceNetworkId} 1 1", "delay 200"
]
}

View File

@@ -103,7 +103,7 @@ private Map parseCatchAllMessage(String description) {
if (cluster.command == 0x07) {
if (cluster.data[0] == 0x00){
log.debug "TEMP REPORTING CONFIG RESPONSE" + cluster
resultMap = [name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID]]
sendEvent(name: "checkInterval", value: 60 * 12, displayed: false, data: [protocol: "zigbee", hubHardwareId: device.hub.hardwareID])
}
else {
log.warn "TEMP REPORTING CONFIG FAILED- error code:${cluster.data[0]}"
@@ -270,9 +270,9 @@ def configure() {
log.debug "Configuring Reporting and Bindings."
def humidityConfigCmds = [
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 2000",
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}", "delay 200",
"send 0x${device.deviceNetworkId} 1 1", "delay 2000"
"zdo bind 0x${device.deviceNetworkId} 1 1 0xFC45 {${device.zigbeeId}} {}", "delay 500",
"zcl global send-me-a-report 0xFC45 0 0x29 30 3600 {6400}",
"send 0x${device.deviceNetworkId} 1 1", "delay 500"
]
// temperature minReportTime 30 seconds, maxReportTime 5 min. Reporting interval if no activity

View File

@@ -28,8 +28,8 @@ metadata {
fingerprint inClusters: "0000, 0001, 0003, 0020, 0402, 0B05", outClusters: "0003, 0006, 0008, 0019", manufacturer: "OSRAM", model: "LIGHTIFY Dimming Switch", deviceJoinName: "OSRAM LIGHTIFY Dimming Switch"
//fingerprint inClusters: "0000, 0001, 0003, 0020, 0500", outClusters: "0003,0019", manufacturer: "CentraLite", model: "3455-L", deviceJoinName: "Iris Care Pendant"
fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0402, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model: "3460-L", deviceJoinName: "Iris Smart Button"
fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model:"3450-L", deviceJoinName: "Iris KeyFob"
//fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0402, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model: "3460-L", deviceJoinName: "Iris Smart Button"
//fingerprint inClusters: "0000, 0001, 0003, 0007, 0020, 0B05", outClusters: "0003, 0006, 0019", manufacturer: "CentraLite", model:"3450-L", deviceJoinName: "Iris KeyFob"
}
simulator {}

File diff suppressed because it is too large Load Diff

View File

@@ -1,11 +1,10 @@
/**
* Color Coordinator
* Version 1.1.1 - 11/9/16
* Version 1.1.0 - 11/9/16
* By Michael Struck
*
* 1.0.0 - Initial release
* 1.1.0 - Fixed issue where master can be part of slaves. This causes a loop that impacts SmartThings.
* 1.1.1 - Fix NPE being thrown for slave/master inputs being empty.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
@@ -34,17 +33,17 @@ preferences {
def mainPage() {
dynamicPage(name: "mainPage", title: "", install: true, uninstall: false) {
def masterInList = slaves?.id?.find{it==master?.id}
def masterInList = slaves.id.find{it==master.id}
if (masterInList) {
section ("**WARNING**"){
paragraph "You have included the Master Light in the Slave Group. This will cause a loop in execution. Please remove this device from the Slave Group.", image: "https://raw.githubusercontent.com/MichaelStruck/SmartThingsPublic/master/img/caution.png"
}
}
section("Master Light") {
input "master", "capability.colorControl", title: "Colored Light", required: true
input "master", "capability.colorControl", title: "Colored Light"
}
section("Lights that follow the master settings") {
input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: true, submitOnChange: true
input "slaves", "capability.colorControl", title: "Colored Lights", multiple: true, required: false, submitOnChange: true
}
section([mobileOnly:true], "Options") {
input "randomYes", "bool",title: "When Master Turned On, Randomize Color", defaultValue: false
@@ -82,44 +81,40 @@ def init() {
}
//-----------------------------------
def onOffHandler(evt){
if (slaves && master) {
if (!slaves?.id.find{it==master?.id}){
if (master?.currentValue("switch") == "on"){
if (randomYes) getRandomColorMaster()
else slaves?.on()
}
else {
slaves?.off()
}
}
if (!slaves.id.find{it==master.id}){
if (master.currentValue("switch") == "on"){
if (randomYes) getRandomColorMaster()
else slaves?.on()
}
else {
slaves?.off()
}
}
}
def colorHandler(evt) {
if (slaves && master) {
if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
log.debug "Changing Slave units H,S,L"
def dimLevel = master?.currentValue("level")
def hueLevel = master?.currentValue("hue")
def saturationLevel = master.currentValue("saturation")
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
slaves?.setColor(newValue)
try {
log.debug "Changing Slave color temp"
def tempLevel = master?.currentValue("colorTemperature")
slaves?.setColorTemperature(tempLevel)
}
catch (e){
log.debug "Color temp for master --"
}
}
if (!slaves.id.find{it==master.id} && master.currentValue("switch") == "on"){
log.debug "Changing Slave units H,S,L"
def dimLevel = master.currentValue("level")
def hueLevel = master.currentValue("hue")
def saturationLevel = master.currentValue("saturation")
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
slaves?.setColor(newValue)
try {
log.debug "Changing Slave color temp"
def tempLevel = master.currentValue("colorTemperature")
slaves?.setColorTemperature(tempLevel)
}
catch (e){
log.debug "Color temp for master --"
}
}
}
def getRandomColorMaster(){
def hueLevel = Math.floor(Math.random() *1000)
def saturationLevel = Math.floor(Math.random() * 100)
def dimLevel = master?.currentValue("level")
def dimLevel = master.currentValue("level")
def newValue = [hue: hueLevel, saturation: saturationLevel, level: dimLevel as Integer]
log.debug hueLevel
log.debug saturationLevel
@@ -128,14 +123,12 @@ def getRandomColorMaster(){
}
def tempHandler(evt){
if (slaves && master) {
if (!slaves?.id?.find{it==master?.id} && master?.currentValue("switch") == "on"){
if (evt.value != "--") {
log.debug "Changing Slave color temp based on Master change"
def tempLevel = master.currentValue("colorTemperature")
slaves?.setColorTemperature(tempLevel)
}
}
if (!slaves.id.find{it==master.id} && master.currentValue("switch") == "on"){
if (evt.value != "--") {
log.debug "Changing Slave color temp based on Master change"
def tempLevel = master.currentValue("colorTemperature")
slaves?.setColorTemperature(tempLevel)
}
}
}
@@ -146,7 +139,7 @@ private def textAppName() {
}
private def textVersion() {
def text = "Version 1.1.1 (12/13/2016)"
def text = "Version 1.1.0 (11/09/2016)"
}
private def textCopyright() {
@@ -173,4 +166,4 @@ private def textHelp() {
"This application will allow you to control the settings of multiple colored lights with one control. " +
"Simply choose a master control light, and then choose the lights that will follow the settings of the master, "+
"including on/off conditions, hue, saturation, level and color temperature. Also includes a random color feature."
}
}

View File

@@ -289,12 +289,12 @@ def initializeLife360Connection() {
state.life360AccessToken = result.data.access_token
return true;
}
log.info "Life360 initializeLife360Connection, response=${result.data}"
log.debug "Response=${result.data}"
return false;
}
catch (e) {
log.error "Life360 initializeLife360Connection, error: $e"
log.debug e
return false;
}
@@ -656,7 +656,7 @@ def generateInitialEvent (member, childDevice) {
try { // we are going to just ignore any errors
log.info "Life360 generateInitialEvent($member, $childDevice)"
log.debug "Generate Initial Event for New Device for Member = ${member.id}"
def place = state.places.find{it.id==settings.place}
@@ -677,8 +677,6 @@ def generateInitialEvent (member, childDevice) {
// log.debug "Distance Away = ${distanceAway}"
boolean isPresent = (distanceAway <= placeRadius)
log.info "Life360 generateInitialEvent, member: ($memberLatitude, $memberLongitude), place: ($placeLatitude, $placeLongitude), radius: $placeRadius, dist: $distanceAway, present: $isPresent"
// log.debug "External Id=${app.id}:${member.id}"
@@ -720,7 +718,7 @@ def haversine(lat1, lon1, lat2, lon2) {
def placeEventHandler() {
log.info "Life360 placeEventHandler: params=$params, settings.place=$settings.place"
log.debug "In placeEventHandler method."
// the POST to this end-point will look like:
// POST http://test.com/webhook?circleId=XXXX&placeId=XXXX&userId=XXXX&direction=arrive
@@ -731,6 +729,8 @@ def placeEventHandler() {
def direction = params?.direction
def timestamp = params?.timestamp
log.debug "Life360 Event: Circle: ${circleId}, Place: ${placeId}, User: ${userId}, Direction: ${direction}"
if (placeId == settings.place) {
def presenceState = (direction=="in")
@@ -745,10 +745,10 @@ def placeEventHandler() {
if (deviceWrapper) {
deviceWrapper.generatePresenceEvent(presenceState)
log.debug "Life360 event raised on child device: ${externalId}"
log.debug "Event raised on child device: ${externalId}"
}
else {
log.warn "Life360 couldn't find child device associated with inbound Life360 event."
log.debug "Couldn't find child device associated with inbound Life360 event."
}
}