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

Comments/Testers to HC2 to DSC integration code wanted


pos
 Share

Question

Hi

 

I was posting here earlier regarding HC2 integration with the DSC alarm. After tricky research with a lot of needed info missing and testing of the Fibaro alarm plugin, I decided to start to write my own integration code. No need to use the crappy EnvisaLink plugin in HC2.

 

I have used EnvisaLink 4 and used the API to it (95% is same as IT-100 API). You do not need to allow traffic to Internet från the EnvisaLink to Eyezon or so.

 

Just plug in the EnvisaLink, power it up and you are ready to go directly (well,  maybe change password..). The code is running in a virtual device. The code is working very well, has different debug levels and also has log to syslog implemented.

 

Scenes can use the “traps” from the alarm sensors through global variables. Extending it to read and write anything to/from the DSC alarm is very easy from here. I do however wonder if there is a better way than using global variables (that cannot be created from lua). I mean… there should be a way to directly talk between scenes and VD:s… But I haven’t found any…

 

 

Comments and feedback to the code is very much appreciated before I give the code its final touch… But don’t be to hard on me. I am rather new to Lua and HC2. And it is a beta after all that I have spent a day on… The API poll function is used to have control of the TCP socket. Documentation of the code is in the top of the lua file. Right now the code it is rather basic. I will implement buttons and writing to the alarm as well from scenes and also implement more stuff from the API. But as said... I would very much appreciate some feedback before I continue the work.

 

Please login or register to see this link.

 

Here are a few log output screenshots:

 

Please login or register to see this image.

 

Screen%20Shot%202017-02-25%20at%2018.14.

 

Screen%20Shot%202017-02-25%20at%2018.14.

 

 

 

 

Edited by pos
Link to comment
Share on other sites

Recommended Posts

  • 0
  • Inquirer
  • Have done some fixes and add-ons...

    Please login or register to see this link.

     

     

     

    /Peo

    Link to comment
    Share on other sites

    • 0

    Very interested in this, I am currently using a Vera to handle my DSC alarm with EVL4 and passing the info on to HC2. Keep it up!

     

    On 2/25/2017 at 0:24 PM, pos said:

     

    Scenes can use the “traps” from the alarm sensors through global variables. Extending it to read and write anything to/from the DSC alarm is very easy from here. I do however wonder if there is a better way than using global variables (that cannot be created from lua). I mean… there should be a way to directly talk between scenes and VD:s… But I haven’t found any…

     

     

     

    I have some scenes that pull label values from VDs instead using a global variable to pass info from VD to scene. Works basically the same way except cant be used as a scene trigger, but no creation of GV required.

    Edited by devfern24
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hmmm.. I am very interested in label handling. I cannot find any docs anywhere about it. I Would very much appreciate if you could give me a link or PM me with info (to not change subject to much on this thread).

     

    Regarding the DSC integration I have posted, I am now working on implementing ARM, DISARM triggers plus the possibility to ARM/DISARM alarm from arbitrary scenes. 

     

    Thanks

     

    Peo

    Link to comment
    Share on other sites

    • 0
    19 hours ago, pos said:

    Regarding the DSC integration I have posted, I am now working on implementing ARM, DISARM triggers plus the possibility to ARM/DISARM alarm from arbitrary scenes. 

     

    Dont forget the "Stay" and "Away" arming that Fibaro forgot to do in their plugin!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • B t w...

     

    Is it better to have numeric codes for it or texts like "AWAY" etc... ? Numeric codes could be better. You have to have a list to check them when writing your scene, but there will be easier data to parse in the scenes.. The scene print out could be names if you so wish anyway.

     

    I mean... For example.. If the scene gets the following on trigger "openclosing"....

    Either:

    UO0003  (or "UOpeter" if a translation table is implementet to translate user 0003 to peter)

    Or:

    7500003

     

    In the last case you have to look into the text docs to know that 750 is "User Opening" by user "0003". But there will be much easier parsing in the scenes with for example:

     

    Lets assume the global trigger var is in variable "openclosing"

    if string.match(openclosing, '^750') then -- User Opening

    local part = string.sub(openclosing, 4, 4) -- Get current partition

    local user = string.sub(openclosing, 5, 8) -- Get current user

    fibaro:debug('Partition:' .. part .. ' has been opened by user: ' .. user)

    end

     

    which will look like:

    Partion 1 has been opened by user: 0003

     

    I started with names, but am in the change state back to numeric values which mean I also could implement more, faster with better quality of the code.. What do you think?

    /Peo

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I just have posted version 1.4 of the DSCengine that can handle triggers from DSC alarm in various ways in scenes.

     

    It includes trigger like...

     

    # ZONES

    Trigger on arbitrary zone that breaches or is restores

     

    # ARMING

    AWAY
    STAY
    ZERO-ENTRY-AWAY
    ZERO-ENTRY-STAY
    DISARMED

     

     

    # OPENING/CLOSING 

    How the opening or closing of the partition is done and what user that did it and when

     

    Se link to code and docs in post above. Now the code is usable for myself :) Comments very much appreciated.

     

    /Peo

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Now I have added ARM and DISARM remotley from the Fibaro app with pin codes in the app. The ARM status can also be seen in the app remotely.

     

    And... I have also implemented the DSC checksum calculation so all codes provided can be written 'as is' with no knowledge or need for understanding of checksum calculation.

     

    This is in version  1.5 that I will put on the web within a day or so (quality testing). There are a few screenshots here...

    Please login or register to see this image.

     

     

    Edited by pos
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Now I have made 1.5 available. I would very much appreciate feedback.

     

    Peo

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Now the code fulfills my own requirements with the integration between Fibaro HC2 and the DSC alarm.

    I just made version 1.6 available which I see as a well functioning baseline that contains:


    - Triggers on all sensors from the DSC alarms in scenes
    - All tricky checksums now calculated automatically
    - Get Fibaro logs and optional syslogs on *everything* (arming users, breach of sensors, arm state etc etc)
    - Implemented ARM and DISARM through the phone with pin code
    - Presentation in the phone of ARM status with time 

    The code is here:

    Please login or register to see this link.

     

    A few screenshots here...

     

     

     

    in the Fibaro smart phone app:

     

    Please login or register to see this image.

     

    ARM_DISARM_with_code_in_app-ver1.6.jpg

     

     

    disarming_ver1.5.jpg

     

    With integrity flag set the time wont be shown...

    DSCpresenter_ARMED_with_integrity_flag-v

     

     

    From syslog:

     

    Screen%20Shot%202017-03-01%20at%2021.41.

     

     

    Edited by pos
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Version 1.7 available here:

    Please login or register to see this link.

    Link to comment
    Share on other sites

    • 0

    Hi Pos!


    Thank you for sharing with us your code!

     

    I have an HC2 + Envisalink4 + DSC 1684 alarm panel to which I have connected various indoor and outdoor DSC PIR sensors and DSC siren.

    Currently I'm using the Envisalink Fibaro plugin however I find it to be pretty limited. For example I cannot make a simple scene like:

     

    IF a DSC PIR is Safe for XX seconds

    AND Partition 1 is Disarmed 

    THEN Force Arm Partition 1

    AND Send push notification.

     

    It seams that Fibaro plugin doesn't read correctly if a DSC PIR or door contact is ARMED or DISARMED or counting the passed SAFE time.

     

    Also If I make a simple scene like

    IF DSC Partition 1 is ARMED

    THEN Send push notification.

    ... id doesn't work because the current Fibaro plugin seams not read / interpret correctly the DSC Partition status.

     

    However I can make a simple scene to turn ON a light based on a motion detected by a DSC PIR sensors but I cannot make it turn it back OFF if the DSC PIR sensor is Safe for more than XX seconds .... pretty odd behavior of the Fibaro Envisalink plugin ... at least in my case!

    (all scenes made through Graphic Blocks)

     

    Now .. back on the subject :) . Could I do the above simple scenes using your API / VD?

     

    Could I trigger the DSC alarm siren If for example a Fibaro flood sensor is breached or ARM automatically the DSC Alarm panel if certain sensors (Fibaro motion / contact sensors and DSC PIR sensors) are safe for XX seconds?

    What about auto disarming the panel without code if I approach my house by reading the phone GPS position? 

     

    I'm asking this in advance because currently I do not have access to my HC2 to test it first but ... curiosity is killing me! :)

     

    Once again congrats for your effort and for your wiliness to share with the community!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, smprofx said:

    Hi Pos!


    Thank you for sharing with us your code!

     

    I have an HC2 + Envisalink4 + DSC 1684 alarm panel to which I have connected various indoor and outdoor DSC PIR sensors and DSC siren.

    Currently I'm using the Envisalink Fibaro plugin however I find it to be pretty limited. For example I cannot make a simple scene like:

     

    IF a DSC PIR is Safe for XX seconds

    AND Partition 1 is Disarmed 

    THEN Force Arm Partition 1

    AND Send push notification.

     

    It seams that Fibaro plugin doesn't read correctly if a DSC PIR or door contact is ARMED or DISARMED or counting the passed SAFE time.

     

    To check if DSC is safe for xx seconds is simply…

    IF global PIR variable is “0” AND present time compared to global PIR variable mod time is greater than XX THEN….

     

     

    To check if if partition 1 is disarmed

    Just check the proper DSC_P1_ArmedStatus

     variable according to

    Please login or register to see this link.

     

    Force arm

    Just arm according to

    Please login or register to see this link.

     

    Regarding sending push. Well that´s up to you to do in a scene or any other VD. You could see my DSCEngine as an engine updating global variables and/or labels that can trigger your stuff. 

     

     

     

    Quote

     

    Also If I make a simple scene like

    IF DSC Partition 1 is ARMED

    THEN Send push notification.

    ... id doesn't work because the current Fibaro plugin seams not read / interpret correctly the DSC Partition status.

     

    However I can make a simple scene to turn ON a light based on a motion detected by a DSC PIR sensors but I cannot make it turn it back OFF if the DSC PIR sensor is Safe for more than XX seconds .... pretty odd behavior of the Fibaro Envisalink plugin ... at least in my case!

    (all scenes made through Graphic Blocks)

     

    Now .. back on the subject :) . Could I do the above simple scenes using your API / VD?

     

    Piece of cake…

    Trigger your scene on the global variable DSC_P1_ArmedStatus. When it triggers check of the value is “ARMED AWAY”, “ARMED STAY” “DISARMED” etc according to my docs. If you see the proper armed status, just send your push… This can be done in a graphic scene and does not require lua code.

     
     

     

    Quote

     

    Could I trigger the DSC alarm siren If for example a Fibaro flood sensor is breached or ARM automatically the DSC Alarm panel if certain sensors (Fibaro motion / contact sensors and DSC PIR sensors) are safe for XX seconds?

    What about auto disarming the panel without code if I approach my house by reading the phone GPS position? 

     

    Most stuff I have done is implementing sending out all seen events from the DSC alarm to syslog and to HC2 do be used freely in scenes and/or VDs. Only a few thing is implemented to actually write to the alarm. These are today (version 1.7)  keep alive  + restart service if network does not work (does the plugin do that?), arming and disarming. It is probably an easy task to implement … Auto disarm is not implemented. It is however easy implemented. Today you can disarm with your DSC code from your phone or tablet app (see the docs I link to above).

     

     

     

    Quote

     

    I'm asking this in advance because currently I do not have access to my HC2 to test it first but ... curiosity is killing me! :)

     

    Once again congrats for your effort and for your wiliness to share with the community!

     

    Tnx

     

    If you have tested it and have suggestions, please tell me.

     

    Edited by pos
    Additional comment
    Link to comment
    Share on other sites

    • 0

    Hi Pos!

     

    I'm sorry but I'm not able to install your VD because I find the installation process not very easy to follow for me as I'm pretty lack of coding skills.

    Please take it only as a suggestion but a more intuitive tutorial with some images would be very handy for others like. 

    Thank you!

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I have made an 1.8 release of the Fibaro HC2 <-> DSC alarm integration plugin.

     

    With this I have also created a quick guide in PDF format with pictures and examples of how to use triggers and arm/disarm.

     

    # Quick guide

    Please login or register to see this link.

     

    # The rest …

    Please login or register to see this link.

     

    Peo

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Due to fw upgrade yesterday there was a temporary error in the download links. Hopefully it is ok now.

    Link to comment
    Share on other sites

    • 0

    I have tried to make two scenes for arming and disarming but I get the following error on DEBUG:

     

    [DEBUG] 23:08:05: line 6: unexpected symbol near char(226)

     

    The LUA code is: 

    --[[
    %% properties
    %% events
    %% globals
    --]]
    local sendcommand = ‘040'
    local partition = ‘1'
    local userpin = '0000'
    local sendcode = sendcommand .. partition .. userpin
    fibaro:call(510, "setProperty", "ui.INPUTCODE.value", sendcode)

     

    510 - is my DSCEngine ID

     

    By the way: what is the sendocmmand code for "STAY" arming state?

    L.E: found it: 

    031 - for STAY ARM

    032 - for Zero Entry Delay ARM

     

     

    Edited by smprofx
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 9 minutes ago, smprofx said:

    I have tried to make two scenes for arming and disarming but I get the following error on DEBUG:

     

    [DEBUG] 23:08:05: line 6: unexpected symbol near char(226)

     

    The LUA code is: 

    --[[
    %% properties
    %% events
    %% globals
    --]]
    local sendcommand = ‘040'
    local partition = ‘1'
    local userpin = '0000'
    local sendcode = sendcommand .. partition .. userpin
    fibaro:call(510, "setProperty", "ui.INPUTCODE.value", sendcode)

     

    510 - is my DSCEngine ID

     

    By the way: what is the sendocmmand code for "STAY" arming state?

     

     

     

    You have wrong quotation before 040 and 1

     

    local sendcommand = ‘040'
    local partition = ‘1'

     

    should be..

     

    local sendcommand = '040'
    local partition = '1'

     

     

    It is you or your editor :)

     

    Peo

     

     

     

    Link to comment
    Share on other sites

    • 0

    Thank's!

    Works fine now!

     

    I just copy-pasted from the PDF guide directly to the LUA editor. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 7 minutes ago, smprofx said:

    Thank's!

    Works fine now!

     

    I just copy-pasted from the PDF guide directly to the LUA editor. 

     

    Interesting.... I took a look. It seems to be the print to PDF that caused it and not you. My scene is ok, and copy to from one editor to the other seems ok as well. But after printing to PDF it is wrong... I will look into it. It is of course a good thing if you can trust the apostrophes in the PDF if copying..

    22 minutes ago, smprofx said:

    I have tried to make two scenes for arming and disarming but I get the following error on DEBUG:

     

    [DEBUG] 23:08:05: line 6: unexpected symbol near char(226)

     

    The LUA code is: 

    --[[
    %% properties
    %% events
    %% globals
    --]]
    local sendcommand = ‘040'
    local partition = ‘1'
    local userpin = '0000'
    local sendcode = sendcommand .. partition .. userpin
    fibaro:call(510, "setProperty", "ui.INPUTCODE.value", sendcode)

     

    510 - is my DSCEngine ID

     

    By the way: what is the sendocmmand code for "STAY" arming state?

     

     

     

    Does it work to arm and disarm now through the app?

     

    Edited by pos
    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.

     Share

    ×
    ×
    • Create New...