I have started to slowly migrate my rules to the NGRE.
However at first I have some problems and I couldn’t find an answer for these at anywhere (even at the helper libraries docs).
Have this rather simple rule:
from core import *
@rule("Everyone at Home", description="Updates the state of Everyone_Home item", tags=["presence"])
@when("Member of gPhoneHome changed")
everyone_home.log.info("Updating Everyone_Home state...")
if ir.getItem("Phone_Home").state == ON:
The warnings I got immediately:
ir is undefined. Where are these defined? What should be included? The docs only says the you can use ir.getItem("Item").
Also the ON state is also interpreted as an undefined variable. Are there any place here in the NGRE where are these constants are defined and be used in rules, so I don’t need to use it them as String?
I might know what my problem is here.
I have used Python in Visual Studio Code for other projects thus I have the Python extension (or what it is called) installed in VSCode. This only does static code checks and that’s why these warning appear here.
And I couldn’t see it working, because that Member of group didn’t received a changed yet…
I managed to get it working. Placing in the conf folder is right.
However after a restart VSCODE said that there is a pylint file, should pylint be enabled or something like this. But after pressing Yes, the same happened.
Opening the command palette and selecting Python Linter as pylint helped.
However if you can specify what should be turned off… Can it be somehow enabled (I mean specifying these in the pylintrc file) to auto-complete these default variables? Like you said items, and ir, events, etc… are in the default scope so it will be always available, so only a static list of these variables would be enough and really could help in the migration process, especially in typos…
I have saved this rule in the personal folder, but when it should trigger nothing happens. I suspect that I least should see the logging in the openhab.log but not. Even saving the file doesn’t give any output. Should it give something similar to Rules DSL when saving a file?
I don’t think so. When restarting openHAB I can see that the initial scripts (“StartupTrigger.py”) is loading. I suspect the same should happen when I save a file but not. A restart is required when saving a new file?
Ok, I know what the problem is now.
It worked before, but yesterday I have updated to 2.5 stable and changed to release through openhabian-config. That replaced the /etc/default/openhab2 file to the default one, so there is no extra Java opts there.
But I need the previousState not the time when changed.
And I need to use mapDB and mapDB is not the default Persistance service for me, that’s why I have to specify there to use that one.
What is the “True” in the previousState call?