What am I doing wrong? Trying to define values for thermostatOperatingState


Hope this is the right place…otherwise please apply torture of choice…

I’m working on a DH for a thermostat, using the multiattribute tile for thermostat. I have the following:

tileAttribute("device.thermostatOperatingState", key: "OPERATING_STATE") {
 				attributeState("idle", backgroundColor:"#44b621")
 				attributeState("heating", backgroundColor:"#ffa81e")
 				attributeState("cooling", backgroundColor:"#269bd2")

That is supposed to get the values from:

def thermostatOperatingState() {
	def active = device.currentValue("inUse")
	def mode = device.currentValue("thermostatMode")
	if (active == "false") {
				sendEvent(name: "thermostatOperatingState", value: "idle")
	else if (mode == "Cooling") {
				sendEvent(name: "thermostatOperatingState", value: "cooling")
	else if (mode == "Heating") {
				sendEvent(name: "thermostatOperatingState", value: "heating")

But it is not working. Please tell me where I am going wrong?


One of the latest Android update broke the thermostat multiattribute tile for my DTH. But its working fine on IOS. Dont know if its the same issue, have you tested on both android and ios?


Good point. I created a value tile and I also checked on iOS. First, the Android app is broken. But so is my code :frowning:
The value it returns is “false” instead of “idle”

(Mike Maxwell) #4

I could be wrong, but I don’t recall inUse being an available device attribute state, as such it will always return null.
If this is a boolean that your dth is managing try storing it in a state variable.


inUse is coming from:

  def updateDeviceData(data) {
	sendEvent(name: "inUse", value: data.inUse)

The fact that I am getting “false” or “true” returned tells me the code is executing. It is just not passing the value to “thermostatOperatingState”. Probably due to a syntax issue.


I noticed something else in the rest API. The mode return a value in quotes while inUse returns a value without quotes like so:

  "mode": "Cooling", 
  "inUse": false,

So am I correct in assuming that inUse is a boolean? If so how do I declare it properly in the code above?

(Mike Maxwell) #7

yea, its a boolean try changing your if to “if (!active)”


Thanks. I have come to realize that the value “false” is stuck in thermostatOperatingState. The def thermostatOperatingState() never even fires to update the state. Now I am stuck on why this is not happening.

(Mike Maxwell) #9

what rest API?, inUse isn’t a standard attribute associated with any device that I know of, so you aren’t getting a value from st for it.
If this attribute is being returned via some API other than ST, you will need to store it in a state variable.


You have been a tremendous help. Thank you very much!