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

LUA code to feedback multiple window sensors feedback ... I'm stuck :(


mvdkallen

Question

Hi all,

 

Once I leave my house and set the house in "away" mode (.. which means it will close some roller shutters, close some curtains and arm window- and some door sensors through a scene), I also would like HC2 to communicate to me in case I left a window open by accident.

 

I had a look online for LUA code examples, and in specific to examples where the "elsif" parameter is used, but I got confused and am stuck now...

 

Anyone who can help me out here, please?

 

I only need to know the part of the code where I actually request HC2 to check the device status and report back in case it does not meet the requirement (.. as example, if Window A is open, send me the notification... If Window B is open, send me another notification... and so on.

 

Just take the below IDs as example when writing the codes:

 

Window sensors

ID35 for Window sensor A

ID36 for Window sensor B

ID37 for Window sensor C

 

Notifications as set in the system

ID40 for Window sensor A notification

ID41 for Window sensor B notification

ID42 for Window sensor C notification

 

Smartphone

ID 50 for smartphone Mark

 

.. probably the LUA script is quite simple, but right now I just don't see how I need to program this.

 

Thanks a lot for anyone's advice.

 

Best regards,

Mark

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Hi Robert,

     

    Excellent script, it does exactly what I was trying to achieve. Many thanks for that!

     

    best regards,

    Mark

    Link to comment
    Share on other sites

    • 0

    Please login or register to see this code.

    I use more generic solution to check for open windows. The "windows" variable at the top has a list of all window sensors (I use both satel and fibaro sensors). The code goes through all the window sensors and prepares a combined message with list of rooms where windows are open.

     

    If all windows are closed I still want to receive the message (then I know the scene worked and not just fibaro died again).

     

    Scene in my case is triggered manually (from iphone app) and I run it also from some other scenes eg. while arming the alarm.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi Robert,

     

    Many thanks, I'll give it a try.

    Good point actually about getting a message at all time to ensure the script ran, I didn't consider this myself but it is actually a very valid point because I notice that after each software upgrade of HC2 most of my automated scripts won't work anymore due to a weird and unknown reason 

    Please login or register to see this image.

    /emoticons/default_sad.png" alt=":(" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

     

    For this last point I wrote a reply in the forum this morning too, because it is getting annoying.

     

    Best regards,

    Mark

    Link to comment
    Share on other sites

    • 0

    Hi 

     

    It is too bad that we can't run a for loop on a device type, for example windows sensor or DOORS sensor.... instead of that, we have to enter all the devices IDs. That means update this list each time you add, remove a new device !!! A more dynamic way to scan devices of a type would be really interesting....

     

    Fibaro team, is it complicate to do that ?

     

    Thanks

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