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

Abort part of Scene based on Global Variable Change


Question

Posted

Hi All

 

I have the following code that that turns on my front door light when it is open and turns it off 5 minutes after it closes, this meets my needs most of the time but if some one leaves the house and wants the light on for their return it has turned off. What I want to do is abort the turn off if my global variable for occupy count changes. I was thinking i could take a count from the global variable  run the scene then check 5 minutes later and if it has changed keep the light on or turn it back on. Anyone have any thoughts or sample code?

 

if (fibaro:countScenes()>1) then fibaro:abort(); end

if ( fibaro:getGlobalValue("TimeOfDay") == "Evening" )
  and  
  (  tonumber(fibaro:getValue(280, "value")) > 0 )
  then
  fibaro:call(291, "turnOn");
end

if ( fibaro:getGlobalValue("TimeOfDay") == "Evening" )
  and  
  (  tonumber(fibaro:getValue(280, "value")) == 0 )
  then
  setTimeout(function()
      fibaro:call(291, "turnOff");
    end, 5*60*1000)
end

6 answers to this question

Recommended Posts

  • 0
Posted

getGlobal has two (!) return values 

value and modifyTime 

please use it

Or use the same from getValue for your switch and check when last your switch was modified 

  • 0
Posted

Since I had same requirement from my family, I've a question about the scenario concept.

How do you change/control your global variable?

In my case I did it by door sensor only. Means if anyone wants the light to stay ON continuously,  just open and close the door second time when you leave home and the light will stay ON till the door will be opened next time (on return to home), then the light back to original action.

 

 

  • 0
  • Inquirer
  • Posted
    34 minutes ago, cag014 said:

    Since I had same requirement from my family, I've a question about the scenario concept.

    How do you change/control your global variable?

    In my case I did it by door sensor only. Means if anyone wants the light to stay ON continuously,  just open and close the door second time when you leave home and the light will stay ON till the door will be opened next time (on return to home), then the light back to original action.

     

     

    I have a global variable called occupy count, i use IFTTT to trigger a scene that either increases or decreased the global variable as the family enter and leave the house. This is working flawlessly for many other scenes i am just wanting to find away to incorporate it into this scene. My wife wouldn't be a happy with shutting the door twice 

    • 0
    Posted

    @Dman568 I think you ignore me :)

     

    Please login or register to see this code.

    so check if a family user is "too far" from home (5 min for example)

     

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted (edited)
    8 hours ago, 10der said:

    @Dman568 I think you ignore me :)

     

    Please login or register to see this code.

    so check if a family user is "too far" from home (5 min for example)

     

    Please login or register to see this code.

     

    Sorry 10der I wasn't ignoring you I just needed to sit down and have a look at what you said and see if i could make it work, cag014's question was something i could just answer quickly.

     

    I am not using the fibaro user presence as it is too unreliable for me, i am using IFTTT to trigger a scene that increases or decrease a global variable called OccupyCount. I was thinking i might be able to do a count of OccupyCount store it then check again in 5 mins and if it has changed abort the auto turn off

    Edited by Dman568
    • 0
    Posted
    On 4/23/2019 at 3:42 AM, Dman568 said:

    I am not using the fibaro user presence as

    you can't believe me but I am not using too :) 

    It's a code sample. just code sample how I work with Global values where I store per-user state.

    I am using ubiquiti unifi + apple (home bridge).. when user leave house apple phone call VD (with home bridge) and HC2 change status for a user in Global Var.

    so if use unexpectedly back to home I can check last modification time for value and for example postpone to set home arm etc

     

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