Skip to content

Commit

Permalink
Merge pull request SmartThingsCommunity#89 from workingmonk/centralit…
Browse files Browse the repository at this point in the history
…e_thermostat

[PROB-516] as Integer causes the temp to be off by 1
  • Loading branch information
workingmonk committed Sep 1, 2015
2 parents 7ff18e5 + 33d9efa commit a49542c
Showing 1 changed file with 24 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,31 +153,37 @@ def refresh()
//}

def getTemperature(value) {
def celsius = Integer.parseInt(value, 16) / 100
if(getTemperatureScale() == "C"){
return celsius
} else {
return celsiusToFahrenheit(celsius) as Integer
if (value != null) {
def celsius = Integer.parseInt(value, 16) / 100
if (getTemperatureScale() == "C") {
return celsius
} else {
return Math.round(celsiusToFahrenheit(celsius))
}
}
}

def setHeatingSetpoint(degrees) {
def temperatureScale = getTemperatureScale()

def degreesInteger = degrees as Integer
log.debug "setHeatingSetpoint({$degreesInteger} ${temperatureScale})"
sendEvent("name":"heatingSetpoint", "value":degreesInteger)

def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x12 0x29 {" + hex(celsius*100) + "}"
if (degrees != null) {
def temperatureScale = getTemperatureScale()

def degreesInteger = Math.round(degrees)
log.debug "setHeatingSetpoint({$degreesInteger} ${temperatureScale})"
sendEvent("name": "heatingSetpoint", "value": degreesInteger)

def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x12 0x29 {" + hex(celsius * 100) + "}"
}
}

def setCoolingSetpoint(degrees) {
def degreesInteger = degrees as Integer
log.debug "setCoolingSetpoint({$degreesInteger} ${temperatureScale})"
sendEvent("name":"coolingSetpoint", "value":degreesInteger)
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x11 0x29 {" + hex(celsius*100) + "}"
if (degrees != null) {
def degreesInteger = Math.round(degrees)
log.debug "setCoolingSetpoint({$degreesInteger} ${temperatureScale})"
sendEvent("name": "coolingSetpoint", "value": degreesInteger)
def celsius = (getTemperatureScale() == "C") ? degreesInteger : (fahrenheitToCelsius(degreesInteger) as Double).round(2)
"st wattr 0x${device.deviceNetworkId} 1 0x201 0x11 0x29 {" + hex(celsius * 100) + "}"
}
}

def modes() {
Expand Down

0 comments on commit a49542c

Please sign in to comment.