I’ve tried editing 'It’s too cool" to be it’s too hot. I still get the null error on line 50 I don’t understand.
definition(
name: “Climate Control Cool II”,
namespace: “”,
author: “Dave Keil”,
description: “Uses external themostat to run HVAC”,
category: “My Apps”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo@2x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Meta/temp_thermo@2x.png”
)
preferences() {
section("Choose Thermostat… ") {
input “thermostat”, “capability.thermostat”
}
section("Choose Sensor... " ) {
input "sensor", "capability.temperatureMeasurement", multiple: false
}
section("Set threshold " ) {
input "tempThreshold", "decimal"
}
}
def installed()
{
log.debug “enter installed, state: $state”
subscribeToEvents()
}
def updated()
{
log.debug “enter updated, state: $state”
unsubscribe()
subscribeToEvents()
}
def subscribeToEvents()
{
subscribe(sensor, “Temperature”, sensorHandler)
subscribe(thermostat, “temperature”, coolingSetpointHandler)
subscribe(thermostat, “thermostatMode”, coolingSetpointHandler)
subscribe(thermostat, “coolingSetpoint”, coolingSetpointHandler)
state.realCoolSetPoint = thermostat.currentCoolingSetpoint
state.tempCoolSetPoint = thermostat.currentCoolingSetpoint - 2
runIn(5,checkTemp)
}
def coolingSetpointHandler(evt)
{
log.trace “coolingSetPoint”
log.info “thermoSetPoint: ‘${thermostat.currentCoolingSetpoint}’ / tempSetPoint: ‘${state.tempCoolSetPoint}’”
if (state.tempCoolSetPoint != thermostat.currentCoolingSetpoint)
{
log.trace "Setting realCoolSetPoint: '${thermostat.currentCoolingSetpoint}'"
state.realCoolSetPoint = thermostat.currentCoolingSetpoint
}
checkTemp()
}
def sensorHandler(evt)
{
checkTemp()
}
def checkTemp()
{
def tm = thermostat.currentThermostatMode
def ctThermo = thermostat.currentTemperature
def ctSensor = sensor.currentTemperature
def sp = state.realCoolSetPoint
if (needCool())
{
if (incrCoolSetPoint())
{
state.tempCoolSetPoint = ctThermo - 2
log.info "Changing Thermostat from '${sp}' to '${state.tempCoolSetPoint}' because sensor is '${ctSensor}'"
thermostat.setCoolingSetpoint(state.tempCoolSetPoint)
}
else
{
log.info "Thermostat set to '${sp}' and current themostat temp is '${ctThermo}'. Not changing anything."
}
}
else
{
if (coolGood() && thermoNotRight())
{
log.info "Changing Thermostat to '${sp}' because Thermostat is '${ctThermo}' and Sensor is '${ctSensor}'"
thermostat.setCoolingSetpoint(sp)
state.tempCoolSetPoint = -99
}
else
{
log.info "Everything is correct"
}
}
}
private coolGood()
{
def ctSensor = sensor.currentTemperature
def sp = state.realCoolSetPoint
def result=false
if (((ctSensor - tempThreshold) <= sp))
{
result = true
}
log.trace "checking if cool is Good"
log.info "[ RETURN: '${result}' ] -- ${ctSensor} - ${tempThreshold} ('${ctSensor - tempThreshold}') <= ${sp}"
return result
}
private thermoNotRight()
{
def sp = state.realCoolSetPoint
def csp = thermostat.currentCoolingSetpoint
def result = false
if (sp != csp)
{
result = true
}
log.trace "thermoNotRight"
log.info "[ RETURN: '${result}' ] -- ${sp} != ${csp}"
return result
}
private needCool()
{
def tm = thermostat.currentThermostatMode
def ctSensor = sensor.currentTemperature
def sp = state.realCoolSetPoint
def result=false
if (((ctSensor + tempThreshold) > sp) && (tm in ["cool","auto"]))
{
result = true
}
log.trace "checking if we Need Cool"
log.info "[ RETURN: '${result}' ] -- ${ctSensor} + ${tempThreshold} ('${ctSensor + tempThreshold}')> ${sp} && ${tm} in ['cool', 'auto']"
return result
}
private incrCoolSetPoint()
{
def sp = state.realCoolSetPoint
def ctThermo = thermostat.currentTemperature
def result = false
if (ctThermo >= sp)
{
result = true
}
log.trace "checking if we Need to increase cool"
log.info "[ RETURN: '${result}' ] -- ${ctThermo} <= ${sp}"
return result
}