.rules file not recognised by opehab

Hi all, I’m sorry to post this is it’s already covered by I can’t find the answer in the community posts.

I’m new to openhab. I have openhab 2.5 up and running on a windows 10 machine and have written the beginning of my .things, .items, .sitemap files in VScode but can’t get any rules to work. I have written a .rules file but nothing happens and I can’t find any reference to it in the logs.

I’ve noticed in VScode that all my other config file show an icon when I type in the correct extension name but this doesn’t happen for my .rules file.

I seems as though openhab and VScode are not recognising the file. Has anyone else seen this before? Can anyone offer any advice? I’ve tried copying a .rules file from a demo installation an this isn’t recognised either. Do I need to have a binding installed for the .rules file to be recognised?

Everything else is working just fine. I can send a receive MQTT commands but can’t make any rules work.

Any help will be greatly appreciated.

There is nothing special to use rules, other than:

  • Rules files must be placed in the ./rules/ directory
  • Rules files must be named like my.rules (where my may vary)

Rules files will be ignored if there are severe errors in it, but openHAB will log a message (’… file has errors, therefor ignoring it’

In question of your version: Which version exact do you use? Please don’t try the nightly version for now, as there may be severe issues. Either use openHAB2.4 (aka stable) or openHAB2.5M1 (aka milestone or testing).

Hi Hartmann,

Thanks for the fast response. What you have states about the .rules file location and .rules naming is what I have followed. This is why I’m at a loss of what step to take next.

I am using openHAB 2.5.0 Build#1589. Can you suggest a direction to take from here? There is no mention of rules in the openHAB log file. It seems like openHAB is not seeing the file at all. I am using VScode to create and edit the config files.

If the file-location and -extension are correct you should see a message in the log for each update/save of the file.

Thank you both for your fast responses.

I think I have resolved the issue. The .rules file was probably working but the log was being over populated by entries for an unrelated issue. Once I fixed this I was able to find the log entries you have both mentioned. I think the rule is not functioning due to errors on my part. Could you offer come insight as to what I am missing in the below code. As is probably obvious I am new to this world so the answer might be glaring. This is the entire content of my rules file. Do I need to declare and use a variable for this to work?

I appreciate any answers to what is probably a very basic question.

rule "Security alrams trigger"
    Item Security_Trigger recievedCommand
    if (recievedCommand == ON) {

Well, mostly typos. It is received, not recieved.
And for the when part, it should be

Item Security_Trigger received command

I have been reading through the documentation but must have changed the syntax during my fault finding and well, there is no excuse for poor spelling.

I now have a test rule up and running and a platform to build from.

Thank you all for contributing.

1 Like