Validation issue in rules: Assignment to final field

Hi guys,
when I copy the content of one variable to another in a rule as shown in the code snipped below (Tem_LR = Tem_LR_h), I get the following message in my log file

2017-12-04 09:15:35.421 [INFO ] [el.core.internal.ModelRepositoryImpl] - Validation issues found in configuration model 'default.rules', using it anyway:
Assignment to final field

The string “Assignment to final field” is repeated for every instance I copy the content to a variable.
Does anyone have an idea how I can get rid of this message?

// Temperature Definitions
// Window open temperature
val Number Tem_WO = 10
// Living Room Temperatures
val Number Tem_LR_h = 20
val Number Tem_LR_l = 18

// Variables to store target temperatures, includes manual changes
// The manual changes will we overwritten according to the timetables
val Number Tem_LR = Tem_LR_h


//Week Plan
rule "SAT-SUN Living Room Morning Heating"
when
	Time cron "0 00 07 ? * SAT-SUN *"
then
	if(Tem_LR < Tem_LR_h)
	{
		Tem_LR = Tem_LR_h
		if(Contact_Shutter_LR.state == CLOSED)
		{
			sendCommand(SetTemperature_Thermostat_LR, Tem_LR)
			logInfo("rule", "SAT-SUN Living Room Morning Heating started")
		}
		else
		{
			logInfo("rule", "SAT-SUN Living Room Morning Heating Temperature set but not started since window is open.")
		}
	}
	else
	{
		logInfo("rule", "SAT-SUN Living Room Morning Heating not started since temperature is already equal or higher.")
	}
end
  • Platform information:
    • Hardware: Raspberry Pi 3
    • OS: openhabianpi-raspbian-201706161358-git7ff273e-crc00389b9f.img
    • Java Runtime Environment: not sure, I didn’t change anything from the installed OS
    • openHAB version: 2.1.0 release build

Thank you very much for your replies!

1 Like

From memory, that is a problem in global namespace. You cannot I think assign another global value outside of a rule?

If you do intend to alter that value later in a rule, which is what you seem to be doing, make it a var not a val (fixed)

3 Likes

Yes, changing Tem_LR to a var solved the problem.
Thank you very much!!

PS: I just realized that during all the time I considered val to be a variable and totaly mixed that up with var.


    val -> value (a fixed value, not to be changed during runtime)
    var -> variable (can be changed during runtime, anytime)
3 Likes

Yes, got it now. :wink:
Interestingly, the code still worked.
Only when I changed the rules file, I had the mentioned info in my logs.