Problems writing rule to raise thermostat one degree

Hey guys. New to OH, but I’ve been using HA for many years (MisterHouse, Homeseer, AgoControl). I’m trying to wrap my head around rules and so far things have gone well. I’m now trying to write a rule that will raise the thermostat one degree when an X10 button is pressed ‘ON’ and lower it one degree when an X10 button is pressed ‘OFF’. Here’s what I have and the errors I’m seeing:

import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import java.lang.Math
import java.util.Calendar
import java.util.Date
import java.util.TimeZone
import java.text.SimpleDateFormat

rule "Press X10 B4 Raise Temp +/- one degree"
when
	Item X10_B4 received command
then
	if(receivedCommand==ON) 
		{
			New_heat = (HVAC_HeatSetPoint) + 1
			sendCommand(HVAC_HeatSetPoint, New_heat)
			New_cool = (HVAC_CoolSetPoint) + 1
			sendCommand(HVAC_CoolSetPoint, New_cool)
			
		}
	else if(receivedCommand==OFF) 
		{
			New_heat = (HVAC_HeatSetPoint as DecimalType) - 1
			sendCommand(HVAC_HeatSetPoint, New_heat)
			New_cool = (HVAC_CoolSetPoint as DecimalType) - 1
			sendCommand(HVAC_CoolSetPoint, New_cool)
		}
end

Here’s my item definitions:

 /* ===================== HVAC ===================== */

 Number	HVAC_HeatSetPoint		"Heat Set [%s °F]"											<heating>		(Living,HVAC)				{ zwave="9:command=THERMOSTAT_SETPOINT,setpoint_type=1,setpoint_scale=1" }
 Number	HVAC_CoolSetPoint		"Cool Set [%s °F]"											<climate>		(Living,HVAC)				{ zwave="9:command=thermostat_setpoint,setpoint_type=2,setpoint_scale=1" }

and the errors when pressing the buttons:

2016-06-04 10:29:25.634 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Press X10 B4 Raise Temp +/- one degree': Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
2016-06-04 10:29:27.618 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Press X10 B4 Raise Temp +/- one degree': Cannot cast org.openhab.core.library.items.NumberItem to org.openhab.core.library.types.DecimalType

I see that it’s complaining about the decimal type but I’m not sure what to do about it. Can someone help this OH newbie get this going?

Many thanks!

I figured it out!

rule "Press X10 B4 Raise Temp +/- one degree"
when
	Item X10_B4 received command
then
	if(receivedCommand==ON) 
		{
			var New_heat = ((HVAC_HeatSetPoint.state as DecimalType).intValue) + 1
			sendCommand(HVAC_HeatSetPoint, New_heat)
			var New_cool = ((HVAC_CoolSetPoint.state as DecimalType).intValue) + 1
			sendCommand(HVAC_CoolSetPoint, New_cool)
			
		}
	else if(receivedCommand==OFF) 
		{
			var New_heat = ((HVAC_HeatSetPoint.state as DecimalType).intValue) - 1
			sendCommand(HVAC_HeatSetPoint, New_heat)
			var New_cool = ((HVAC_CoolSetPoint.state as DecimalType).intValue) - 1
			sendCommand(HVAC_CoolSetPoint, New_cool)
		}
end