Error that I don't understand

Im only doing a simple comparison of number items and number item + val (within the rule)

rules

//determine if heating or HWS have any demand

//Heating_Setpoint
//HWS_Setpoint
//OAT_Setpoint
//Temperature_LivingRoom
//Temperature_HWS
//Temperature_OAT
//Temperature_FlowPipe
//Temperature_Upstairs

val Number Heating_Deadband = -1
val Number HWS_Deadband = -15
val Number OAT_Deadband = -1

rule "OAT Hi check"
when
        System started or
        //every minute check the demands
        Time cron "0 * * ? * *"
then
        //check OAT temp
        if (Temperature_OAT.state > OAT_Setpoint.state){
                if (OAT_Hi.state != ON){
                        OAT_Hi.sendCommand(ON)
                        logInfo("demand_check","OAT HoldOff "+OAT_Hi.state)

                }
        } else if (Temperature_OAT.state < (OAT_Setpoint.state+OAT_Deadband)){
                if (OAT_Hi.state != OFF){
                        OAT_Hi.sendCommand(OFF)
                        logInfo("demand_check","OAT HoldOff "+OAT_Hi.state)
                }
        }
end

rule "Heating demand check"
when
        System started or
        //every minute check the demands
        Time cron "0 * * ? * *"
then
        //check inside temp
        if (Temperature_LivingRoom.state < (Heating_Setpoint.state+Heating_Deadband)){
                if (Heating_Demand.state != ON){
                        Heating_Demand.sendCommand(ON)
                        logInfo("demand_check","Heating demand "+Heating_Demand.state)

                }
        } else if (Temperature_LivingRoom.state > Heating_Setpoint.state){
                if (Heating_Demand.state != OFF){
                        Heating_Demand.sendCommand(OFF)
                        logInfo("demand_check","Heating demand "+Heating_Demand.state)

                }
        }
end

rule "HWS demand check"
when
        System started or
        //every minute check the demands
        Time cron "0 * * ? * *"
then
        //check inside temp
        if (Temperature_HWS.state < (HWS_Setpoint.state+HWS_Deadband)){
                if (HWS_Demand.state != ON){
                        HWS_Demand.sendCommand(ON)
                        logInfo("demand_check","HWS     demand "+HWS_Demand.state)

                }
        } else if (Temperature_WS.state > HWS_Setpoint.state){
                if (HWS_Demand.state != OFF){
                        HWS_Demand.sendCommand(OFF)
                        logInfo("demand_check","HWS     demand "+HWS_Demand.state)

                }
        }
end

error

2018-02-18 21:04:00.105 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Heating demand check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
2018-02-18 21:05:00.044 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS demand check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
2018-02-18 21:05:00.133 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Heating demand check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null

I made a change to the OAT hi check rule, it was

} else if (Temperature_OAT.state < (OAT_Setpoint.state-1)){

i changed to

} else if (Temperature_OAT.state < (OAT_Setpoint.state+OAT_Deadband)){

and now get this error

2018-02-18 21:31:00.099 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'OAT Hi check': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_greaterThan(org.eclipse.smarthome.core.types.Type,java.lang.Number) on instance: null

which is different from the other errors. This only occurred after I restarted the raspberry pi.

Not sure what the errors are telling me.

Thanks

@steven_191 please post your items file.

This errors occur when the items are not initialized with values. Maybe just add some log infos and post the state of the items you use.

logInfo("Label", "Item:\"" + <Item>.name + "\" state:\"" +  <Item>.state + "\"" )

Solve this be setting initial values with a rule. Or use a persistence strategy with restoreOnStartup.

rule "System started"
when
    System started
then
    ...

    logInfo("System started", "All Items Initialized")
end

persistence is something I havent got round to yet but after reading what you have posted I suspect the reason the OAT error occurred after the reboot would be due to the setpoint value no longer being there.

But I dont know why it still showed errors for the others when all values are present.

I will try the initialise at start up option first for a quick work around and report back later.

Thanks

annoyingly I accidentally deleted the file so I wrote it out again. I dont think I did anything different and didn’t get the same error. I did find that I did get some other error which made no sense, rebooted and then I didnt get it.

I am getting a different error now with something that was working fine before.

this error

2018-02-19 19:18:00.033 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Heating Occupancy Check': An error occurred during the script execution: Could not invoke method: org.joda.time.base.AbstractInstant.isAfter(long) on instance: 2018-02-19T19:18:00.026Z

as a result of this rule

//heating times
//every day
val T1start = now.withTimeAtStartOfDay.plusHours(5).plusMinutes(30).millis
val T1stop  = now.withTimeAtStartOfDay.plusHours(7).millis
val T2start = now.withTimeAtStartOfDay.plusHours(15).plusMinutes(0).millis
val T2stop  = now.withTimeAtStartOfDay.plusHours(21).millis
//weekend or with presence
val T3start = now.withTimeAtStartOfDay.plusHours(8).plusMinutes(30).millis
val T3stop  = now.withTimeAtStartOfDay.plusHours(9).plusMinutes(30).millis
val T4start = now.withTimeAtStartOfDay.plusHours(10).plusMinutes(30).millis
val T4stop  = now.withTimeAtStartOfDay.plusHours(12).millis

//hws times
val T10start = now.withTimeAtStartOfDay.plusHours(4).plusMinutes(30).millis
val T10stop  = now.withTimeAtStartOfDay.plusHours(5).plusMinutes(30).millis
val T20start = now.withTimeAtStartOfDay.plusHours(14).plusMinutes(0).millis
val T20stop  = now.withTimeAtStartOfDay.plusHours(15).plusMinutes(0).millis

rule "occupancy system start"
when
        System started
then
        Occupancy.sendCommand(OFF)
        OccupancyHeating.sendCommand(OFF)
        OccupancyHWS.sendCommand(OFF)
        Today.sendCommand(now.getDayOfWeek)
        OAT_Hi.sendCommand(OFF)
end

rule "setting day of the week"
when
        Time cron "0 0 0 ? * *"
then
        Today.sendCommand(now.getDayOfWeek)
        logInfo("Setting day_of_the_week","Today is "+Today)
end

rule "Heating Occupancy Check"
when
        //cron trigger fires every minute (working!!)
        Time cron "0 * * ? * *"
then
        //heating
        //every day schedules
        if(now.isAfter(T1start) && now.isBefore(T1stop)){
                if(occProxy1.state!=ON){
                        occProxy1.sendCommand(ON)
                }
        } else if(occProxy1.state!=OFF){
                occProxy1.sendCommand(OFF)
        }
        if(now.isAfter(T2start) && now.isBefore(T2stop)){
                if(occProxy2.state!=ON){
                        occProxy2.sendCommand(ON)
                }
        } else if(occProxy2.state!=OFF){
                occProxy2.sendCommand(OFF)
        }

        //day of the week scedules

        //use this for saturday/sunday only + presence
        //if(Today.state==6 || Today.state==7 || gPresent.state==ON){

        //use this for every day + presence
        if(gPresent.state==ON){
                if(now.isAfter(T3start) && now.isBefore(T3stop)){
                        if(occProxy3.state!=ON){
                                occProxy3.sendCommand(ON)
                        }
                } else if(occProxy3.state!=OFF){
                        occProxy3.sendCommand(OFF)
                }
                if(now.isAfter(T4start) && now.isBefore(T4stop)){
                        if(occProxy4.state!=ON){
                                occProxy4.sendCommand(ON)
                        }
                } else if(occProxy4.state!=OFF){
                        occProxy4.sendCommand(OFF)
                }
        } else {
                if(occProxy3.state!=OFF){
                        occProxy3.sendCommand(OFF)
                }
                if(occProxy4.state!=OFF){
                        occProxy4.sendCommand(OFF)
                }
        }
end

this seemed to be working until I started working on the other rule so no idea what has changed.
Do I need to import something?

try for all your Times.

val long T1start 

Does not matter it runs on my rpi. Like this, no error in the log.

//every day
val T1start = now.withTimeAtStartOfDay.plusHours(5).plusMinutes(30).millis
val T1stop  = now.withTimeAtStartOfDay.plusHours(7).millis
val T2start = now.withTimeAtStartOfDay.plusHours(15).plusMinutes(0).millis
val T2stop  = now.withTimeAtStartOfDay.plusHours(21).millis

rule "Heating Occupancy Check"
when
        //cron trigger fires every minute (working!!)
        Time cron "0 * * ? * *"
then
        logInfo("Heating Occupancy Check","Test")

        //heating
        //every day schedules
        if(now.isAfter(T1start) && now.isBefore(T1stop)){
        }

        if(now.isAfter(T2start) && now.isBefore(T2stop)){
        } 
end

I had that same thought about declaring it as a long after reading some of the joda time functions.

I still get this error though

2018-02-20 12:32:00.038 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Occupancy Check': An error occurred during the script execution: Could not invoke method: org.joda.time.base.AbstractInstant.isAfter(long) on instance: 2018-02-20T12:32:00.034Z
2018-02-20 12:32:00.089 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Heating Occupancy Check': An error occurred during the script execution: Could not invoke method: org.joda.time.base.AbstractInstant.isBefore(long) on instance: 2018-02-20T12:32:00.085Z

I tried the function T1start.isAfterNow() but this didnt work either.

Just log all used times. And let’s find the time which is wrong. I suspects the Z at the end of the time which is the Timezone ofsett bit there is none. May e when comparing with the other timestamps we will spot a difference.

Ive added logs after the change of status on the ‘heating occupancy check’ and now it seemed to run through and apply each status as expected. The HWS rule though still has the same error.
See below, I refreshed at 6:26 but the rule refresh again a minute later but I dont know why but this seems to happen every time I refresh a rule.
After this only the HWS rule returned an error. I really dont know why one works now and the other doesnt.

One other thing I changed was to removed the unnecessary use of .plusMinutes(0) in the times at the start. That did seem to have an effect too.

2018-02-23 06:56:44.056 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'occupancy.rules'
2018-02-23 06:57:25.759 [INFO ] [thome.model.script.Occupancy Started] - Occupancy_SystemStart
2018-02-23 06:57:25.812 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 0
2018-02-23 06:57:25.822 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Demand Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
2018-02-23 06:57:25.855 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_Start
2018-02-23 06:57:25.914 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 0
2018-02-23 06:57:25.928 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_T1Start
2018-02-23 06:57:25.952 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_T2Stop
2018-02-23 06:57:26.018 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_T3Stop
2018-02-23 06:57:26.125 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_T4Stop
2018-02-23 06:57:26.214 [INFO ] [thome.model.script.Heating Occupancy] - Heating Occupancy state - OFF
2018-02-23 06:57:26.219 [INFO ] [thome.model.script.Heating Occupancy] - Heating Occupancy state - OFF
2018-02-23 06:57:26.254 [INFO ] [thome.model.script.Heating Occupancy] - Heating Occupancy state - OFF
2018-02-23 06:57:26.262 [INFO ] [thome.model.script.Heating Occupancy] - Heating Occupancy state - OFF
2018-02-23 06:57:26.329 [INFO ] [thome.model.script.General Occupancy] - General Occupancy state - OFF
2018-02-23 06:57:26.432 [INFO ] [thome.model.script.General Occupancy] - General Occupancy state - ON
2018-02-23 06:57:26.469 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 0
2018-02-23 06:57:26.474 [INFO ] [thome.model.script.General Occupancy] - General Occupancy state - ON
2018-02-23 06:57:26.524 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 0
2018-02-23 06:57:26.557 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 0
2018-02-23 06:57:26.579 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 1
2018-02-23 06:57:26.891 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'occupancy.rules'
2018-02-23 06:57:50.278 [INFO ] [thome.model.script.Occupancy Started] - Occupancy_SystemStart
2018-02-23 06:57:50.363 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 1
2018-02-23 06:57:50.387 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To 0
2018-02-23 06:58:00.021 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_Start
2018-02-23 06:58:00.061 [INFO ] [se.smarthome.model.script.OAT Status] - OAT Hi  - OFF
2018-02-23 06:58:00.114 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Demand Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
2018-02-23 06:59:00.035 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_Start
2018-02-23 06:59:00.081 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Demand Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null

So I next logged the now and one of my times and found that the now is actually a date/time stamp but my time is in millis, so I added var Now=now.millis to the start of the rule and confirmed the log had two references of millis which is does and this introduced a new error.

2018-02-23 07:35:00.037 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_Times-1519371300019-1519363800000
2018-02-23 07:35:00.047 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_Start
2018-02-23 07:35:00.056 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Heating Occupancy Check': 'isAfter' is not a member of 'java.lang.Long'; line 53, column 5, length 20
2018-02-23 07:35:00.084 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Occupancy Check': 'isAfter' is not a member of 'java.lang.Long'; line 116, column 5, length 22
2018-02-23 07:35:00.125 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Demand Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null

Next I restarted the pi and waited again for the files to run and got new errors

2018-02-23 07:39:27.404 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'HWS Demand Check': Could not invoke method: org.eclipse.smarthome.model.script.lib.NumberExtensions.operator_greaterThan(org.eclipse.smarthome.core.types.Type,java.lang.Number) on instance: null
2018-02-23 07:39:30.451 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Heating Demand Check': Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
2018-02-23 07:39:31.140 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'hue:0200:0017881c8bbf:1' to inbox.
2018-02-23 07:39:31.181 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'hue:0100:0017881c8bbf:2' to inbox.
2018-02-23 07:39:31.210 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'hue:0100:0017881c8bbf:3' to inbox.
2018-02-23 07:39:31.237 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'hue:0100:0017881c8bbf:5' to inbox.
2018-02-23 07:39:50.063 [INFO ] [l.script.boiler.rules occupancy_mode] - Mode Set To NULL
2018-02-23 07:39:50.671 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'T4stop' on rule file 'occupancy.rules' cannot be initialized with value '<XMemberFeatureCallImplCustom>.millis': The name 'now' cannot be resolved to an item or type; line 11, column 20, length 3
2018-02-23 07:39:50.694 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'T10start' on rule file 'occupancy.rules' cannot be initialized with value '<XMemberFeatureCallImplCustom>.millis': The name 'now' cannot be resolved to an item or type; line 14, column 21, length 3
2018-02-23 07:39:50.716 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'T10stop' on rule file 'occupancy.rules' cannot be initialized with value '<XMemberFeatureCallImplCustom>.millis': The name 'now' cannot be resolved to an item or type; line 15, column 21, length 3
2018-02-23 07:39:50.739 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'T20start' on rule file 'occupancy.rules' cannot be initialized with value '<XMemberFeatureCallImplCustom>.millis': The name 'now' cannot be resolved to an item or type; line 16, column 21, length 3
2018-02-23 07:39:50.763 [WARN ] [me.internal.engine.RuleContextHelper] - Variable 'T20stop' on rule file 'occupancy.rules' cannot be initialized with value '<XMemberFeatureCallImplCustom>.millis': The name 'now' cannot be resolved to an item or type; line 17, column 21, length 3
2018-02-23 07:39:52.667 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
2018-02-23 07:39:52.875 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-02-23 07:39:53.582 [INFO ] [b.core.service.AbstractActiveService] - Expire Refresh Service has been started
2018-02-23 07:39:53.776 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-02-23 07:39:53.784 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'mybroker'
2018-02-23 07:39:54.254 [INFO ] [ternal.dhcp.DHCPPacketListenerServer] - DHCP request packet listener online
2018-02-23 07:39:55.569 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel

I seem to have a different error every time I look.

SD card degradation? Maybe try a new one!

Can you set the ..internal.engine.ExecuteRuleJob log to trace? Find out the whole name by setting the log to more characters. And also ..internal.engine.ExecuteRuleJob

For karaf you can specify the patern it in the console or in the file /var/lib/openhab2/etc/org.apache.karaf.log.cfg.
For file based logging /var/lib/openhab2/etc/C

you can then specify the log level with Karaf or also in the /var/lib/openhab2/etc/

So I think I worked it out.

By changing ‘now’ to now.millis I changed the object from a datetime object to a long value.

.isAfter is not part of the long class (as the error suggested) so I changed now.isAfter(start) to now>start
basically

so comparing to long values which is fine.

Which made me wonder, if I hadnt set up the start and stop time values as .millis in the first place they probably wouldve been datetime objects and worked straight away…

I was going to try to fine out but will double check this is working correctly first and make sure the schedules actually change state as expected. At least then I know I have a working platform.

Cheers for you help, and hopefully the SD isnt a problem, I might take another image just to be safe!!

Ive rebooted the pi and now have a new error…

2018-02-24 10:24:00.025 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_Times-1519467840016-1519450200000
2018-02-24 10:24:00.027 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Demand Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null
2018-02-24 10:24:00.032 [INFO ] [model.script.Heating Occupancy Start] - Occupancy_Start
2018-02-24 10:24:00.065 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'Heating Occupancy Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.LongExtensions.operator_greaterThan(long,long) on instance: null
2018-02-24 10:24:00.085 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Occupancy Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.LongExtensions.operator_greaterThan(long,long) on instance: null

The first log is showing the now.millis and start.millis.
The second log is from a different rule file, again it makes no sense because Im not actually using any string object but thats a seperate issue.
The third log is the start of the occupancy rule.

The last two errors are the new ones, which appears to say it cant compare two long values, but I dont know what the instance of ‘null’ is.

Ive not used karaf before but have managed to log into it and now have no idea how im supposed to use it lol
Are there any guides available?

https://docs.openhab.org/administration/console.html

https://docs.openhab.org/administration/logging.html#karaf-console

I checked the output in karaf and its the same as in the log file. Im seeing the warning/error messages so I dont know what else I need to look for.

Ive been messing around with it for a while and Im not getting any error messages.

Ive just tried restarting the service and have noticed this error now

2018-02-25 16:24:15.088 [WARN ] [el.core.internal.ModelRepositoryImpl] - Ignoring file 'occupancy.rules' as we do not have a parser for it.

could this be a formatting issue? I have seen in the past that I would need to open a file in vim and set its format. I normally use nano.

It still seems to run through after this though so I dont know how important this message is.

Otherwise Im out of ideas with what to do now other than through this all in the bin.

So you created the file with nano? And never opened it from Windows and saved it?

Then it should be ok.

Maybe just open it and save it so it gets reloaded. Watch the log in parallel so you see the massages.

The Null errors after a restart can come from items which have not been initiated with a value. For this you can use persistence or the system started rule.

I have set all values to write upon startup to eliminate any null values.

I only open and save with nano but did see an issue once or twice about formatting so change it with vim but that was related to a python script I was calling from the exec binding.

I worked out how to extend the number of characters in the log and here is the full path of the error

2018-02-25 19:06:10.347 [ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule 'HWS Demand Check': An error occurred during the script execution: Could not invoke method: org.eclipse.xtext.xbase.lib.ObjectExtensions.operator_plus(java.lang.Object,java.lang.String) on instance: null

what I dont get is where am I asking the rule to add an object and a string together?
Ive tried nulling out the logging lines but these are copies of other logging lines in the other rules (except for simple name changes)
and that first log isnt even showing after the temp><setpoint lines…

rule "HWS Demand Check"
when
        Time cron "0 * * ? * *"
then
        if(Temperature_HWS.state > HWS_Setpoint.state){
                logInfo("HWS Demand","HWS Temp is HIGH"+Temperature_HWS.state+"/"+HWS_Setpoint.state)
                if(HWS_Demand.state != OFF){
                        HWS_Demand.sendCommand(OFF)
                        logInfo("HWS Status","Demand     - "+Heating_Demand.state)
                }
        }else if(Temperature_HWS.state < (HWS_Setpoint.state+HWS_Deadband)){
                logInfo("HWS Demand","HWS Temp is LOW"+Temperature_HWS.state+"/"+HWS_Off_Temp)
                if(HWS_Demand.state != ON){
                        HWS_Demand.sendCommand(ON)
                        logInfo("HWS Status","Demand     - "+Heating_Demand.state)
                }
        }
end

Do you use VSCode as editor with openhab extension. If not I encourage you to have a look, it helps avoiding doing mistakes.

Please post your rule how it is at the moment. I think maybe there where some changes which are not reflected by your first post.

I did have an error because I tried to change the line I thought was causing a problem, but reverted back to how it was before, the rule is posted above, the HWS_Setpoint is just a reminder at the top so I got the spelling and format correct. Its a number item from another file.

I havent used VScode, but is there any reason I cant on a headless pi? It looks like it has a GUI but I only connect SSH over the network.

I use net sftp to mount the drive from my rpi to my windows pc. And run VSCode in windows. There are sftp clients for every os or use samba which needs more configuration.

So basically, I see no reason you can’t use VSCode to edit the files on your headless pi.

Ive sorted VScode over sftp and could see lots of errors regarding comparisons or strings due to not being able to convert a .state to a .number which makes no sense to me as other .state items are being recognised as the numbers they are and they are in the same lines???

anyway, heres a snippet of the rules and I have declared the apparent string as a number as it seems to be working. Its now showing the log info of the proceeding lines so its processing past the line in question.

rule "HWS Demand Check"
when
        Time cron "0 * * ? * *"
then
        if(Temperature_HWS.state > HWS_Setpoint.state as Number){
                logInfo("HWS Demand","HWS Temp is HIGH"+Temperature_HWS.state+"/"+HWS_Setpoint.state)
                if(HWS_Demand.state != OFF){
                        HWS_Demand.sendCommand(OFF)
                        logInfo("HWS Status","Demand - "+Heating_Demand.state)
                }
        }else if(Temperature_HWS.state < (HWS_Setpoint.state as Number + HWS_Deadband)){
                logInfo("HWS Demand","HWS Temp is LOW"+Temperature_HWS.state+"/"+HWS_Setpoint.state+"/"+HWS_Deadband)
                if(HWS_Demand.state != ON){
                        HWS_Demand.sendCommand(ON)
                        logInfo("HWS Status","Demand - "+Heating_Demand.state)
                }
        }
end

so the benefit that VScode gave me was highlighting the line where the error was, but I have no idea why it is an error in the first place.

Any ideas?

another thing with vscode, it wouldnt let me save the file I had changed, so I had to copy it and paste it into the ssh terminal then save that way. Is there a way to get the privileges when trying to save? I couldnt see in the settings and couldnt see anything about it with a google.

Linux has a very strict file access permission policy.

Add your user in this case pi to the group openhab. For the group policy to have effect you must reboot.

sudo usermod -a -G openhab pi

Change all file permissions in the openhab folder to be read, write, execute for owner and group, and to be read and executable by all. This has to be repeated eg, when you install a new binding, the cfg for the binding will not have the permission set. I set the sgid bit to make the files and folders inherit the file permissions from the parent bu it seems not to work. I have not look into ACL managment which would be the next step.

sudo chmod -R 2775 /etc/openhab2

Now after reboot you should be able to edit and save the files.

The benefit of VSCode is, it helps a lot.

The Items are all object types. This means they are more then e.g. just a plain number. They have functions you can call and the information is store into them.

Contact  ContactItem
Switch   SwitchItem
String   StringItem
Number   NumberItem
DateTime DateItme

If you want to get the number from NumberItem you need to

var aNumber = NumberItem.state
var aString = StringItem.state

here you can see getting a state from a string can not compare with a state from a Number.
I don’t know how your Items where defined, so this is just an assumption.

Also the error when you hover over the red marked Variables will help you resolve this errors.

Type mismatch: cannot convert from State to Number

To put it simple, the runtime environment is sometimes able to guess what you intended to do but not always.

But explicitly converting the value from item state to a number object will solve that.

if( ( NumberItem_1.state as Number  ) > ( NumberItem_2.state as Number ) ){
    logInfo("Show me your number", NumberItem_1.state.toString )
}

To get into this you have also post your items file.