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


  • 0

HC3: how to check sensors before arming the Alarm?


JcBorgs

Question

Want to use the Fibaro app to arm and disarm the house. But how do you perform a check in either block or LUA that checks if any of the sensors are in breaching before arming the alarm?

 

Do want a check that is initiated when the house is arming and if any of the door/windows sensors are open or if there are movement registered at one of the movement sensors the arming should be cancelled and a push message sent saying what sensor is active. 

 

Have tried now both in Block and LUA but can’t get it to work, thought I solved it with a combination of “Armed” sensor and open/movement on the sensor which then disarmed the house, but when testing it out I realized I failed miserably because that scene actually disarmed the house if there was an actual breach later when the house was properly armed.

 

So open for any suggestion, this is what I want to achieve:

- Arm the house with the Fibaro App.

- If an sensor is open or movement registered when the house is “arming” the arming should be cancelled and a push message sent saying what sensor that was active.
 

 

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Thanks, will test this.

     

    Need to change coding a bit so that it could work in a HC3 and not sure if all parameters are supported in the HC3.

     

     

    Edited by JcBorgs
    Link to comment
    Share on other sites

    • 0

    On the HC3 when one arm an alarm zone in the UI one can select an "exit delay" in seconds. After the delay, the zone is armed and a trigger is sent that the partition/zone is now armed.

    It would be nice if the HC3 would send a trigger before that, "partition is about to be armed", so that a scene could react to that and do whatever house-keeping is needed before

    everything gets armed. Which could involve cancelling the arming if doors or windows were found open or playing a message on the Sonos speaker that the alarm is about to be enabled...

     

    One way around that is to make your own delay by having a binary switch QA per partition that turns on your alarm, but with the same selectable delay (maybe with a UI slider?). When the QA is turnedOn (arming) it will send a customEvent that informs that it is about to arm the partition in X seconds. Scenes or blocks scenes could then trigger on that event and decide to cancel the alarm by calling the QA's turnOff.

     

    ...or fibaro will add that feature to the existing alarm functionality...

    Edited by jgab
    Link to comment
    Share on other sites

    • 0

    Please login or register to see this code.

     

    Edited by 10der
    Link to comment
    Share on other sites

    • 0

    Opps! can't find in HC3 how to disable alarmExclude

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 21 hours ago, 10der said:

    Opps! can't find in HC3 how to disable alarmExclude

    Yes, Noted that to.

     

    So with the current features available in Fibaro HC3 it does not seem to be possible to do a “pre-check’ before arming the Alarm. As JGAB mentioned the one key feature that is missing is that even if you set an ‘Exit Delay’ you can’t get information out of the HC3 that the Exit Delay has been initiated, you will only get information once the sensors are armed.

     

    Really hope that Fibaro will introduce some changes here, a “pre-check” is in my view a really basic alarm feature.

    • Like 1
    Link to comment
    Share on other sites

    • 0

    Good Morning

    Look at my alarm system, you can possibly use some of it.
    Unfortunately, all comments are in German, I hope that you can still manage.
    The alarm takes place in another module so that is completely missing here.

    Greetings from Germany / Sauerland

    Frank

     

    DECLARATIONS (Bedingungen/Trigger)

    --[[
    Die Szene wird ausgelöst von :
    id 489 = Starttaster
    id 490 = Stopptaster
    homeBreached = Komplettes Haus Alarm
    --]]
    {
      conditions = { {
          id = 489,
          isTrigger = true,
          operator = "==",
          property = "value",
          type = "device",
          value = true
        }, {
          id = 490,
          isTrigger = true,
          operator = "==",
          property = "value",
          type = "device",
          value = true
        }, {
          isTrigger = true,
          operator = "==",
          property = "homeBreached",
          type = "alarm",
          value = true
        } },
      operator = "any"
    }
     
    AKTION
     
    --[[
    Alarmanlage Scharfschalten und Unscharfschalten
     
    Wird die Starttaste gedrückt, beginnt die Rote LED über dem Taster an zu blinken für 00:05 sprich 5min.
    Die Grüne LED für Umscharf geht aus.
    Nach Ablauf der Zeit ist die Anlage Scharf
    Beim Bestätigen der Stoptaste
    Geht die Rote LED aus und die Grüne an.
    Jetzt ist die Alarmanlage unscharf.
    Bei einem Alarm hat man 5min Zeit bevor der Radau los geht.
    Die Grüne und die Rore LED blinken
     
    Die Globalen Variablen werden gefüllt wenn ein Alarm besteht mit :
    Alarm               = 1 =  Alarm
    Alarm_Etage_ID      = ID Nummer der Etage in der der Alarm ausgelöst wurde 
    Alarm_Etage_Name    = Der Klartextname der Etage
    Alarm_Device_ID     = ID Nummer des Devices der den Alarm ausgelöst hat
    Alarm_Etage_Name    = Der Klartextname des Devices
     
    Noch in Planung ! :
        Eine Push Nachricht wird aber sofort gesendet.
        Sirene
        Blinkendes Licht
     
    --]]
     
    --Globale Variablen übergeben
    local alarm = tonumber(fibaro.getGlobalVariable("Alarm"))
    local alarm_etage_id = tonumber(fibaro.getGlobalVariable("Alarm_Etage_ID"))
    local alarm_etage_name = fibaro.getGlobalVariable("Alarm_Etage_Name")
    local alarm_device_id = tonumber(fibaro.getGlobalVariable("Alarm_Device_ID"))
    local alarm_device_name = fibaro.getGlobalVariable("Alarm_Device_Name")
     
    -- Lokale Veriablen (Geräte ID´s)
    starttaster     = 489
    stoptaster      = 490
    start_led_rot   = 493
    stop_led_gruen  = 494
     
    print("Start")
     
    ------------------------------------------------------------------------------------
    -- Funktion zum Zeitumrechnung in Minuten
    -- die Übergebene Uhrzeit wird in Minuten umgerechnet und zurück gegeben
    ------------------------------------------------------------------------------------
    local TimeNow = os.date("%H:%M", os.time())
    tonumber,oldTonumber=function(str) 
      local h,m,s=str:match("(%d%d):(%d%d):?(%d*)")
      return h and m and h*3600+m*60+(s~="" and s or 0or oldTonumber(str)
    end,tonumber
    ------------------------------------------------------------------------------------
     
    ------------------------------------------------------------------------------------
    -- Funktion welcher Bereich und welcher Teilnehmer hat ausgelöst 
    ------------------------------------------------------------------------------------
    function Frage_Alarm_wo()
        local data, status = api.get('/alarms/v1/partitions')
        local alarm = 0
        local alarm_etagen_id = 0
        local alarm_etagen_id_name = ""
        local alarm_device_id = 0
        local alarm_device_name = ""
        for _, v in pairs(data) do --raussuchen welcher Bereich auf Alarm ist
            if (json.encode(v.breached) == 'true'and (alarm == 0then --Nur der Erste Alarm wird gemeldet
                alarm_etage_id = json.encode(v.id) -- Etagen ID
                alarm_etage_name = json.encode(v.name) -- Etagen Name
                alarm = "1"
                break -- Vergleichsschleife beenden Etage gefunden
            end
        end
        -- Gemerkte Zustände der Device zurückholen
        local data = fibaro.getGlobalVariable("Alarm_Device_Zustand")
        tabelle = json.decode(data)
        for _, v in pairs(tabelle) do -- Device raussuchen das ausgelöst hat
            if fibaro.getValue(tonumber(json.encode(v.ID)),"value") ~= v.zustand then -- Momentaner Zustand anders als der Abgespeicherte ?
                alarm_device_id = v.ID
                alarm_device_name = fibaro.getName(tonumber(json.encode(v.ID)))
                break -- Vergleichsschleife beenden Teilnehmer gefunden
            end
        end
        return alarm,alarm_etage_id,alarm_etage_name,alarm_device_id,alarm_device_name
    end
    ------------------------------------------------------------------------------------
     
    ------------------------------------------------------------------------------------
    -- Funktion Alarmbereiche scharfschalten und Sicherungsgeräte merken
    ------------------------------------------------------------------------------------
    function Alarm_bereiche_scharf()
        local data, status = api.get('/alarms/v1/partitions')
        local geraete={} --Zustand der Alarm-Device merken
        for _, v in pairs(data) do
            --Bereiche scharfschalten    
            if (json.encode(v.armed) == 'false'then
                fibaro.alarm(tonumber(json.encode(v.id)), 'arm')
            end
            -- Zustand der Alarm-Device einsammeln
             i=1
            repeat
                --Device die in der Alarmkette sind mit deren Zustand abspeichern
                local neugeraet = 
                    {
                    etage = tonumber(json.encode(v.id)),
                    ID = tonumber(json.encode(v.devices)), 
                    zustand = fibaro.getValue(tonumber(json.encode(v.devices)),"value")
                    }
                table.insert(geraete,neugeraet)
                i = i+1 --Nächster Device
            until json.encode(v.devices) == "null" or i == 200 --200 Angst essen Seele auf !
        end
        --Alles auf Globale Variablen abspeichern
        fibaro.setGlobalVariable("Alarm_Device_Zustand",json.encode(geraete)) --Alle Alarmdevice Zustände Global abspeichern
    end
    ------------------------------------------------------------------------------------
     
    ------------------------------------------------------------------------------------
    -- Funktion Bereiche unscharfschalten
    ------------------------------------------------------------------------------------
    function Alarm_bereiche_unscharf()
        local data, status = api.get('/alarms/v1/partitions')
        for _, v in pairs(data) do
            if (json.encode(v.armed) == 'true'then
                fibaro.alarm(tonumber(json.encode(v.id)), 'disarm')
            end
        end
    end
    ------------------------------------------------------------------------------------
     
    ------------------------------------------------------------------------------------
    ---------------------------------- Hauptprogramm -----------------------------------
    ------------------------------------------------------------------------------------
    -- Locale Variablen
    local time_alarmanlage = tonumber(TimeNow)
     
    if (json.encode(sourceTrigger.property) == '"execute"'then
        --print('Szene manuell ausgeführt - UserID: ' ..json.encode(sourceTrigger.id))
        -- Alarmaktion Manuel nicht vorgesehen !
    elseif json.encode(sourceTrigger.id) == tostring(starttaster) then -- Starttaste hat getriggert
        --print ("Stattaster getriggert")
        --Scharf schalten
        -- print("Start scharfschalten = ",  os.date("%H:%M", os.time()))
        time_alarmanlage =tonumber(os.date("%H:%M", os.time()))
        fibaro.call(494,"turnOff")
        repeat 
            fibaro.call(start_led_rot,"turnOn")
            fibaro.sleep(1000)
            fibaro.call(start_led_rot,"turnOff")
            fibaro.sleep(1000)
        until (tonumber(os.date("%H:%M", os.time())) == (time_alarmanlage+tonumber("00:05"))) --Warten nach Start
        fibaro.call(start_led_rot,"turnOn"
        Alarm_bereiche_scharf()
        alarm = 0
        alarm_etage_id = 0
        alarm_etage_name = ""
        alarm_device_id = 0
        alarm_device_name = ""
        print("Scharf = ", os.date("%H:%M", os.time()))
        -- Jetzt ist die Kiste Scharf
    elseif json.encode(sourceTrigger.id) == tostring(stoptaster) then --Stoptaste hat getriggert
        --print("Stoptaster getriggert")
        --Unscharf schalten & Alarm löschen
        fibaro.call(stop_led_gruen,"turnOn")
        fibaro.call(start_led_rot,"turnOff")
        Alarm_bereiche_unscharf()
        alarm = 0
        alarm_etage_id = 0
        alarm_etage_name = ""
        alarm_device_id = 0
        alarm_device_name = ""
        print("Unscharf = ", os.date("%H:%M", os.time()))
        -- Jetzt ist die Kiste Unscharf
    elseif json.encode(sourceTrigger.id) == "null" then --Hausalarm hat getriggert
        --print("Hausalarm getriggert")
        -- Alarmanlage meldet Alarm
        -- feststellen wo der Alarm herkommt
        print("Es wurde alarm ausgelöst")
        local alarm,alarm_etage_id,alarm_etage_name,alarm_device_id,alarm_device_name = Frage_Alarm_wo()
        --Alarmdaten anzeigen
        print("Alarm da ?         = ",alarm, "Uhrzeit = ", os.date("%H:%M", os.time()))
        print("Alarm-Bereich ID   = ",alarm_etage_id)
        print("Alarm-Bereich Name =",alarm_etage_name)
        print("Alarm_Device ID    = ",alarm_device_id)
        print("Alarm_Device Name  = ",alarm_device_name)
        time_alarmanlage =tonumber(os.date("%H:%M", os.time()))
        fibaro.call(start_led_rot,"turnOff")
        repeat --Rote und grüne LED blinken lassen
            fibaro.call(start_led_rot,"turnOn")
            fibaro.call(stop_led_gruen,"turnOn")
            fibaro.sleep(1000)
            fibaro.call(start_led_rot,"turnOff")
            fibaro.call(stop_led_gruen,"turnOff")
            fibaro.sleep(1000)
        until (tonumber(os.date("%H:%M", os.time())) == (time_alarmanlage+tonumber("00:05"))) --Warten nach Alarmerfassung
        fibaro.call(start_led_rot,"turnOn"
        fibaro.call(stop_led_gruen,"turnOn")
        --Jetzt geht der Alarm los
    end
     
    fibaro.setGlobalVariable("Alarm",tostring(alarm))
    fibaro.setGlobalVariable("Alarm_Etage_ID",tostring(alarm_etage__id))
    fibaro.setGlobalVariable("Alarm_Etage_Name",alarm_etage_name)
    fibaro.setGlobalVariable("Alarm_Device_ID",tostring(alarm_device_id))
    fibaro.setGlobalVariable("Alarm_Device_Name",alarm_device_name)
     
    Edited by FBerges
    Link to comment
    Share on other sites

    • 0

    Hello

    sorry, not at the right place and can't delete it.

    original tread around "how changing device parameters from QA", with full details and code is then there:

    Please login or register to see this link.

    br

    mathias

     

    Please login or register to see this image.

    /monthly_2020_05/image.png.03b1b3d8e779ecc9efd446202bf41d6d.png" />

     

    Please login or register to see this attachment.

    Edited by Mateo
    try to delete; made a mistake, not at the right place
    Link to comment
    Share on other sites

    • 0
    On 5/20/2020 at 1:00 PM, 10der said:

    Please login or register to see this code.

     

     

    Hi @10der

    thank you for this example :-) 

    I see the 

    com.fibaro.doorWindowSensor and 

    com.fibaro.doorSensor

     

    Is there a com.fibaro.WindowSensor ? I tried guessing this name - but it seems not to be working

    if not - It might be possible to get WindowSensor buy doing the differences between com.fibaro.doorSensor and com.fibaro.doorWindowSensor

     


    function getWinSensors()
        local IDs = {}
        -- com.fibaro.doorWindowSensor
        local result = api.get('/devices?isTypeOf=com.fibaro.WindowSensor&visible=true')
        -- local result = api.get('/devices?isTypeOf=com.fibaro.doorSensor&visible=true')
        for k,v in pairs(result) do
            table.insert(IDs, v.id)    
        end  
        return IDs
    end

     

     

    Link to comment
    Share on other sites

    • 0
    19 minutes ago, ChristianSogaard said:

     

    Hi @10der

    thank you for this example :-) 

    I see the 

    com.fibaro.doorWindowSensor and 

    com.fibaro.doorSensor

     

    Is there a com.fibaro.WindowSensor ? I tried guessing this name - but it seems not to be working

    if not - It might be possible to get WindowSensor buy doing the differences between com.fibaro.doorSensor and com.fibaro.doorWindowSensor

     


    function getWinSensors()
        local IDs = {}
        -- com.fibaro.doorWindowSensor
        local result = api.get('/devices?isTypeOf=com.fibaro.WindowSensor&visible=true')
        -- local result = api.get('/devices?isTypeOf=com.fibaro.doorSensor&visible=true')
        for k,v in pairs(result) do
            table.insert(IDs, v.id)    
        end  
        return IDs
    end

     

     

     

    Please login or register to see this link.

    com.fibaro.windowSensor

     

    Try

    Please login or register to see this code.

     

     

    • Like 1
    Link to comment
    Share on other sites

    • 0
    On 5/20/2020 at 1:00 PM, 10der said:

    Please login or register to see this code.

     

    I tried running this in a scene - I'm getting

    (load):13: Assertion failed: Expected string.

    I tried comment out line 13 - fibaro:debug("Device: ".. id .. " is not ready for arming") - but is still getting 

    Assertion failed: Expected string.

    any idea ?

    Link to comment
    Share on other sites

    • 0
    Guest titopringles

    This code works for me

     

    print("--------------------------------------------------")
    local filter = 
          {
            enabled = "true",
            visible = "true",
            interfaces = {"fibaroAlarmArm"},
            isTypeOf = "com.fibaro.doorSensor",
            properties = { alarmExclude = "false" }
          }
    local deviceIds = fibaro.getDevicesID(filter)
    local status = ""
    local value = false

    for k, id in pairs(deviceIds) do
    value = fibaro.getValue(id, "value")

    if value == true
    then 
    status = "OPEN"
    else
    status = "close"
    end

    print(" Room [".. fibaro.getRoomNameByDeviceID(id).. "] Device: (".. id .. ") ["..fibaro.getName(id).."] Value: [" .. status .. "]")
    value = false
    end

    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
    Answer this question...

    ×   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...