[SOLVED] OpenWebNet alarm in Openhab

I would like to add a button to enable and disable my openwebnet alarm from the openhab app.
I have three python script (https://github.com/francesco-re-1107/openwebnet-alarm):

  • one that enables the alarm
  • one that disables the alarm
  • one that get the alarm status (a number 0/1)

I would like to create a switch that when clicked if it is ON it executes the disable alarm script
if it is OFF, it executes the enable alarm script.
This is not so difficult, with the exec binding.
But I would like also to update the alarm switch state when the output of the alarm status script has changed, because the alarm can also be enabled/disabled from the physical interface.

How can I achieve this?
I’m sorry for this question but I don’t know how to do it.


What version of OpenHAB?
How is your alarm controller by OpenHAB (what binding?)

firstly, thank you fro your reply.
I’m using OH2.5
For controlling my alarm I have the three python scripts listed before. So I guess I need to use the Exec binding to execute those scripts.


OH 2.5 is not scheduled to be released until the end of this year. There are various testing & Unstable versions now though. Which one? Milestone 4 was released within the past day.

Sorry for the imprecision, I’m using OpenHab version 2.5.0-SNAPSHOT for Windows.

And which SNAPSHOT version? They are released nightly.They are expected to have errors which can be reported through GitHub.
Snapshot versions are not usually recommended for daily use unless developing a binding.

Build is 1606, but I don’t think this is relevant in order to find a solution to my problem.

You need to create switch items to enable you alarm
You then need to write a rule triggered by the state of that item


https://www.openhab.org/docs/tutorial/rules.html and https://www.openhab.org/docs/configuration/rules-dsl.html

Have a go
You will need to use the Exec actions: https://www.openhab.org/docs/configuration/actions.html#exec-actions

Have a go. Try it. Come back to us if are stuck or publish your working code.
We will help if you make an effort but we will not write code for you.
I can write it for you but I’ll charge…

I’ve checked out your links and finally I found a solution.
I’ve used a secondary item that maintains the state of the alarm.
Then there’s a rule that is triggered when that item changes.

Thank you

Please post your code
It’s good to share and we may have good advice about it

This is the functional code that I used.

This is myItems.items
Switch Allarme "Allarme" ["Switchable"]
String Stato_allarme {channel="exec:command:alarm_state:output"}

This is myThings.things (obviously I’ve used the Exec Binding)
Thing exec:command:alarm_state [command="C:\\Python27\\python.exe C:\\openwebnet\\stato_allarme.py", interval=10 , autorun=true ]

These are the rules:

rule "Alarm state changed from 0 to 1"
    Item Stato_allarme changed from 0 to 1

rule "Alarm state changed from 1 to 0"
    Item Stato_allarme changed from 1 to 0

rule "Alarm received ON command"
    Item Allarme received command ON
    executeCommandLine("C:\\Python27\\python.exe C:\\openwebnet\\enable_alarm.py")

rule "Alarm received OFF command"
    Item Allarme received command OFF
    executeCommandLine("C:\\Python27\\python.exe C:\\openwebnet\\disable_alarm.py")

And lastly this is the sitemap:

Switch item=Allarme icon="siren" mappings=[ON="ON",OFF="OFF"]

Hope this will be helpful for other newbies.

Can you share the 3 python scripts as well?
It may be useful for others until the OpenWebNet binding will support alarm.
I also suggest you add BTicino in the thread title so that is more focused.

Yes, sure.
I’ve created this repository with all the code: https://github.com/francesco-re-1107/openwebnet-alarm
And I’ll change the title so it is more specific.

1 Like

Thanks! You may also mark the thread as SOLVED on the answer (even yours) that has solved your problem.

Hi, so with this solution you no longer need F422? is a 3477 enough? I refer to cases where I only have the burglar alarm system without lights and roller shutters.

probably yes, you will no longer need F422 but I can’t tell you for sure.


Hi, I wanted to test openhabian 2.5
I wanted to know if the scripts work.
I don’t know exec well.
What would be the path for openhabian?

This is what you used on windows.

executeCommandLine (“C: \ Python27 \ python.exe C: \ openwebnet \ disable_alarm.py”)

While in openhabian linux?

also the scripti you created should be placed in the addon script folder?

if you want to use my scripts in openhabian you need to:

  1. Download Python (version 2.7.x) from here
  2. Download my scripts from here and put them in /home/openwebnet for example
  3. Install the Exec binding in your openhab instance (more info here)
  4. Use
    executeCommandLine(“/path/to/python/installation/python /home/openwebnet/enable_alarm.py”)
    command in your .rules file when you want to execute a script

Ok thank you very much I try and update you

Unfortunately I was unable to manage the scripts.
I have given up for myself as I am not a programmer a mountain too high to climb …
However I solved it like this:
I installed a 3477 on the anti-theft scs bus.
I have configured the first Aux 1 channel ON and the second Aux 1 channel OFF. Then I have 2 shelly 1s that will command the two interface contacts.
This is a tip for everyone who has only the alarm scs bus at home.
Then I also ran a rule that allows me to use the shelly contacts alternately.