Multi Zone Home Alarm Script for openHAB

Hello there.

What about a Multi Zone Home Alarm Script for openHAB?

Some people will claim that a Home alarm system should be a dedicated one to provide the highest security available. That might be true but some of us might not want to spend that extra money. Some of us already have scripts, more or less developed for doing this task using the existing sensors and devices available in openHAB.

I’ve been working with a Multi Zone Home Alarm Script for openHAB written in jsr223 jython. While it actually works fine at my installation it can probably be improved in many ways. I have tried to make it as generic as possible. I’ve given the project the name ideAlarm.

ideAlarm fetures in short:

  • Suports multiple zones that can be managed independently of each other.
  • Configuration in separate file
  • Custom event helpers will let you script whatever should happen on your system at various alarm system events.
  • Entry and exit delays
  • 2 different arming modes (Home and Away)
  • Individual sensor configuration with the possibility to create sensor functions
  • Built in “nagging feature” that will harass you (by sound notification etc) when you have unlocked door/open windows. Nagging can be set per sensor.
  • Provides an item for each alarm zone defined that constantly tracks number of open sensors. You may use this for scripting. (Why not turn on a red lamp whenever a door is unlocked?!)
  • More …

ideAlarm is available on GitHub as part of the Helper Libraries for openHAB Scripted Automation.

To install ideAlarm, you should already have some skills when it comes to openHAB, jython scripting, debugging and the linux environment in general. Of you find an issue, please report it here.


Ohh… I almost forgot to mention the built in Nagging Feature. Finally you can be sure that all your doors are locked even when at home. I’ve added it in the initial post.

Home Security Alarms are meant to be monitored by an external, certified monitoring system. DIY Home security alarms will never have a certificate, so any insurance company will not give you anything for it. I would call your system an “alert” system, as opposed to an actual alarm system so that it won’t give potential users the confusion.

I did build my own home alarm system using a combination of DIY sensors and certified sensors, and is monitored by a certified external company.

Thanks for your suggestions @luckymallari

You are sure right about that ideAlarm will never be graded and as such won’t meet the requirements of home insurance companies. It won’t allow to become a professionally monitored security system. No doubt about that. Another con is that there is no manufacturer being able to answer questions or a regular tech support that you can call. There is also a risk of setting up the DIY system incorrectly.

I believe that it’s very important to inform clearly about what to expect when building a DIY home alarm system. We could use some help improving that part of the wiki from a native English speaker.

It’s my believe though that not all of us are willing to pay for monthly monitoring to a surveillance company and maintenance contracts. For some of us, it’s perfectly enough to keep an eye on our property and possessions using the gadgets we already own, together with free software. As a bonus, we get a system that’s very well integrated with openHAB.

My key point here is that both a DIY system (as ideAlarm) and a professional alarm system offer benefits and drawbacks. Both kind of systems provide a certain level of protection for your home.

I’ve used ideAlarm some time (it was originally written for another HA system) and it has helped me to take some video footage of a burglar and the sirens scared him away from my property before he was able to actually steal anything in my garden shed. I keep the garden shed door unlocked at night so there won’t be any damage on the door in case of “uninvited visitors”. It has been working like a charm for me. The new version of ideAlarm written in python aimed for openHAB hasn’t been in use for so long so I haven’t caught any burglars yet.

1 Like

ideAlarm version 1.0.0 released.

New in version 1.0.0

  • Added version info string to logging.
  • Added ideAlarm function version()

Due to lack of public interest for a script like this I’ve decided to delete the repository on gitHub. After all, there would be some work in maintaining it.


Hi RRoe,
Maybe you would reconsider as deleting such an effort just 21 days after initial release, it’s a little premature to say the least!
Most open-source projects take some time and effort to build engagement, and this project has some features which interest me in a number of ways. Not being a programmer myself - I cannot offer my skills to add to it- but I was going to propose some of the enhanced features which alarm systems have, such as gross attack and pulse-count.

So perhaps build on what you have and the community support will follow.
Good luck, R.


Thanks @RonnieLast

You are right of course and I can certainly reconsider and let the future show if there is an interest in using and contribute to the project.

Please feel free to suggest new features.



I agree with @RonnieLast that maybe you need to wait a little bit more. There are so many contributions in this community that finding a contribution that interests oneself often happens by chance.

I would for example be quite interested to contribute to your project. Here are some first ideas for additional features:

  • use persistence for logging alarm related events, rather than openhab log which I believe is more meant to debug the installation itself
  • define a pre-alarm state for some zones/sensors. One use would be a sensor that does not have the level of confidence sufficient to trigger a full alert status but which may be interesting to trigger a pre-alert
  • Define an “Armed pets” state for the zones, in addition to existing “Armed home” and “Armed away”, for pet owners.

I need to install and try your script first. Did you perform any update since the initial posting ?


This looks very good indeed, lots of work!
I don’t have enough sensors installed yet to be able to call them an alarm system but I will certainly look at installing your system when I am set-up
Good work!

1 Like

That sounds great @tarag

I’m happy for any contributions to improve the code and documentation.

All alarm related events are already persisted by each alarm zones arming mode item and status item, e.g. Z1_Arming_Mode and Z1_Status. It should be nice to be able to set a separate log file though…

About the suggested “Armed Pets” arming mode. Maybe it can be achieved already by disabling certain sensors under certain conditions (pets presency), that is, using a function for the sensors “enabled”-property see here. I guess that the suggested “Armed Pets” arming mode is all about disabling certain sensors when the pets are at home, right?

That’s right, some sensors may not be pet proof. You may want to enable to enable window contacts for example but not PIR sensor. From a concept standpoint, it looks very similar to me as away and home modes and therefore, I think it would fit quite well with the sensor class attribute.

Yet maybe a function is more appropriate for implementation. I really need to try the script first. Is the one on GitHub the last version?

Yes, the version on GitHub should be up to date. :grinning:


I finally found a bit of time to give it a try to install version 2.0 of the alarm script. I followed the very detailed instructions (thanks!) for the alarm script itself and all the dependencies but got stuck on one error at the init of the script, which is probably obvious for some python guru but I am not:

[ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/': ImportError: No module named config in <script> at line number 2

So of course I did re-check that is valid python using the online tool.

Somehow it seems the instructions between installation of JSR223, lucid library and idealarm differ on the final path of the python modules (either $OPENHAB_CONF/lib/python or $OPENHAB_CONF/automation/lib/python), so I tried both. Ensuring the python.path startup variable was consistent…

I doubled check the permissions to check that openhab user was able to read and write in all python library directories.

I tried to document myself on python packages, and so far I don’t see what could be wrong. Could you please help me ?

My understanding is that OH only loads/reloads modules on startup. I know I read this somewhere, and I haven’t been successful proving it wrong! Is it possible you copied the files while OH was running and haven’t restarted yet?


I will try to help you and I will also check that the documentation is consistent between ideAlarm and lucid.

Thanks also to @5iver for helping out, it’s very appreciated.

For some reason it seems that the $OPENHAB_CONF/automation/lib/python/idealarm/ can not be found.

  1. I’d like to see what you’ve set the EXTRA_JAVA_OPTS environment variable in /etc/default/openhab2 to.
  2. Did you restart openHAB after setting EXTRA_JAVA_OPTS ?
  3. What is the path name for your ideAlarm config file?
  4. What is the path name for your lucid config file?
  5. Does a simple lucid script work for you? Please try one of the lucid examples.

Please provide the information above and I will try to solve this. Thanks!

1 Like

Thanks for your help.

1 - Here’s the config:

EXTRA_JAVA_OPTS="-Xbootclasspath/a:/home/openhabian/dep/jython/jython-standalone-2.7.0.jar \
  -Dpython.home=/home/openhabian/dep/jython \

2 -I did restart every time I made a change to make sur it did not come from the lack of dynamic reloading.

3 - Here is the full path of the files:

[08:59:37] openhabian@openHABianPi:/etc/openhab2$ tree automation
├── jsr223
│   ├──
│   └──
└── lib
    └── python
        ├── idealarm
        │   ├──
        │   ├──
        │   ├──
        │   └── __init__$py.class
        └── lucid
            ├── clickatell
            │   └──
            ├── __init__$py.class
            ├── jsr223$py.class
            ├── log$py.class
            ├── osgi
            │   ├──
            │   ├── events$py.class
            │   ├──
            │   └── __init__$py.class
            ├── rules$py.class
            ├── triggers$py.class
            └── utils$py.class

4 - I skipped lucid config creation since it was marked as optional, maybe the issue comes from this. I’ll try see if it works. I did not think about it at first because I had not noticed that the lucid config should have had the same name…

5 - I could not find the to test lucid, and the examples needed binding or items that I had not at hand, so I admit, I skipped that part too.

Initially I thought that the lucid configuration file can be an optional step but I’ve changed that now in the documentation.

I’ve fixed that too. Thanks for pointing it out. I changed the documentation and I’ve added a “Hello World” script for you guys!

Awaiting your tests!

The jsr223 documentation suggests


But ideAlarm uses


I’ve changed the lucid install instuctions to recommend


Both works, but one must be choosen. I will make the ideAlarm documentation more clear on this point.


So at first I tried the following one line lucid configuration based on the instructions:

import lucid.config as config

But it wouldn’t work. Then I just used the example lucid configuration and it seems to work better but I still got another error.

2018-07-12 09:26:59.828 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/': org.eclipse.smarthome.core.items.ItemNotFoundException: org.eclipse.smarthome.core.items.ItemNotFoundException: Item 'Siren_Indoors' could not be found in the item registry in <script> at line number 2

After adjusting the idealarm/

I get the following error after restart:

2018-07-12 09:40:14.096 [ERROR] [ipt.internal.ScriptEngineManagerImpl] - Error during evaluation of script 'file:/etc/openhab2/automation/jsr223/': TypeError: can't set attributes of built-in/extension type 'NoneType' in <script> at line number 1

And after a second restart:

Sometimes during all these manipulations, lucid worked fine, and sometimes no, with the same error as above…