UPDATE I'm guessing this may be a scope issue as another of my questions was answered by my not fully understanding scope. I understand the concept but not the rules
I have a variable "tempUnitsDegC" that gets set using an "input name" function. If I assign it a (what I think is numeric) a following "if" test does not work (i.e. is not processed) and I get the below error.
However when I change the Type to String by assigning the variable "0" or "1" all is fine.
So clearly I am missing some subtlety but I've not been able to find it.
Any insights would be helpful?
I have this line to define "tempUnitsDegC"
input name: "tempUnitsDegC", type: "enum", title: "Temperature Units", options: [1:"°C",0:"°F"], defaultValue: 1, required: false
Then this "if" statement did not resolve to "true" in the below
if (tempUnitsDegC ==0 ){
SensorValue = SensorValue * 9 / 5 + 32
sendEvent(name: "temperature", value: SensorValue, unit:"F", isStateChange: true)
}
I changed the numbers to strings and all worked.
input name: "tempUnitsDegC", type: "enum", title: "Temperature Units", options: ["1" : " °C","0" : "°F"], defaultValue: "1", required: false
and
if (tempUnitsDegC =="0" ){
Works OK.