Multi Zone Home Alarm Script for openHAB

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!

2018-07-12 09:56:47.910 [DEBUG] [lucid.IdeAlarmZone.Rez-de-chaussée ] - Open sensor: F0_Bureau_Fenetre_CTS
2018-07-12 09:56:47.920 [DEBUG] [lucid.IdeAlarmZone.Rez-de-chaussée ] - Number of open sections in Rez-de-chaussée is: 1
2018-07-12 09:56:47.931 [DEBUG] [lucid.utils                         ] - New postUpdate value for Z1_Open_Sections is 1
2018-07-12 09:57:00.284 [INFO ] [lucid.HelloWorld                    ] - Hello world from lucid!
2018-07-12 09:57:00.325 [DEBUG] [lucid.IdeAlarmZone.Rez-de-chaussée ] - Number of open sections in Rez-de-chaussée is: 0
2018-07-12 09:57:00.332 [DEBUG] [lucid.utils                         ] - New postUpdate value for Z1_Open_Sections is 0

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.

Cheers!

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.

We’ll see if we can come up with a convenient solution for that.

It would be nice if most of the config scripts are moved out of the lib folder so any change made is automatically refreshed.

Like in the same place as 001_ideAlarm.py

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.

It’s currently working with openHAB 2.3. It will be ported to 2.4 but that work hasn’t been done yet.

Ahh ok. So it’s not working with 2.4? I will have to wait then.

Hi,

Thank you for the great work on this. I’m in the process to migrate my automation system to OpenHAB, and your work saved me a lot of time.

I started to use it on OpenHab 2.4, but moved to 2.3 when I saw it was not compatible. I will happily test a new version compatible with 2.4.

I have a few remarks on the documentation (sorry, I didn’t take the time to check how to do a pull request on the Wiki)
In First Installation:

  • A reference to MAP Transform should be added in the Prerequisits section
  • The commands off Download mapping files section does not have the intended behavior. Here is the modified version (I changed lines 2 and 3)
    sudo wget -O $OPENHAB_CONF/transform/en_armingmode.map https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/transform/en_armingmode.map
    sudo chown openhab:openhab $OPENHAB_CONF/transform/en_armingmode.map
    sudo wget -O $OPENHAB_CONF/transform/en_zonestatus.map https://raw.githubusercontent.com/OH-Jython-Scripters/ideAlarm/master/transform/en_zonestatus.map
    sudo chown openhab:openhab $OPENHAB_CONF/transform/en_zonestatus.map

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.

You can see all the changes here : https://github.com/maskimfr/ideAlarm.

Hope this will help you to improve your script.

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.

This may help you with using binding Actions.

1 Like

Thank you very much for your answer.

For now I used rules to handle binding actions instead of custom.py script. I will have a look to your solution when you will have merged it

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.

Thanks!

Hi,

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)

addRule(ideAlarmTrigger())

Any ideas?

You’re using a version of OH that the lucid modules do not (yet) support. I worked on getting them migrated back into openhab2-jython, and I’ve gotten distracted, but I will get back to it soon!

1 Like

just to let you guys watching this thread know that ideAlarm has been migrated by @5iver and @RRoe. The new link is https://github.com/openhab-scripters/openhab-helper-libraries/tree/master/Community/IdeAlarm.

1 Like

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.

3 Likes

The new ideAlarm V4.0.0 documentation is located at https://openhab-scripters.github.io/openhab-helper-libraries/Python/Community/ideAlarm.html

1 Like

thanks this looks like what im looking for been integrating some mysensors into openhab with the view to make an alarm

1 Like