openhab / org.openhab.ui.habmin

HABmin - a graphical user interface for openHAB 2
231 stars 92 forks source link

Creating a rule variable causes 'null' errors #292

Open Rubidze opened 5 years ago

Rubidze commented 5 years ago

As soon as I add a variable to my rule designer it adds var null LED-status = 0 to the rules file and OpenHAB gives me an error: [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model '(5)_nupuga_tuli_vilkuma.rules' has errors, therefore ignoring it: [10,5]: no viable alternative at input 'null' [19,16]: no viable alternative at input '=' image

ddoll commented 5 years ago

Maybe try a variable without a minus in it’s name. Don’t know exactly if this could be a problem. For example: “LED_status” or “LEDstatus”

Rubidze commented 5 years ago

Thanks @ddoll for your input! Changing variable name did not solve the problem, but your suggestion lead me to other ideas to try.

For others who may happen to come across this issue, it appears, we can't use item states (On, Off, Open or Closed) as variables. Using a logic value, such as number (1,2,3,etc.) or boolean (True, False) doesn't try to create a variable called "null" and instead creates a usable variable. OpenHAB doesn't throw described error anymore.

Using boolean will look like this: image And variable in a code looks like this: image

Rubidze commented 5 years ago

@ddoll, I have to add that you are also right about minus in variable name. When changing variable back to include minus, it stopped working. It appears I had two problems. Variable can't have a minus in it and can't use item states as values.

ddoll commented 5 years ago

It was my pleasure to help. Don’t forget to close the issue.