I’m having some issues performing calculations on device values. Could somebody please take a look and tell me what I’m doing wrong, it seems like I’m getting data type mismatches. Can’t find much documentation on data types of device values.
This is just groovy stuff, unless otherwise specified, everything ST is a string value.
Sometimes the strings evaluate to ints on their own, sometimes they don’t, I know it’s not Magic, and I also know I don’t know Groovy well enough to tell you where/when/why you have to do it one way or another.
All I can tell you is that when I get errors evaluating numbers, casting them to integers (or whatever you need) eliminates the type errors
java.lang.ClassCastException: physicalgraph.app.AttributeWrapper cannot be cast to java.math.BigDecimal
Should I be trying to convert everything to .toBigDecimal() ?
Any suggestions / tips would be appreciated.
@Jim feel free to chime in. PS I tried your mySensor.currentState(“temperature”) to no avail.
Pardon any programming vulgarities, I’m just struggling through this one. (Like not understanding how to create new variables of the correct datatype on line 114-117…)
for the setpoints, it looks like you’re just using the attribute itself, like thermostat.heatingSetpoint. I think that just returns the attribute itself, like you’re seeing in the exception.
Try getting the current value via the current<attributeName> method: thermostat.currentHeatingSetpoint, just like you are for the temperature attributes.