Custom values (states) of an official capability


#1

1) Give a description of the problem
Built a DTH with custom states in a typical capability

e.g. tileAttribute(“device.thermostatMode”, key: “THERMOSTAT_MODE”) {
attributeState(“off”, label:’${name}’)
attributeState(“heat”, label:’${name}’)
attributeState(“cool”, label:’${name}’)
attributeState(“dyson”, label:’${name}’)
attributeState(“auto”, label:’${name}’)

“dyson” is a state added into the predefined list.
DTH and commands works as usual in Smartthings

2) What is the expected behavior?

When selecting “thermostatMode” in “Value” drop down menu, custom values should show up

3) What is happening/not happening?

Only official values are shown “auto, off, emergency heat, cool, heat”

Would like to know how to utilize custom values (with || and && parameters) for comparison in pistons,
tried (“auto” || “dyson”) but didn’t work.

Read the wiki section on expression but If() keeps returning true because everything is treated as a boolean somehow?

Moreover, for custom attributes, do I use commas or syntax to separate states in Value field?

Please help :’(



#2

Your thermostat has the capability of having custom modes? What type of thermostat do you have? My has different schedule mode (home, away, work, sleep, etc) but only the obvious Thermostat modes (heat, cool, auto and off). Maybe thermostat mode isn’t the capability you want to use.


#3

It’s a virtual thermostat DTH that I created to give the core piston I’ve been using a UI for settings

I’ve figured out if I use expression:

If( [Bedroom Thermostat : thermostatMode] == “heat”, true, false)

It works but can I use OR in there to compare it with multiple values? or I need to stack them within?


#4

Why not simply put the function into the If part of the piston? I’m confused why you’re using an expression. If your DTH has the capability of thermostatMode, then it is accessible from the IF part of the piston.


#5

Here is a snippet of one of my pistons. (You could probably modify it to suit you)

This one sets my variable (rain) to a number based on the text found in another variable (wuCurrent). If nothing matches, it uses the last number listed (0).

temp

By the way, even though the word IF is not in that code, it is assumed. You can translate it to say:

IF variable 'wuCurrent' contains the word 'Snow, then set variable 'rain' to '90'
ELSE, go on to the next line
etc...
If nothing matches, set variable 'rain' to '0'...

(The tricky part is making sure you put in the right number of closing parentheses)

More examples found here: wiki.webcore.co/Functions