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


Question

Posted (edited)

Check status of doors and windows v1.0

 

This simple scene will send push message every time when door or window is opened if global Variable DoorWinCheck is set to "Yes". Usage, we are sitting in garden on the opposite side of our house main entrance door. Turning this scene on and we will be informed every time when somebody opens main door

Please login or register to see this image.

/uploads/emoticons/default_smile.png" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" /> If scene is started manually with RUN button or by other scene or VD then it will check all doors and windows (or just those we put in the list) and will send popup message with the list of opened doors and windows. The rest is up to you. Here is scene code:

Please login or register to see this code.

global variable DoorWinCheck can be changed by virtual device which have one label and one button. Here is code that goes to button:

Please login or register to see this code.

And if you want you can add this code to Main loop:

Please login or register to see this code.

Don't forget to change name for label from label1 to lblDoorWinCheck or vice-versa. Here is also picture of DV and icons to use for scene and VD:

 

Please login or register to see this attachment.

   

Please login or register to see this attachment.

   

Please login or register to see this attachment.

 

EDIT :

New version 1.0 with some changes for users to easier setup. Now you can use existing variable and values you just need to enter name of your variable and map your values to Yes and No for checking and sending push notification when door or window is opened.

 

Also changed push notifications so that users are defined in table variable userID. userFlag defines if user will get notification set by 1, or not set with 0. You can add your part of code to change flags, see example:

Please login or register to see this code.

Enjoy coding! :)

Edited by Sankotronic
Release new version of code

Recommended Posts

  • 0
Posted

Thank you so much for sharing

Please login or register to see this image.

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

I will definitely utilize this in my system.

  • 0
  • Inquirer
  • Posted

    Enjoy coding!

    Please login or register to see this image.

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

    • 0
    Posted

    Thanks, will try to add this to my alarm scene

    Please login or register to see this image.

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

    • 0
    Posted

    For some reason i can't get it to send the pushmessage (the popup in the fibaro app works perfect).

    Maybe I should try to reboot the HC2? I get other pushes from an other scene so I don't think thats the problem...

    • 0
    Posted

    Hello, i get the following error :

     

    line 74:bad argument#1 to ´match`(string expected,got nil)

     

    Can I perhaps help someone or give a tip? greetings

    • 0
  • Inquirer
  • Posted

    Hello, i get the following error :

     

    line 74:bad argument#1 to ´match`(string expected,got nil)

     

    Can I perhaps help someone or give a tip? greetings

    Must be some typo, please check code before line 74, most probably missing ' or " to close string or similar.

    • 0
    Posted

    This simple scene will send push message every time when door or window is opened if global Variable DoorWinCheck is set to "Yes". Usage, we are sitting in garden on the opposite side of our house main entrance door. Turning this scene on and we will be informed every time when somebody opens main door

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> If scene is started manually with RUN button or by other scene or VD then it will check all doors and windows (or just those we put in the list) and will send popup message with the list of opened doors and windows. The rest is upt to you. Here is scene code:

    Please login or register to see this code.

    Hello Sankotronic. Your script is great. I am using the second part. I just want to check my windows with the press of a Scene button and get a combined list of open windows in a Pop-Up. It is working. The script is listing the windows in the popup.

    I just have one problem. I cannot modify the pop up with the last if then end part, where you define typeInfo and titleInfo depending on opened.

    Could you have a look what might be the reason for this behavior? This is the last missing piece of a great script I would like to use.

    Thanks. AV

    Here is my modified code

     

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

     

    Hello Sankotronic. Your script is great. I am using the second part. I just want to check my windows with the press of a Scene button and get a combined list of open windows in a Pop-Up. It is working. The script is listing the windows in the popup.

    I just have one problem. I cannot modify the pop up with the last if then end part, where you define typeInfo and titleInfo depending on opened.

    Could you have a look what might be the reason for this behavior? This is the last missing piece of a great script I would like to use.

    Thanks. AV

    Here is my modified code

     

    Please login or register to see this code.

    Hi avichr,

     

    Only problem I can find in your code is in line 27 where is missing part of code, it is:

     

          local room =     (winDoorID[iVar]);

     

    and should be:

     

         local room = fibaro:getRoomNameByDeviceID(winDoorID);

     
    Regards
    • 0
    Posted

    Very nice. thanks. I'm trying to get it working.

    I've imported your icons, but how do I know what ID is assigned to that icon?

    • 0
  • Inquirer
  • Posted

    Very nice. thanks. I'm trying to get it working.

    I've imported your icons, but how do I know what ID is assigned to that icon?

    It depends on which browser do you use. With safari just pull icon to the desktop and you will se ID in the name of icon something like UserXXXX.png

    If you use Chrome then you can turn on Inspect mode and from source of the page you can see path to that icon with it's name same as for Safari. Instead of XXXX will be icon ID number.

    For Firefox and IE I don't know, don't use them, but must be some way to find out.

    • 0
    Posted

    Exactly what I was looking for, but can't make it work.

    Please login or register to see this code.

    Inserted the id of my front door and balcony door, and changed the id to my phone.

    Still get an error [DEBUG] 21:59:23: line 74: bad argument #1 to 'match' (string expected, got nil)

    is it anywhere else I should change to 

    Please login or register to see this code.

    ?

    • 0
  • Inquirer
  • Posted

    Hi Gullfrode,

     

    I see that in first part of code you are getting Name of the device with function: fibaro:getName(winDoorID) but in second part which is executed when scene is started manually you use my original code to get user description of the device with function fibaro:getValue(winDoorID[iVar], "userDescription"). If you didn't enter description for sensors on advanced tab then you can get this error since it is empty or NIL.

     

    I would suggest you to replace fibaro:getValue(winDoorID[iVar], "userDescription") with fibaro:getName(winDoorID) in lines 66 and 67 and that should work just fine!

     

    Enjoy coding!

    • 0
    Posted

    I had to change the second line for room remove [iVar], and remove the line

    Please login or register to see this code.

    Now it works like a charm.

    Thank you very much !

    look like this:

    Please login or register to see this code.

    503 and 183 are my sensors, and 377 are my Phone  

    I belive that the number in

    Please login or register to see this code.

    have to correspond to the number of sensors that are checked  

    • 0
  • Inquirer
  • Posted

    I had to change the second line for room remove [iVar], and remove the line

    Please login or register to see this code.

    Now it works like a charm.

    Thank you very much !

    look like this:I belive that the number in

    Please login or register to see this code.

    have to correspond to the number of sensors that are checked  

    Of course, that line with jT=json... must be removed if you don't use global variable with table of devices ID.

     

    You are correct, winDoorNO keeps the number of sensors to be checked which ID's are in variable winDoorID. Line 56 can be also deleted and in line 58 replaced with #winDoorID because winDoorID is table of values, and # added to it's name is giving number of elements of that table, nice feature of LUA!

    • 0
    Posted

    Very beautiful script, nice piece of work!

    I don''t have window sensors but I want to use it for lamps switched on or of. I only use it for on-off lamps, for dimmed lamps the values are not 0 or 1.

    However, I get the warning pop-up only when I run the sript manually.

    Turning a lamp on or off by a scene or by a button on my phone or by pressing the on-off switch on the device itself  doesn''t result in a warning. I expected the status change should trigger this script.

    I have the proper ID entered in the properties and throughout the scene.

     

    What am I doing wrong?

    • 0
    Posted (edited)

    Works for push and also for popup when ALL doors/windows are closed... but when any door or window is open and i run scene i get...

     

    [DEBUG] 13:35:51: line 54: Assertion failed: Expected number

    Edited by Supernode
    • 0
    Posted

    Looks like the moment it comes across a 'true' value it fails...

     

    for example

     

    window 1 - closed

    window 2 - closed

    window 3 - open

     

    if i set doorNo to 2 then manually run says all windows are shut... if i set to 3 it fails regardless of doorID being present etc... so something is not converting the true statements to numeric values? or something else?

    • 0
    Posted

    fixed it [iVar] was missing from a few lines that was all... thank you

    • 0
    Posted

    fixed it [iVar] was missing from a few lines that was all... thank you

     

    Can you post where you put the missing iVar] ? 

    • 0
    Posted

    Winter is coming, and i bought a couple of new Fibaro Door/Window sensors to set my heating panel to Holiday-mode when the sensor is breached.

    The icon changes to open when the sensor is breached, but the script doesn't work.

    I tried adding the sensors to this scene, and it doesn't show any windows open(but does with my two Aeotec door sensors(ZW089)). All parameters are set to standard values. Am running 4.091 beta. Any tips?

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