So I had several undefined items remaining in the config for the alertDevices.
But what happened is that after each modification of idealarm/config.py and OH restart, if I don’t clean-up the .class files in automation directory, I get the same TypeError as above.
Anyway, now it seems to work! Thanks very much for your help!
So the conclusion is that the lucid/config.py is not an optional step (whatever is inside it), and some strange things happen with the .class files that get generated in the python path…
That’s a bit strange I believe. I’ve never needed to clean up those compiled “.class files” after I’ve change a configuration file.
The config file needs to be reloaded after a change, that’s normal and can be done in different ways (Restart openHAB is one of those methods or it can be done in the script which is faster) But as I said, I’ve never seen that changes are not picked up by the compiler after a reload. I’d have to check further on that. Maybe someone else knows what could have caused that.
Thanks to you, I’ve been able to do some changes in the documentation that I hope will make the installation smoother.
Please don’t hesitate to ask if you have further questions and good luck with setting up ideAlarm. What you get out of it is very much up to what you define in the Event helpers.
I just performed another change to idealarm/config.py and restarting openhab without any other action worked.
Yet it is a pity that a restart is necessary for all these changes, because it takes quite some time on a Pi and is far less convenient that what can be done for items/sitemaps …
I tried the console command indicated on the slack channel: bundle:restart org.eclipse.smarthome.automation.module.script.rulesupport
but it seems to only reload the main script 001_ideAlarm.py, but not the config.
001_ideAlarm.py is placed among other Jython scripts in the scripts directory. Modules must be in the lib directory. As such the module is loaded by Jython through the standard Python import directive and uses sys.path. So, it’s not possible.
I will try to come up with a solution. bundle:restart org.eclipse.smarthome.automation.module.script.rulesupport should work. I must do some testing.
Looks like it’s been a while - but interested if anyone is using this. First glance at the code and it looks like it can do everything I want. It is complicated for the average user - but that’s not a big worry.
I also made some improvements on the init.py script, mainly by adding the support of armWarn property of sensors.
With these modifications:
the arming fails only if opened sensors have armWarn set to True
When armed, armWarn=False sensors will trigger the entry timer (used for the front door), amrWarn=True will directly trigger the Alert mode (used for windows)
Remark: I only use the Armed_away switch, not the Armed_home one. So I did not test fully the modifications I made.
One question:
How to use actions addons in custom.py script?
from openhab.actions import Mail doesn’t work:
Error during evaluation of script ‘file:/etc/openhab2/automation/jsr223/001_ideAlarm.py’: ImportError: No module named openhab in at line number 1
You may want to look over at openhab-Jython. I’ll be updating lucid, and merging it back into this repo, along with weatherStationUploader and ideAlarm. Some will go into the core, some will go into community modules and scripts. I think I can get this in before the end of the year, after I wrap up this PR, which will hopefully pull things together to make it easier for us to share and collaborate on community modules, scripts and reusable code.
Thanks! I’ve made the corrections. I appreciate that you told me about it.
About the changes to the init script, I haven’t considered it yet. If you’d like to see it implemented, please consider to make a pull request to allow other team members to review it as well. It might be a good idea to wait until it’s merged into openhab2-jython repo.
I tried to get the idealarm script running and followed the wiki instructions.
I am running into the following error:
2019-03-08 17:39:59.397 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script ‘file:/etc/openhab2/automation/jsr223/001_ideAlarm.py’: java.lang.NoSuchFieldException: java.lang.NoSuchFieldException: uid in <script> at line number 16*
I did not change the script:
from lucid.rules import rule, addRule
from idealarm import ideAlarm
from lucid.utils import hasReloadFinished
@rule
class ideAlarmTrigger(object):
"""Make ideAlarm trigger on item changes"""
def getEventTriggers(self):
return ideAlarm.getTriggers()
def execute(self, modules, inputs):
if not hasReloadFinished(True): return
ideAlarm.execute(self, modules, inputs)
The new ideAlarm has been migrated to be using the openhab-helper-libraries as a community (former openhab2-jython) as a community script and has been tested for a couple of weeks here with no known issues. However the documentation needs to be rewritten and after that I’ll start a topic (or maybe I just continue here) to sum up what needs to be done to upgrade. Anyone interested to upgrade without the new documentation could try to do so but that’s nothing that I’d recommend. Instead I’d recommend to wait a little bit further for the new documentation to become ready.