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


Generic Fibaro HC3 Alarm system


ChristianSogaard
 Share

Recommended Posts

Generic Fibaro HC3 Alarm system 

 

Hi Luabuilder :-) Sharing is Caring 

 

I have see a lot of talk using Fibaro HC3 for Alarm system. I love the idea - i want that, so i tried to describe what a Generic Alarm system should be build of.

Several people already tipped in with things they made og thoughts they have, issues they identified.

Why invent the wheel when great tuff already has been made.

 

@jgab has created the 

Please login or register to see this link.

 and

Please login or register to see this link.

 
- All-in-one QA framework for HC3 - this can be used for arming and disarming the alarm - An example is provided

Please login or register to see this link.

@10derand @JcBorgs  described issue about HC3 is missing the  "disable alarmExclude" -  a “pre-check” for sensors before arming ALARM is needed

What a good way to solve this - I way thinking of enhancing the doorstatus QA (below) ?

And @FBerges already shared

Please login or register to see this link.

of an alarm system 

@Mateo created a Siren

Please login or register to see this link.

And probably many more worked on their own solution to create a ALARM SYSTEM.

 

Please tip IN if there is elementary features ? - that is missing for a generic HC3 Alarm!

How would you structure this? ? - ONE Quick APP with everything, Variable for customising? or a QA with Scenes and 

Please login or register to see this link.

?

 

Another useful idea that could be used, is the status for open windows and doors.

This QA changes the Color in the matrix Bulb when a door or windows is opened.

 

Please login or register to see this attachment.

 @10der learned me about getting the sensor possibilities with 

Please login or register to see this code.

 

 

Perhaps some of the forum experts could create some overall structure and point the learners in right direction? ? ?

 

Desired Functionality

 

In case of alarm not armed

Geofence 

•    Ongoing control - have all users left the house? Message on Telephone (s) that the house is empty and the alarm is not active

 

For ARMING the Alarm
•    Message on Telephone (s) about which windows are not closed.

  • Message format Section, room, Sensor 
  • Message on Telephone (s) about which doors are not closed
    • Message format Section, room, Sensor 
  • Message on Phone (s) When alarm is active and which Zone.
    • Message could be Fibaro APP push, or Telegram
    • Delay to get out the door 
  • Use a Keypad like Matrix for ARM - ala triple cut on one button and subsequently double click on another.
    • Please login or register to see this link.

      is already made by @Jgab in

      Please login or register to see this link.

  • Use Fibaro APP for ARM
  • LED/Bulb for show Status ARMED – I will probably use MATRIX ZDB LED in the perimeter to changes to RED

 

By Disarm the Alarm

  • Message on Phone (s) alarm is deactivated and if other Zones are active
  • LED/Bulb for show Status DisARMED – I will probably use MATRIX ZDB LED in the perimeter to changes to GREEN, but could be a HUE Bulb
  • Use Matrix for DisARM - like triple cut on one button and subsequently double click on another.
    • This feature is already made by @jgab in

      Please login or register to see this link.

  • Use Fibaro APP for DisARM

 

For Alarm ACTIVE

  • Internal sirens are triggered
  • External sirens are triggered
  • Light with alarm status, flashes 1 Hz
  • SONOS speech - sound.
    • Could be by using the Quick App - 

      Please login or register to see this link.

  • Message on Telephone about which device has triggered alarm - Section, room, Sensor
     

  

Link to comment
Share on other sites

I have an alarm example with ER4 that solves a couple of the problems

Please login or register to see this link.

  • It triggers when a zone is activated and then checks the devices that are part of the zone if someone is breached and if so cancels the alarm and notifies the user. Because it triggers on the zone being activated it doesn't matter if a users enabled the alarm with the UI/app or with a Lua rules. It depends on that there is a delay set between the zone being activated and it actually becoming armed. 
  • It can notify you the name of the breached sensors when you try to activated the alarm with this add-on. <

    Please login or register to see this link.

    >
  • It could be complemented with a rule checking if a sensor is breached between being activated and actually armed. Now the check is done only when activated.
  • Like 1
Link to comment
Share on other sites

  • Topic Author
  • 6 minutes ago, jgab said:

    I have an alarm example with ER4 that solves a couple of the problems

    Please login or register to see this link.

    • It triggers when a zone is activated and then checks the devices that are part of the zone if someone is breached and if so cancels the alarm and notifies the user. Because it triggers on the zone being activated it doesn't matter if a users enabled the alarm with the UI/app or with a Lua rules. It depends on that there is a delay set between the zone being activated and it actually becoming armed. 
    • It can notify you the name of the breached sensors when you try to activated the alarm with this add-on. <

      Please login or register to see this link.

      >
    • It could be complemented with a rule checking if a sensor is breached between being activated and actually armed. Now the check is done only when activated.

    Thank you for you collaboration - I had the feeling that ER4 is very powerfull ?  for alarm system. 

    - I would be awesome with an Rule example "if a sensor is breached between being activated and actually armed" 

     

    Link to comment
    Share on other sites

    7 minutes ago, ChristianSogaard said:

    Thank you for you collaboration - I had the feeling that ER4 is very powerfull ?  for alarm system. 

    - I would be awesome with an Rule example "if a sensor is breached between being activated and actually armed" 

    The rule in the linked example look like this

    Please login or register to see this code.

    The ER4 sends out a trigger of {type='alarm',property='willAlarm'} when a zone is about to be armed. The trigger also contains the ID of the zone and the number of seconds until it arms.

    In the example we check if all the devices are safe and then notify the user that the alarm is about to be armed in X seconds

    If any device is breached we instead notify the user that there are breached devices and cancel the alarm.

     

    The rule could be modified to do other things if needed...

    The add-on I linked to retrieves the name of the beached sensors in the zone and sends them in the notification.

     

    ER4 treats zone 0 as the whole house (all defined zones)

     

    Link to comment
    Share on other sites

    1 hour ago, ChristianSogaard said:

    com.fibaro.windowSensor com.fibaro.doorWindowSensor  com.fibaro.doorSensor

    you do NOT need to use 

    /devices/hierarchy

     

    cuz 

    local doorWindowSIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.doorWindowSensor"})
    local motionIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})

    already include hierarchy

     

    for example.

    I have 

    Please login or register to see this image.

    /monthly_2020_11/image.png.cb201103bd1913b61db1928edda7b80f.png" />

     

     

    call 

    fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})

     

    as you can see Type is motion but my foibaro sensor is

    • type: "com.fibaro.FGMS001v2",
    • baseType: "com.fibaro.FGMS001",

    so trying

     

    image.png.447753ed03ad46c81eff18836759448b.png

     

    yay!

     

    but if you wanna learn 

    hierarchy

     

    you can playing with my code

     

    function findType(hierarchybaseType)
        local current = hierarchy
     
        if current == nil then
            return nil
        elseif current.type == baseType then
            return current
        else
            for _,v in pairs(current.childrendo
                local data = findType(v, baseType)
                if data ~= nil then
                    return data
                end
            end
        end
     
        return nil
    end
     
    function collect(current)
        for _,v in pairs(current.childrendo
            if v.type then
                print(v.type)
                collect(v)
            end
        end
    end
     
    -- 860
     
    local doorWindowSIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.doorWindowSensor"})
    local motionIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})
     
    local tree = api.get("/devices/hierarchy")
    local result = findType(tree, 'com.fibaro.motionSensor')
    collect(result)
    --print(json.encode(result))
    local result = findType(tree, 'com.fibaro.doorWindowSensor')
    collect(result)
    -- print(json.encode(result))

     

    Edited by 10der
    • Like 2
    Link to comment
    Share on other sites

    I think the alarm model in HC3 makes sense. We put devices in alarm zones and we arm zones. (On the HC2 we arm devices).

    The issue may be that we can't put any device in an alarm zone. It needs the be a derivative of com.fibaro.securitySensor, like motionSesnor, windowSensor etc. I think it would have been better if it was a device "interface" but there needs to be some protocol for devices to signal that they are breached or safe.

    However, it's not that difficult to make a QA wrapper for something else like a binarySwitch etc.

    Link to comment
    Share on other sites

  • Topic Author
  • 27 minutes ago, 10der said:

    you do NOT need to use 

    /devices/hierarchy

     

    cuz 

    local doorWindowSIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.doorWindowSensor"})
    local motionIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})

    already include hierarchy

     

    for example.

    I have 

    Please login or register to see this link.

     

     

    call 

    fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})

     

    as you can see Type is motion but my foibaro sensor is

    • type: "com.fibaro.FGMS001v2",
    • baseType: "com.fibaro.FGMS001",

    so trying

     

    Please login or register to see this link.

     

    yay!

     

    but if you wanna learn 

    hierarchy

     

    you can playing with my code

     

    function findType(hierarchybaseType)
        local current = hierarchy
     
        if current == nil then
            return nil
        elseif current.type == baseType then
            return current
        else
            for _,v in pairs(current.childrendo
                local data = findType(v, baseType)
                if data ~= nil then
                    return data
                end
            end
        end
     
        return nil
    end
     
    function collect(current)
        for _,v in pairs(current.childrendo
            if v.type then
                print(v.type)
                collect(v)
            end
        end
    end
     
    -- 860
     
    local doorWindowSIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.doorWindowSensor"})
    local motionIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})
     
    local tree = api.get("/devices/hierarchy")
    local result = findType(tree, 'com.fibaro.motionSensor')
    collect(result)
    --print(json.encode(result))
    local result = findType(tree, 'com.fibaro.doorWindowSensor')
    collect(result)
    -- print(json.encode(result))

     

    This is great stuff for learning - thank you very usefull ?

    Link to comment
    Share on other sites

    On 11/15/2020 at 1:06 PM, jgab said:

    The rule in the linked example look like this (the "pre-check")

    Please login or register to see this code.

    The ER4 sends out a trigger of {type='alarm',property='willAlarm'} when a zone is about to be armed. The trigger also contains the ID of the zone and the number of seconds until it arms.

    In the example we check if all the devices are safe and then notify the user that the alarm is about to be armed in X seconds

    If any device is breached we instead notify the user that there are breached devices and cancel the alarm.

     

    The rule could be modified to do other things if needed...

    The add-on I linked to retrieves the name of the beached sensors in the zone and sends them in the notification.

     

    ER4 treats zone 0 as the whole house (all defined zones)

     

     

    On 11/15/2020 at 11:37 AM, ChristianSogaard said:

     @10der learned me about getting the sensor possibilities with 

    I think it was my example, but I'm fine with @10der getting the credit :-) 
    Even better may be to print out the hierarchy - makes it easier to see the descendants of com.fibaro.securitySensor

    Please login or register to see this code.

     

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 2 minutes ago, jgab said:

     

    I think it was my example, but I'm fine with @10der getting the credit :-) 
    Even better may be to print out the hierarchy - makes it easier to see the descendants of com.fibaro.securitySensor

    Please login or register to see this code.

     

    I'm sorry @jgab for sure i dont want to disrespect anyone or give wrong credits ?.

    I was looking after an example to show the hierarchy Tree - Thank you for your example here.

     

    I tried creating a new Quick App and putting it there - my QuickApp crashed. I also tied putting into a scene and calling the printTypes function.

    could you give some hint how I should use your example?

    Please login or register to see this code.

     

     

    Link to comment
    Share on other sites

    31 minutes ago, ChristianSogaard said:

    I'm sorry @jgab for sure i dont want to disrespect anyone or give wrong credits ?.

    I was looking after an example to show the hierarchy Tree - Thank you for your example here.

     

    I tried creating a new Quick App and putting it there - my QuickApp crashed. I also tied putting into a scene and calling the printTypes function.

    could you give some hint how I should use your example?

    Please login or register to see this code.

     

     

    Sorry a "local" was added to the function by mistake

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • 19 minutes ago, jgab said:

    Sorry a "local" was added to the function by mistake

    Please login or register to see this code.

     

    I get the structure now ? - and the example @10der provided I can search for attributes in the different sensors.

    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, 10der said:

    you do NOT need to use 

    /devices/hierarchy

     

    cuz 

    local doorWindowSIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.doorWindowSensor"})
    local motionIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})

    already include hierarchy

     

    for example.

    I have 

    Please login or register to see this link.

     

     

    call 

    fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})

     

    as you can see Type is motion but my foibaro sensor is

    • type: "com.fibaro.FGMS001v2",
    • baseType: "com.fibaro.FGMS001",

    so trying

     

    Please login or register to see this link.

     

    yay!

     

    but if you wanna learn 

    hierarchy

     

    you can playing with my code

     

    function findType(hierarchybaseType)
        local current = hierarchy
     
        if current == nil then
            return nil
        elseif current.type == baseType then
            return current
        else
            for _,v in pairs(current.childrendo
                local data = findType(v, baseType)
                if data ~= nil then
                    return data
                end
            end
        end
     
        return nil
    end
     
    function collect(current)
        for _,v in pairs(current.childrendo
            if v.type then
                print(v.type)
                collect(v)
            end
        end
    end
     
    -- 860
     
    local doorWindowSIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.doorWindowSensor"})
    local motionIds = fibaro.getDevicesID({isTypeOf = "com.fibaro.motionSensor"})
     
    local tree = api.get("/devices/hierarchy")
    local result = findType(tree, 'com.fibaro.motionSensor')
    collect(result)
    --print(json.encode(result))
    local result = findType(tree, 'com.fibaro.doorWindowSensor')
    collect(result)
    -- print(json.encode(result))

     

    So this 

    Please login or register to see this code.

    gives the same result as the old code - at least what I can test.

    So just by using {} will put the result into a table direct ? 

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    10 minutes ago, ChristianSogaard said:

    So this 

    Please login or register to see this code.

    gives the same result as the old code - at least what I can test.

    So just by using {} will put the result into a table direct ? 

     

    Please login or register to see this code.

     

     

    Are you doing a "alarm system" that is not using the HC3 alarm partition/zone concept?

    Because using the HC3 model all sensors that are part of a zone/partition can be fetched from the zone/partition info.

    In practice there is no need to list all devices of a particular type as the only relevant devices are the ones added to the zones/partitions.

     

    and you can check if a zone is breached or safe

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • Just now, jgab said:

     

    Are you doing a "alarm system" that is not using the HC3 alarm partition/zone concept?

    Because using the HC3 model all sensors that are part of a zone/partition can be fetched from the zone/partition info.

    In practice there is no need to list all devices of a particular type as the only relevant devices are the ones added to the zones/partitions.

    My goal is to reuse as much as possible from the original HC3 Alarm system. My first goal is to have PUSH messages, when arming, about door & windows not closed. And for an Alarm breach a push message for which zone, device has breach

    Link to comment
    Share on other sites

    7 minutes ago, ChristianSogaard said:

    My goal is to reuse as much as possible from the original HC3 Alarm system. My first goal is to have PUSH messages, when arming, about door & windows not closed. And for an Alarm breach a push message for which zone, device has breach

    So my point is that you don't need getDoorSensors(), because you have the zones and the devices belonging to the zones.

    If you list all the door sensors you still need to find out what zone it belongs to and if that zone is armed/about to be armed.

    Better then to trigger on a zone about to be armed and check whatever devices belong to that zone if they are breached.

     

    • Like 1
    • Thanks 1
    Link to comment
    Share on other sites

  • Topic Author
  • 29 minutes ago, jgab said:

    So my point is that you don't need getDoorSensors(), because you have the zones and the devices belonging to the zones.

    If you list all the door sensors you still need to find out what zone it belongs to and if that zone is armed/about to be armed.

    Better then to trigger on a zone about to be armed and check whatever devices belong to that zone if they are breached.

     

    So 

     

    Please login or register to see this code.

    Gives me my 3 zones 

    • What is the 200 Value returned?
    • and can I use a command like fibaro.getDevicesID({isTypeOf = "com.fibaro.doorSensor"}) to get my partitions ? - i dont see it the hierarchy QA, because it end with a crash

     

    [15.11.2020] [15:55:23] [DEBUG] [SCENE129]: Alarm ZonesTypes 200
    [15.11.2020] [15:55:23] [DEBUG] [SCENE129]: Alarm ZonesTypes [{"id":1,"devices":[270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302],"breachDelay":5,"armDelay":0,"name":"Perimeter Zone","armed":false,"breached":false},{"id":2,"devices":[236,270,272,274,276,278,280,282,284,286,288,290,292,294,296,298,300,302,404],"breachDelay":0,"armDelay":0,"name":"Whole House","armed":false,"breached":false},{"id":3,"devices":[270],"breachDelay":0,"armDelay":0,"name":"Outdoor","armed":false,"breached":false}]

     

     

    Link to comment
    Share on other sites

    Examples in Lua if you don't want to use ER4 :-)

    Please login or register to see this code.

     

    If you want to list all devices that can be part of a alarm partition/zone you can do

    Please login or register to see this code.

    Guess fibaro uses that to populate the pop-up form when adding devices to partitions

    Edited by jgab
    Link to comment
    Share on other sites

  • Topic Author
  • 10 minutes ago, jgab said:

    Examples in Lua if you don't want to use ER4 :-)

    Please login or register to see this code.

     

    If you want to list all devices that can be part of a alarm partition/zone you can do

    Please login or register to see this code.

    Guess fibaro uses that to populate the pop-up form when adding devices to partitions

    This is very explaining and useful, great stuff :-)

    As you probably already discovery, i'm pretty rookie for this. I for sure believe I will manage - I used to code assembler on my commodore 64, but do the math ;-) that was in 1986. I'm investing a lot of hours to learn

    I like the event runner 4 - but I installed it two days ago - so there are some learning curve ;-) like everything else here.

    For the examples you just provided - I put that in a Scene, and I am getting

    [15.11.2020] [16:15:24] [ERROR] [SCENE134]: (load):6: Assertion failed: Expected number

    I have other examples where "Assertion failed" i bugging me - WHY, I dont get it?

    I implemented ChildrenOfHue yesterday, in the whole house. My family was very happy - no of the Matrix Switches as worked since I migrated from my HC2 to HC3  more than a month ago.

    Still i have a big wish for one button support and the "thing" were dim2off=true kicks in way too early.

    How would you make EV4 to send a PUSH with devices not ready?

     

     

      

    Link to comment
    Share on other sites

    2 minutes ago, ChristianSogaard said:

    For the examples you just provided - I put that in a Scene, and I am getting

    [15.11.2020] [16:15:24] [ERROR] [SCENE134]: (load):6: Assertion failed: Expected number

    I have other examples where "Assertion failed" i bugging me - WHY, I dont get it?

    Sorry, I renamed a variable in the first function.

    It should. be

    Please login or register to see this code.

     

    5 minutes ago, ChristianSogaard said:

    How would you make EV4 to send a PUSH with devices not ready?

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, jgab said:

    Sorry, I renamed a variable in the first function.

    It should. be

    Please login or register to see this code.

     

     

     

    Please login or register to see this code.

     

    I'm getting an error on RULE 10 - the user is missing , I tried adding a User into the HT - but I missed the syntax.

    I did try to fin a description in the 

     

     

    Please login or register to see this code.

     

    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.

     Share

    ×
    ×
    • Create New...