Hello there, I’m new here to Smartthings. I just read the documentation and now I want to make a Device Type Handler. Now I made a Device Handler with a GUI ( Tiles ) and on this GUI are two Buttons. One to increase the temperature and one to decrease. Now I made the functions ( tempup and tempdown ).
Now I got 2 Problems.
-
I included the Thermostat capability. I can change the Values of own created attributes by sendEvent on the installed method and then this value is shown in the smartthings app. But I can’t change the value of attributes that are already defined by the capability. For Example: thermostatSetpoint. Do I have to initialize these attributes I need of a capability first or how can I use them?
-
I can change the values of my own attributes on the installed method. But when I try to change the Value in another function like “tempup” or “tempdown”, the Value don’t change in the Smartthings app.
I hope you understand what I mean, otherwise just ask.
Hopefully someone can help me.
Code:
metadata {
definition (name: "SmartThermostatDeviceHandler", namespace: "Dany Van der Meij", author: "Dany Van der Meij") {
capability "thermostat"
attribute "ThermostatSetpoint", "Number"
attribute "ThermostatHumidity", "Number"
attribute "ThermostatAirquality", "Number"
command "tempUp"
command "tempDown"
}
simulator {
// TODO: define status and reply messages here
}
tiles (scale: 2) {
multiAttributeTile(name:"thermostatFull", type:"thermostat", width:6, height:4)
{
tileAttribute("device.ThermostatSetpoint", key: "PRIMARY_CONTROL") {
attributeState("temp", label:'${currentValue}', unit:"dF", defaultState: true)
}
tileAttribute("device.ThermostatSetpoint", key: "VALUE_CONTROL") {
attributeState("VALUE_UP", action: "device.tempUp")
attributeState("VALUE_DOWN", action: "device.tempDown")
}
tileAttribute("device.ThermostatHumidity", key: "SECONDARY_CONTROL") {
attributeState("humidity", label:'${currentValue}', unit:"%", defaultState: true)
}
tileAttribute("device.thermostatOperatingState", key: "OPERATING_STATE") {
attributeState("idle", backgroundColor:"#00A0DC")
attributeState("heating", backgroundColor:"#e86d13")
attributeState("cooling", backgroundColor:"#00A0DC")
}
tileAttribute("device.thermostatMode", key: "THERMOSTAT_MODE") {
attributeState("off", label:'${name}')
attributeState("heat", label:'${name}')
attributeState("cool", label:'${name}')
attributeState("auto", label:'${name}')
}
}
standardTile('temperatureTile', 'device.ThermostatSetpoint', defaultState: true, width: 2, height: 2, backgroundColor: "#e86d13")
{
state "ThermostatSetpoint", label: '${currentValue}'
}
standardTile('humidityTile', 'device.ThermostatHumidity', defaultState: true, width: 2, height: 2)
{
state "ThermostatHumidity", label: '${currentValue}'
}
standardTile('airqualityTile', 'device.ThermostatAirquality', defaultState: true, width: 2, height: 2)
{
state "ThermostatAirquality", label: '${currentValue}'
}
standardTile('thermostatmodeTile', 'device.thermostatSetpoint', defaultState: true, width: 2, height: 2)
{
state "thermostatSetpoint", label: '${currentValue}'
}
standardTile("refresh", "command.refresh", inactiveLabel: false, decoration: "flat", width: 2, height: 2)
{
state "default", label:'', action:"refresh.refresh", icon:"st.secondary.refresh"
}
main('thermostatFull')
details('thermostatFull','temperatureTile', 'humidityTile', 'airqualityTile', 'thermostatmodeTile', 'refresh')
}
}
def installed()
{
log.debug "Installed"
sendEvent(name: "ThermostatSetpoint", value: 20)
sendEvent(name:"ThermostatHumidity", value: 41)
sendEvent(name: "ThermostatAirquality", value: 400)
sendEvent(name: "thermostatSetpoint", value: 42)
initialize()
}
def tempUp()
{
log.debug "Tempup()"
sendEvent(name: "ThermostatSetpoint", value: 30)
}
def tempDown()
{
log.debug "Tempdown()"
sendEvent(name: "ThermostatSetpoint", value: 40)
}
def initialize()
{
log.debug "Initialize"
}
def poll()
{
log.debug "Executing poll"
}
def updated()
{
log.debug "updated()"
}
// parse events into attributes
def parse(Map description) {
}
/************** Betriebsfunktionen **************/
def auto()
{
log.debug "auto()"
}
def cool()
{
log.debug "cool()"
}
def emergencyHeat()
{
log.debug "emergencyHeat()"
}
def fanAuto()
{
log.debug "fanAuto()"
}
def fanCirculate()
{
log.debug "fanCirculate()"
}
def fanOn()
{
log.debug "fanOn()"
}
def heat()
{
log.debug "heat()"
def temp = device.currentState("ThermostatSetpoint").value;
log.debug "Temp: ${temp}"
setThermostatSetpoint(temp)
}
def off()
{
log.debug "off()"
}
/************** Setter Methods **************/
def setCoolingSetpoint(Number setpoint)
{
log.debug "setCoolingSetpoint()"
setThermostatSetpoint(setpoint)
}
def setHeatingSetpoint(Number setpoint)
{
log.debug "setHeatingSetpoint()"
setThermostatSetpoint(setpoint)
}
def setThermostatFanMode(Enum fanmode)
{
log.debug "setThermostatFanMode()"
}
def setThermostatMode(Enum mode)
{
log.debug "setThermostatMode()"
}
def setThermostatSetpoint (Number setpoint)
{
log.debug "setThermostatSetpoint()"
sendEvent(name: "ThermostatSetpoint", value: setpoint)
log.debug "Heating Sepoint: ${setpoint} new Setpoint: ${device.currentState("ThermostatSetpoint").value}"
}