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

Any clever trick to find the previous breach time?


Question

Posted

Lets say i have a script that when fired needs to know when the triggering sensor was last breached previous to the triggering event.

Do i need to create a global var which is compared to current time on breach and then updated.. or is there a shortcut?`

Basically i want a "Ok, someone has entered this room. How long has the room been empty?"

[ Added: 2014-10-03, 18:06 ]

Hm, I suppose I shpuld just create a second script that fires when the sensor has been "safe" for the desired amount of time, and update a global var (room_empty) at that point ?

4 answers to this question

Recommended Posts

  • 0
Posted

I'm using this code to switch off some lights when the motion detector has not been breached for a specified time:

Please login or register to see this code.

86 is the ID of the motion detector you want to test for when it was last breached.

Apparantly, this only works with certain versions of the firmware, as some get the "lastBreached" returned as 0 always, but it might be worth a shot to avoid having to use a global.

  • 0
  • Inquirer
  • Posted
    I'm using this code to switch off some lights when the motion detector has not been breached for a specified time:

    That logic will not work for me, as i do not want to keep a script running. (bad coding form if you ask me)

    I want to be able to trigger a scene and ask the system "So, how long has this room been empty before this triggering event?" And chose a nummer of different scenarios depending inch the length of that time span and a number of different other factors.

    • 0
    Posted

    Be that as it may, you won't reach your goal with "good" coding practice.

    I agree that it is bad coding practice to keep a script running, but with the possibilities you have with the fibaro unit, I don't think there is much else you can do if you don't want to use globals. If you are okay with globals, check the thread called "somebody home" - it does almost the same.

    • 0
  • Inquirer
  • Posted
    Be that as it may, you won't reach your goal with "good" coding practice.

    I agree that it is bad coding practice to keep a script running, but with the possibilities you have with the fibaro unit, I don't think there is much else you can do if you don't want to use globals. If you are okay with globals, check the thread called "somebody home" - it does almost the same.

    Oh, I never said that i did not WANT to use globals. I was however curious to if there was a more clever way of doing it.

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