Multi Zone Home Alarm Script for openHAB

I have been looking at this to superseed my homegrown alarm, since it looks quite promosing for my use case.
Now I have finally looked at it, and I must admit it is almost there.
I have one tiny problem that I can’t figure out.
When a zone is alerted, the status stays alerted also after things has settled down.

In my case I would like to have an possibility to allow a zone to automatically reset after an alert. I have some zones that is triggered by outdoor PIR sensors. If PIR sensors in in multiple zones is activated I want some spots to be turned on. And hopefully the unwanted persons leaves and the alarm should be ready to fire again. It is fine that I get the possibility to do some alerting in the callbacks :slight_smile:
I just need the possibility to auto reset (without disarming)
Would that be possible?

You are right, the alerted status stays remains alerted until acknowledged by you (when you disarm the zone). There is currently no built in function for the zone to reset itself. However you create an item and puts an expire timer on it like this:

Number Zone_Alert_Timer  {expire="120s,command=0"}

At an alert you set the item to some value and then you could easily write a simple script that detects when the item changes and disarm the zone, wait afew secs followed by arming it again. Wouldn’t that be a nice solution for you?

I have thought of that solution, but would like to avoid disarming a zone. This is because i plan to have some overall handling of which zones is armed, based on scenario ( time of day, who is present, and so forth).
Your sucgestion would do for a shorter time, but it is definately a feature request to have a reset switch to avoid disarming. I think of it as feature that can be Disa ked like nagging, possibility to arm with trigger ed sensor. I would like seeing that feature :grinning:.

Hi @RRoe
Can you please make a simple tutorial for using ideAlarm Package.
I am really struggling to get started as I found the instructions in the docs a bit confusing and also incomplete like the configuration page is empty. I really appreciate your work. It would be a lot more beneficial for everyone if you make a noob friendly tutorial about it.

One thing I have recognised when installing ideAlarm was that I need to create some items for each zone. Most of it is actually configurable in the configuration.py file, besides from these five items, they MUST be named like this (for zone 1):

Number Z2_Open_Sections        "Zone 2 open sections [%.0f]"                        <door>      

Switch Z2_Entry_Timer          "Zone 2 entry timer [%s]"                            <time>              {expire="15s,command=OFF"}
Switch Z2_Exit_Timer           "Zone 2 exit timer [%s]"                             <time>                 {expire="2m,command=OFF"}
Switch Z2_Nag_Timer            "Zone 2 nag timer [%s]"                              <time>                  {expire="4m,command=OFF"}
Switch Z2_Alert_Max_Timer      "Zone 2 alert maximum time [%s]"                     <time>      {expire="20s,command=OFF"}

If you are not familiar with writing code you will most probably get sucked, it is a little tricky, but if you solve one problem at the time it should be possible.

Hi @RRoe,
I was wondering what the differences is between ArmAway and ArmHome? The only thing I have found is the Exit / Entry timer, but is there something else?

Hi @mr_eskildsen. Seems like you are using ideAlarm successfully. Do you mind sharing the steps to get started with setting up ideAlarm.
I opened the link https://openhab-scripters.github.io/openhab-helper-libraries/Python/Community/ideAlarm.html and got lost in between there.
Can you please outline the steps to install ideAlarm.

  1. Make sure openHAB Rule ENgine addon is installed
  2. Follow the steps here to install openhab-helper-libraries
    https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html#installation
    Step 12 will verify that it is installed correct
  3. Verify in your log that step 12 was successfull
  4. Copy files from ideAlarm into appropriate folder. They are already organised correct in the repository
    https://github.com/openhab-scripters/openhab-helper-libraries/tree/master/Community/ideAlarm
  5. Make sure to configure ideAlarm as described, stick to the sample config for a start:
    https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html#community

You should look carefully in your log files, and as I wrote programming skills is probably needed. Make sure that the RuleEngine doesn’t write error log entries. Step 1- 3 can cause some problems, this has nothing to do with ideAlarm, this is a prerequisite. Search the forum to solve problems, other people might have had similar problems.

If you encounter problems and can’t find an answer in the forum, ask in the forum, remember to describe what you have done and what is the error, it is hard to help if you doesn’t provide any information of what you have tried. :grinning:

1 Like

Thanks a lot @mr_eskildsen . I’ll try to follow that and report back.

Thanks for the suggestion.

ideAlarm has as you know it’s own documentation. My goal is that the installation instructions section should contain all the necessary steps, explained in an easy way to get started with ideAlarm.

Before trying to install ideAlarm, it’s important of course that openHAB Helper Libraries which ideAlarm is a part of is installed, tested and working. Then of course it’s important to follow each installation step carefully as they are there for a reason.

However, the current documentation can and should be improved in several aspects. If there are any errors please report them as an issue here and we’ll be able to deal with it. If you “get lost” in a specific part of the documentation please let us know where and we’ll check it out.

Thanks

1 Like

I’ll surely be trying to install this in the coming week and report back. Thanks
:smiley:

Each sensor has a sensorClass defined in the configuration. It can either A or B.

A, sensor can be tripped in both arming modes. E.g. “Armed Home” and “Armed Away”.
B, sensor can be tripped in arming mode “Armed Away” only.

For example if you stay at home and arm “Armed Home” when (e.g. you go to sleep) you probably don’t want PIR motion sensors to trigger an alert if you happen to walk around in your house in the middle of the night for whatever reason. So, set those sensors to sensorClass B. At the same time you want to be aletered if someone opens the front door (set those sensors to sensorClass A.)

See: Glossary — openHAB Helper Libraries documentation

1 Like

Thanks for the clearification. That will certainly be helpfull. Should have read the glossary more carefully… :blush:

During installation of the core, in the step 11 where it says to download the jar file “Download the standalone Jython 2.7.0 jar”, the page is not found. Is this a mandatory step?? Is there some alternative??
Edit: Found correct link is standalone Jython 2.7.1 jar. Should I go for 2.7.1 instead of 2.7.0. Or should I find the recommended version 2.7.0 instead??
In the meantime I am installing 2.7.0 from the page https://mvnrepository.com/artifact/org.python/jython-standalone/2.7.0

Okay the 11th step went well. i could not understand the step 12 though.It says "Copy the /Script Examples/Python/hello_world.py script to /automation/jsr223/python/personal/"
But where is the hello_world.py file. I am really confused now. What am I missing
Just to add, this is the log output

2019-11-29 22:19:32.880 [INFO ] [openhab.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2019-11-29 22:19:33.979 [INFO ] [b.core.service.AbstractActiveService] - Expire Refresh Service has been started
2019-11-29 22:19:35.656 [INFO ] [io.openhabcloud.internal.CloudClient] - Connected to the openHAB Cloud service (UUID = f4ded7d9-b9c1-4dc9-8572-df25a155f1b5, base URL = http://localho$
2019-11-29 22:19:35.895 [DEBUG] [.AutomationResourceBundlesEventQueue] - Process bundle event 2, for automation bundle 'org.openhab.core.automation'
2019-11-29 22:19:35.905 [DEBUG] [vider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation'
2019-11-29 22:19:35.904 [DEBUG] [.AutomationResourceBundlesEventQueue] - Process bundle event 32, for automation bundle 'org.openhab.core.automation.module.script.rulesupport'
2019-11-29 22:19:35.910 [DEBUG] [vider.AbstractResourceBundleProvider] - Parse rules from bundle 'org.openhab.core.automation.module.script.rulesupport'
2019-11-29 22:19:36.231 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added CoreModuleHandlerFactory
2019-11-29 22:19:36.235 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added EphemerisModuleHandlerFactory
2019-11-29 22:19:36.239 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added TimerModuleHandlerFactory
2019-11-29 22:19:36.243 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedActionModuleTypeProvider
2019-11-29 22:19:36.367 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added AnnotatedThingActionModuleTypeProvider
2019-11-29 22:19:36.495 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added MediaModuleHandlerFactory
2019-11-29 22:19:36.638 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added GenericScriptEngineFactory
2019-11-29 22:19:36.651 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngineFactory details for Oracle Nashorn (1.8.0_232): supports ECMAScript (ECMA - 262 Edition 5.1) with $
2019-11-29 22:19:36.655 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added NashornScriptEngineFactory
2019-11-29 22:19:36.658 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngineFactory details for Oracle Nashorn (1.8.0_232): supports ECMAScript (ECMA - 262 Edition 5.1) with $
2019-11-29 22:19:36.664 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Removed GenericScriptEngineFactory
2019-11-29 22:19:36.667 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Removed NashornScriptEngineFactory
2019-11-29 22:19:36.737 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added GenericScriptEngineFactory
2019-11-29 22:19:36.741 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngineFactory details for Oracle Nashorn (1.8.0_232): supports ECMAScript (ECMA - 262 Edition 5.1) with $
2019-11-29 22:19:36.744 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added NashornScriptEngineFactory
2019-11-29 22:19:36.747 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - ScriptEngineFactory details for Oracle Nashorn (1.8.0_232): supports ECMAScript (ECMA - 262 Edition 5.1) with $
2019-11-29 22:19:36.752 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptModuleHandlerFactory
2019-11-29 22:19:36.842 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedCustomModuleHandlerFactory
2019-11-29 22:19:36.868 [DEBUG] [e.automation.internal.RuleEngineImpl] - ModuleHandlerFactory added ScriptedPrivateModuleHandlerFactory
2019-11-29 22:19:43.387 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Error during the execution of startup rule 'Start Bauts Power1': 'plusSeconds' is not a member of 'null'; line$
2019-11-29 22:20:01.951 [INFO ] [me.core.service.AbstractWatchService] - Loading script 'javascript/core/000_startup_delay.js'
2019-11-29 22:20:05.647 [DEBUG] [ipt.internal.ScriptEngineManagerImpl] - Added ScriptEngine for language 'js' with identifier: file:/etc/openhab2/automation/jsr223/javascript/core/000$
2019-11-29 22:20:05.969 [INFO ] [jsr223.javascript.core.startup_delay] - Checking for initialized context
2019-11-29 22:20:06.097 [INFO ] [jsr223.javascript.core.startup_delay] - Context initialized... waiting 30s before allowing scripts to load
2019-11-29 22:20:36.209 [INFO ] [jsr223.javascript.core.startup_delay] - Complete

Update: Okay I found the script in Examples Folder.

Jython isn’t mandatory, but since most of the code snippets you will find around is Python, I would recommend it.
I believe 2.7.1 is fine, Remember to update the extra_opts accordingly

Hi !
I have posted the logs. Please have a quick look if that looks fine to you

Your logs is indicating that Jython isn’t running as you also write. As @RRoe wrote, each step in the install guide is there for some reason. If not done, then something would probably not work as expected.

Okay I think I should make a separate post to get help on this. Once it clears out, I’ll follow the rest of steps. Thanks

FYI… I plan to submit a PR this weekend for OHC that will include Jython and the helper libraries as an optional feature that can be installed through Paper UI. The installation will be much much much simpler :smile:! If you do create another post to get help with the installation, setup or beginner questions, please tag it with jsr223 so that others will be notified of your post (and feel free to @ me).

3 Likes