Using time and temp to control outlets - Please Help

I am trying to control outlets mainly by temperature. That works without any issues. However, there are a few hours of the day where I need them to turn off, regardless of the temperature. I can not see to get that added functionality to work.

I checked the live logging and it seems that the boolean I am trying to use is being passed a null.

Any suggestions/help would be very much appreciated.

Thank you,
Jerry

/**

  • RoofMelt ><3
  • This application allows outlets powering roof mounted heat strips to turn on when the tempurature drops below
  • a user determined tempurature and turn off when the tempurature rises above a user determined tempurature.
  • Author: Jerry Mabrito @ jerry_mabrito@icloud.com
    */

definition(
name: “RoofMelt ><3”,
namespace: “Roof”,
author: “Gerald Mabrito”,
description: “Version 1.2:”,
category: “My Apps”,
iconUrl: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience.png”,
iconX2Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png”,
iconX3Url: “https://s3.amazonaws.com/smartapp-icons/Convenience/Cat-Convenience%402x.png”)

preferences {
// Allows user to select a temperature sensor for sensorS1, to use as the input source for the outside temp
section("Choose a temperature sensor… "){
input “sensorS1”, “capability.temperatureMeasurement”, title: “Temp Sensor”
}
// Allows user to select the desired outlet(s)/switch(es) to control.
section("Select the outlet(s)… "){
input “outlets”, “capability.switch”, title: “Outlets”, multiple: true
}
// Allows user to set the temperature below which, the outlet(s) should come on.
section(“Set the on temperature for the outlet(s)…”){
input “setPointOn”, “decimal”, title: “Set On Temp”
}

// Allows user to set the temperature above which, the outlet(s) should turn off.
section("Set the off temperature for the outlet(s)..."){
	input "setPointOff", "decimal", title: "Set Off Temp"
}

// Allows user to select the time to shut off the outlet(s).
input name: "offTime", title: "Turn Off Time?", type: "time"

// Allows user to select the time to turn on the outlet(s).
input name: "onTime", title: "Turn On Time?", type: "time"

// Allows user to set operation to, "On", "Off", or "Auto"
section("Select 'On' for manual on and 'Off' for manual off, and 'Auto' for automatic operation..."){
	input "operation", "enum", title: "On, Off, or Automatic?", metadata: [values: ["On","Off","Automatic"]]
}

}

def installed()
{
//Actions taken when the application is installed
subscribe(sensorS1, “temperature”, temperatureHandler)
schedule(offTime, “offTimerCallback”)
schedule(onTime, “onTimerCallback”)

}

def updated()
{
//Actions taken when the application is updated
unsubscribe()
subscribe(sensorS1, “temperature”, temperatureHandler)
subscribe(sensorS1, “temperature”, temperatureHandler)
unschedule()
schedule(offTime, “offTimerCallback”)
schedule(onTime, “onTimerCallback”)

}

def scheduledOff = false

def offTimerCallback() {
log.debug " Flipping the switch off"
scheduledOff = true

}

def onTimerCallback() {
log.debug "Flipping the switch on"
scheduledOff = false
}

// Temperature Event Handler - Monitors for a change of temperature for the temperature sensor and updates lastTemp.
// If mode2 is in automatic, it will initiate the evaluate process. If mode2 is on, will turn the outlet
// on. If mode2 is off, will turn the outlet off.
def temperatureHandler(evt)
{
// Checks to see if operation is in automatic
if (operation == “Automatic”) {
def lastTempS1 = sensorS1.currentTemperature
// Verifies that lastTempS1 is not empty and then initiates evaluate
if ((lastTempS1 != null)) {
evaluate(lastTempS1, setPointOn, setPointOff, scheduledOff)
}
}
// Checks to see if operation is set to On, turns on the selected outlet/switch. Outlet/switch will remain on until
// operation has been changed. NOTE: Temperature will not affect outlet status.
else if (operation == “On”){
outlets.on()
}
// If operation is not in Automatic or On, then assumes it is set to Off, turns off the selected outlet/switch. Outlet/switch will remain off until
// operation has been changed. NOTE: Temperature will not affect outlet status.
else {
outlets.off()
}
}

// Will compare current temps and the on/off temps to turn on/off the selected outlet on and off depending on the mode.
private evaluate(lastTempS1, setPointOn, setPointOff, scheduledOff)
{
log.debug “EVALUATE($lastTempS1, $setPointOn, $setPointOff, $scheduledOff)”

		// Turns outlets on if the temp is below the setPointOn & the scheduledOff is false.
		if ((lastTempS1 <= setPointOn) && !(scheduledOff)) {
			outlets.on()
	
		}

		// Turns outlets off if the temp is above the setPointOff or the scheduledOff is true.
		 if ((lastTempS1 >= setPointOff) || (scheduledOff)) {
			outlets.off()
	
		}

}