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

Stop all running instances except the last started


FJW

Question

Hi,

 

Is there a methode to stop all instances of a scene EXCEPT the last started.

 

I tried fibaro:abort() but that stops only the last started instance and leaves all other running.

 

 

Thanks.

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Hi @FJW,

Assuming your scene goes to some sort of loop, maybe you can use that loop to monitor a global variable?

J

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi 3JL,

     

    No, I'm not using loops, I'm trying to keep it as simple as possible (if I can).

     

    I have a lighting sceme that I want to use to do all of my lighting needs in the house. I use "sleep" to wait until another lamp should turn on.

    The type of lighting is dictated through a variable and the variable in turn is controled by a light sensor.

    So theoretically it is possible to switch to another lighting when there is still one running and I want the last trigger the onlu one to be running.

    Link to comment
    Share on other sites

    • 0

    Hi FJW,

    The solution then remains the same:

    Just after sleep you check a global variable that can be edited by another instance of the scence.

     

    For example, assuming you name the global variable MonitorScene1:

    - at the beginning of your scene script, you increment the value of the MonitorScene1 variable

    - If before and after sleep, the value has increased, you know another scene was initiated and you can abort

     

    J

    Link to comment
    Share on other sites

    • 0
    On 6/15/2017 at 7:35 PM, FJW said:

    Hi,

     

    Is there a methode to stop all instances of a scene EXCEPT the last started.

     

    I tried fibaro:abort() but that stops only the last started instance and leaves all other running.

     

     

    Thanks.

    The only way I have found to reliably keep a more recent instance of a scene is to use a second scene to kill all the current running scene instance and then start a new single instance of the original scene. This may work for you but is not exactly what you asked for.

     

    I was a bi concerned when I first tried this that it may cause issues as it is a bit odd but it does not appear to cause issues

    Please login or register to see this code.

    the cancel scene calls the original after killing all instances of the original

    Please login or register to see this code.

     

     

    Link to comment
    Share on other sites

    • 0

    Use %%killOtherInstances in the header. Like this:

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 0
    2 minutes ago, petergebruers said:

    Use %%killOtherInstances in the header. Like this:

    Please login or register to see this code.

     

    I will have to pay more attention. When did they add that?

    Edited by robmac
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thanks petergebruers,

     

    I just tried it and ran into a problem.

    I made a scene to switch of a lamp after 60 sec. (just as a test) after movement was detected so: sensor breached.

     

    --[[
    %% killOtherInstances
    %% properties
    103 value
    %% weather
    %% events
    %% globals
    --]]

    local startSource = fibaro:getSourceTrigger();

    if (
     ( tonumber(fibaro:getValue(103, "value")) > 0 )
    or
    startSource["type"] == "other"
    )
    then
      local int aantal = fibaro:countScenes();
      fibaro:debug("Power save count: " .. aantal);
      
      setTimeout(function() fibaro:call(62, "turnOff"); end, 60000)
      
      fibaro:debug("Power save count end of the scene!");
    end
     

    What I noticed is that the lamp (ID 62) never switched off???

    When I used a delay of 5 sec. it worked. That got me thinking.

     

    After about 10 sec. the sensor goes back to safe and that also is registered by the scene and kill the running one.

    Since that is not the trigger, the scene is not started again and the light will NOT go off.

     

    What I have to do is make the scene trigger on going safe again (== 0) and than it works.

     

    Do you know if there is another solution?

     

     

    Link to comment
    Share on other sites

    • 0
    2 hours ago, petergebruers said:

    Use %%killOtherInstances in the header. Like this:

    Please login or register to see this code.

     

     

    Nice :) that's much easier indeed!

    Link to comment
    Share on other sites

    • 0
    4 hours ago, FJW said:

    Thanks petergebruers,

     

    I just tried it and ran into a problem.

    I made a scene to switch of a lamp after 60 sec. (just as a test) after movement was detected so: sensor breached.

     

    --[[
    %% killOtherInstances
    %% properties
    103 value
    %% weather
    %% events
    %% globals
    --]]

    local startSource = fibaro:getSourceTrigger();

    if (
     ( tonumber(fibaro:getValue(103, "value")) > 0 )
    or
    startSource["type"] == "other"
    )
    then
      local int aantal = fibaro:countScenes();
      fibaro:debug("Power save count: " .. aantal);
      
      setTimeout(function() fibaro:call(62, "turnOff"); end, 60000)
      
      fibaro:debug("Power save count end of the scene!");
    end
     

    What I noticed is that the lamp (ID 62) never switched off???

    When I used a delay of 5 sec. it worked. That got me thinking.

     

    After about 10 sec. the sensor goes back to safe and that also is registered by the scene and kill the running one.

    Since that is not the trigger, the scene is not started again and the light will NOT go off.

     

    What I have to do is make the scene trigger on going safe again (== 0) and than it works.

     

    Do you know if there is another solution?

     

     

    Single lamp with fibaro sensor just use association and parameters. 

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