[SOLVED] Help with a heating rule

hey guys.

im looking for some help on the below rule.


rule "Arrival Heating and Cooling"
when
	Item Test_Heating changed from OFF to ON or
	Item Someones_Home changed from OFF to ON
then
if	((Lounge_Hue_Temp.state <= 18) && (Heating_AC_Time_Switch.state == ON))
		{
		sendCommand(Lounge_Setpoint_Temp_Heat, 20)
		}
if	((Lounge_Hue_Temp.state >= 25) && (Heating_AC_Time_Switch.state == ON))
		{
		sendCommand(Lounge_Setpoint_Temp_Cool, 24)
		}
end

in the logs im getting these errors

2018-12-20 18:34:12.982 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Arrival Heating and Cooling': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_greaterEqualsThan(org.eclipse.smarthome.core.types.Type,java.lang.Number) on instance: null
2018-12-20 18:35:10.773 [WARN ] [io.openhabcloud.internal.CloudClient] - Jetty request 4388 failed: null
2018-12-20 18:35:10.775 [WARN ] [io.openhabcloud.internal.CloudClient] - Response Failure: null

ive got the item Lounge_Hue_Temp in a sitemap and the current temp is showing as 17.5 degrees but the rule is not firing.

ok so removing the quotations from the temps has fixed the errors in the logs but the rule is still not working and no errors are being shown in the logs at all now

Try with some logInfo() in your code, which either simply tells you, you’re in your if clause. You can also put in some variable outputs in it.
If you’re still struggling, please add some context on how the items are declared and when they change, so we can have a look

so it doesn’t look like its getting into the if clause because my rule is now as follows

rule "Arrival Heating and Cooling"
when
	Item Test_Heating changed from OFF to ON or
	Item Someones_Home changed from OFF to ON
then
if	((Lounge_Hue_Temp.state <= 20) && (Heating_AC_Time_Switch.state == ON))
		{
	        logInfo("Arrival Heating and Cooling", "HEATING")
		sendCommand(Lounge_Setpoint_Temp_Heat, 20)
		}
if	((Lounge_Hue_Temp.state >= 25) && (Heating_AC_Time_Switch.state == ON))
		{
	        logInfo("Arrival Heating and Cooling", "Cooling")
		sendCommand(Lounge_Setpoint_Temp_Cool, 24)
		}
end

the presence side of our openhab system uses wifi detection to check the presence so we have one switch for each person and then a global “switch Someones_Home” and that side of everything is working extremely well.
a couple of weeks ago we got a ir heat pump code blaster which is working in a sitemap with no issues at all.

the “Heating_AC_Time_Switch” is just a time based switch that turns on at 6am and off at 10 pm and the switch is currently on as verified by our sitemap.

so there is something wrong with the if clauses in my rule but I’m nit sure what

the items in the rule are below

Switch 		Heating_AC_Time_Switch 		"Allow Heating if between 6am and 9PM"
Number:Temperature		Lounge_Setpoint_Temp_Cool	"Lounge Cooling Temp [%.1f °C]"		{channel="zwave:device:512:node41:thermostat_setpoint_cooling"}
Number:Temperature		Lounge_Setpoint_Temp_Heat	"Lounge Heating Temp [%.1f °C]"		{channel="zwave:device:512:node41:thermostat_setpoint_heating"}
Number				Lounge_Heating_Cooling_Mode	"Heatpump Mode [%s]"			{channel="zwave:device:512:node41:thermostat_mode"}
Switch Test_Heating
Number:Temperature  	Lounge_Hue_Temp 		"Temperature [%.1f °C]" 	<temperature>						{channel="hue:0302:00178829a0c5:43:temperature"}

confirmed by putting this directly after then and before if

	        logInfo("Arrival Heating and Cooling", "Rule Fired")

so the rule is firing

soo after some more tinkering its getting stuck on the Lounge_Hue_Temp.state because removing that the rule works fine. I have no idea why checking the current state and its displayed currently as 18.72 so it should be working?

Try changing to

Lounge_Hue_Temp.state as Number <= 20

does it work then?

Comparing states to primitives can be troublesome sometimes.

Or use something like

Lounge_Hue_Temp.state <= 20|"°C"

Lounge_Hue_Temp.state is not just a Number, it is a number with a specific unit of measurement, which should be incorporated in such a comparison. So in the specific case of a temperature, it is a Number:Temperature, so it should include the applicable unit, so either °C or °F. (not sure if Kelvin is supported, but that might be less practical anyway)

that’s giving the following error in the logs

2018-12-20 20:13:40.880 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'Heating.rules' has errors, therefore ignoring it: [9,39]: no viable alternative at input '='
[9,41]: mismatched input '20' expecting '>'

your a legend. thats fixed it!!!

No problem, you are welcome. And feel free to mark my answer as a solution by clicking the checkbox at the bottom of my post, it also might help others.

If you are interested in a bit of background this might be of interest:

https://www.eclipse.org/smarthome/blog/2018/02/22/units-of-measurement.html

Thanks, ill have a read. I’m still pretty green but I’m learning fast!