Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Developing Solutions for the Alarm Panel


andyb749

Recommended Posts

I want to use my HC2 as a replacement for my aging alarm system.   Yes I know there are people who say don't build an alarm system with z-wave devices, but here's what I've come up with so far.

 

I want to be able to use the Fibaro Alarm Panel to enable, disable the arming of my system, to report on breaches and set off the sirens I have.   It should have been easy to find the appropriate API call to arm, disarm and get the status but seemingly nothing exists.   I did a bit of digging and found that when the arm button is pressed there is a call to /api/devices/1/multiSetArmed with a list of all the devices that need to be armed.   I played with that for a while and it wasn't as elegant as I wanted so I abandoned it in favour of my own code.

 

I use two scenes, one to disarm, one to arm along with a virtual device.   Each all use the same piece of logic to iterate around the security devices:

Please login or register to see this code.

This snippet of code returns a list of all the security devices in my system that are enabled i.e. don't have the Sensor Is Excluded from Alarm checkbox ticked in the advanced properties.   This almost meets my desire to have elegant code and above means I don't need to worry about hardcoding device IDs everywhere.

So moving straight to the code, here's the arm scene:

Please login or register to see this code.

The unarm scene is almost identical.  Only changes are in the arguments for the "setArmed" method:

Please login or register to see this code.

These go round each enabled security device and arm or disarm it as required and Fibaro Alarm panel keeps up to date with the progress.  Any doors that have an alarm delay on them also work as expected and during the delay the Alarm Panel shoes the partially armed state, followed by the fully armed when the delay time expires.

For ease and status I created this virtual device to find the status and present a easy to find device for my users:

Please login or register to see this image.

/monthly_2017_09/image.png.52779cbe6443aa1d3cd72e43f159bf9e.png" alt="image.png.52779cbe6443aa1d3cd72e43f159bf9e.png" />

The code behind this each button simply calls the appropriate scene to arm or unarm.  This bit I don't like as I have to manually find the alarm scenes IDs.  I could have put the arm/unarm code in this device, but I want to be able to call the scenes using other devices like keypads etc and controlling a virtual device is a pain.  If Fibaro get around to allow developers to create plugins then I'll keep all the code in one device, but until then....

The Status label using the same snippet of code to find the security devices and this time in the for loop I have two counters.  The first one counts the total number of devices, the second counts the number that are armed.   The logic then checks if the number of armed is 0, and if so the status is UNARMED, if the number of armed equals the number of security devices, then the status is "ARMED" otherwise if the counts are different then we're partially armed.

Please login or register to see this code.

There's probably a method in Lua to find the size of an array/table and save a bit of code, but I'm not to familiar with Lua.

The complete VD code is attached, just change the scene IDs for arming and unarming to those on your system.

Back in the Fibaro Alarm panel I've enabled the Lights Scene and added my sirens as the devices to trigger.  Its a real shame that Fibaro failed to have a scene which catered for sirens and went for lights, window blinds and everything else as I'd like to have the sirens set in the system as an alarm device not as a light.  On a side note if you set an actor as a security breach device it disappears from the main pages.

 

The next stage is to get a keypad device, either the Zipato RFID, or a homebrew device using the Universal Sensor or the Z-Uno using one of these RFID keypads

Please login or register to see this link.

 .  I'm leaning towards the Z-Uno as it has a lot more pins that I can use for giving feedback about armed/unarmed status.  That's still very much in the experimental stages for now, but I'm happy that I can now easily arm/unarm the Fibaro Alarm.

Please login or register to see this attachment.

Link to comment
Share on other sites

Hi @andyb749,

 

Thanks for sharing your code. It is very interesting. First thing I would change is add check if sensor is armed in the loop which arms them:

Please login or register to see this code.

Notice that you can get number of found devices by simply adding # in front of the variable name that contains devices ID's. This of course is valid only for flat tables eg.:

Please login or register to see this code.

Placing pause with fibaro:sleep(100) between command to arm sensor and checking status is necessary to give time to gateway to update new state of the sensor.

Now same solution can be used for disarming sensors.

 

Above solution is great when you want to arm all sensors, but what if you want to do partial arming? For example, when going to sleep you definitely don't want to arm all sensors but only ones that are downstairs. Also if you have pets that will stay at home then you don't want to arm motion sensors but only door/window sensors. So now question is how to achieve this?

 

There is one more thing. It is good practice to check for opened windows and doors before setting alarm because Fibaro door/window sensor will not arm if they are already breached. In that case you need to have a choice, either you will first close opened windows/doors and then restart arming, or you will force arming of this sensors or just leave them unarmed?

 

Regarding alarm activation devices. Zipato RFID keypad would be perfect choice if it could work perfectly with Fibaro HC but from other users posts it seems that is not. I don't own one so I can only recommend you to first look for more information before deciding to buy one. For the other one Z-Uno I can't write anything at the moment since I have no experience with it.

 

Hope that this helps a little!

 

Enjoy coding! :-) 

Link to comment
Share on other sites

  • Topic Author
  • Hi @Sankotronic thanks for the suggestions.   Its crazy that we actually have to implement solutions like this.   Fibaro should have them out of the box!     Ultimately want to have a physical alarm panel on the wall that I can set/unset the alarm from and that's why I kept away from putting lots of messages on the VD. 

     

    I have the Zipato RFID and I'm not too happy with it.  I used it for a while with my Vera, but it was clumbersome to work with and continually required intervention and the biggest annoyance was that there was no feedback as to the armed status etc.   I've tried to use it with HC2 but without any degree of success and its now been retired from my system.   My Z-Uno based system is complete enough that it will work from the coffee table with the bench power supply and I can arm/unarm and there's a status LED for status.   Bit of work to do with it but the Z-Uno only handles a few of the Z-Wave command classes, none of which are particularly suitable for a alarm panel.

     

    First try at setting this alarm when I went to work this morning was a partial success.   Everything was armed OK, except the front door because I was opening it as I set the alarm.  Should have worked as it has a 30 second time delay before arming.   

     

    I thought implementing devices and Lua scenes was difficult with Vera, Fibaro are not much better as the only official documentation about virtual devices and Lua scenes appears to state the obvious.

     

    Andy
     

    Edited by andyb749
    Link to comment
    Share on other sites

    Hi @andyb749,

     

    I must say that it is not easy to implement alarm panel that will satisfy all users. It is sufficient for small simple systems, but if you want anything extra then LUA is answer and luckily HC2 is quite capable system to handle it.

     

    If there is anything I can help you with please ask and me and other users that have even more experience in LUA will be glad to help.

     

    Link to comment
    Share on other sites

  • Topic Author
  • Thanks @Sankotronic    I'm sure its going to be an interesting project after seeing what others have done.   Likewise, if there's anything I can help other with, just shout.  I've over 30 years experience in Control Systems, Electronics, Industrial Controls including programming in assembler, C, C++, C#, Java, IEC61131 programming languages and more.

    Link to comment
    Share on other sites

    Guest fat

    I wish Fibaro would just add alarm sirens to automatically link to the alarm panel and trigger when alarm is triggered and turn on when the alarm is disarmed

    Link to comment
    Share on other sites

  • Topic Author
  • Hi @fat I agree completely.   What's the point of having a device that can be configured as Alarm - Breach, Alarm - Arming or Alarm State (Armed/Unarmed) when the system doesn't do anything with the information and prevents you from using in an alarm scene unless it is set to a light, or blind.  I niavely thought that it was just the documentation and help that was missing.  Now I realise that the functionality is missing too.

     

    And whilst I'm in mid-rant.  Has anyone tried to quickly arm/unarm the alarm panel from the Android App?  That is a joke, I'm presuming that the iPhone one is as bad and takes dozens of actions on the screen to arm/unarm. 

     

    Alarms was something that Vera was pretty good about.  There was a nice table and you just ticked the actors that you wished to be activated on alarm.

    Link to comment
    Share on other sites

    • 2 weeks later...
    On 2017-09-25 at 2:29 PM, andyb749 said:

    Hi @fat I agree completely.   What's the point of having a device that can be configured as Alarm - Breach, Alarm - Arming or Alarm State (Armed/Unarmed) when the system doesn't do anything with the information and prevents you from using in an alarm scene unless it is set to a light, or blind.  I niavely thought that it was just the documentation and help that was missing.  Now I realise that the functionality is missing too.

     

    And whilst I'm in mid-rant.  Has anyone tried to quickly arm/unarm the alarm panel from the Android App?  That is a joke, I'm presuming that the iPhone one is as bad and takes dozens of actions on the screen to arm/unarm. 

     

    Alarms was something that Vera was pretty good about.  There was a nice table and you just ticked the actors that you wished to be activated on alarm.

     

    Hi

    Please login or register to see this link.

    .

    I may have misunderstood your problem with turning on / off alarm but have you tried to swipe up on alarm icon (red bell) for alarm on and swipe down for alarm off? Or the switch in tablet version.
    However, I agree that the alarm function has a lot of development potential :D

    Fibaromobile.PNG.179e81e55d06c0f9726a7479737b6be0.PNGtabletalarm.PNG.2b92a9174428b9ae034ab3463f49ba77.PNG

    Edited by hegu
    Link to comment
    Share on other sites

    • 1 year later...

    i have tryied this and works only for one roomID

     

    Please login or register to see this code.

    How can i het a multi room

    roomID = {93,92,91},

    this doesn't work (and a get way)

    but how can we realyse this

    there is also no sectionID in api/devices, that wil make things easyier

    Link to comment
    Share on other sites

    • 1 year later...

    All great and usefull information, and I agree that my Vera had a great Alarm Panel, come on Fibaro not too much to ask!

     

    So took some of the above code and added my own functions:

     

    I have a Zipato RFID keypad by the Front Door and a Fortrezz Indoor Siren

    I have created a Global Variable ("Home", "Night", "Away", "Vacation") which I have a Virtual Device to control

    So I can set the alarm from the RFID keypad or via the Virtual Device or last of all the Alarm Panel

     

    Code attached for all to use, abuse, or fix :-) 

     

    I have reported a problem with the Zipato RFID that you cannot change the state of secured via fibaro:call(123, "unsecure") or fibaro:call(123, "secure")

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...