[HELP] Comparing variables in SmartApp

Hello,

I was having some issues comparing the current temp of a sensor to a value that is set. Below is the code that I am trying to use. Everytime i run it I get a Java.math.bigdecimal error. Any help is appreciated!

input "tempsen", "capability.temperatureMeasurement", title: "Use Which Temperature Sensor", 
input "comfort_high", "decimal", title: "Set Comfort High Temp", required: false
input "comfort_low", "decimal", title: "Set Comfort Low Temp", required: false

def temperaturehandler(evt){
def tempState = tempsen.currentTemperature
log.debug "Temperature is ${tempState.value} Degrees"

    if (tempState > comfort_high) {
    	log.debug "Temperature is Higher Than Desired for Comfort Settings"
    }
    else if (tempState < comfort_low) {
    	log.debug "Temperature is Lower Than Desired for Comfort Settings"
    }
    else {
    	log.debug "Temperature is within Desired Comfort Settings"
    }
}

This is a link to the code >> thermostat-smart-controller.groovy

CurrentTemp is a string, so it needs to be converted
Try currentTemperature.toBigDecimal ()

3 Likes

Mike_Maxwell you are awesome!!! Thank you so much for you help! This fixed it.