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

lifecycle of %%autostart scenes


Question

Posted

I was wondering how the lifecycle of a scene is that is tagged as an %%autostart scene?

 

I noticed for example that it is started immediately after saving the scene, and i would assume that it is also started after the system reboots...please correct me if i'm wrong.

 

what I'm not sure about is what happens when i save the scene a second time (or a third time, or a fourth...). I can see that it is in fact run again after each save, but what happens to the already running instance? since autostart scenes are often used for doing things in intervals they often run in an infinite loop. so what happens to such an already running instance when i edit and save the scene and it is started again?

 

by the way, i assume that the number of parallel instances allowed is set to 1 if that would make a difference for the behaviour.

 

in this context I also wanted to ask about the "Deactivate" Button on the very bottom of the "Advanced" tab of a scene. As far as I understand it it should kill all instances of the scene...or is it all instances of all scenes?

 

and why do i get an "access forbidden" whenever i try to click on this "Deactivate" button? (my Alarm is not armed)

 

thanks in advance!

best regards

Max

10 answers to this question

Recommended Posts

  • 0
Posted

There is only one instance running, ever. If you press start, the running instance gets killed and a new one is started. I'm not sure about the "deactivate" button. If you want your scenes to work at boot, you need some delay because scenes can start before Z-Wave is operational. I usually add 30 seconds.

  • 0
Posted

There is only one instance running, ever. If you press start, the running instance gets killed and a new one is started. I'm not sure about the "deactivate" button. If you want your scenes to work at boot, you need some delay because scenes can start before Z-Wave is operational. I usually add 30 seconds.

 

So the autostart needs a sleep before something can be done? Can you explain that a bit more detailed and could you give us an example?

  • 0
Posted

An autostart scene starts when you reboot or turn on your HC2. If your scene checks and controls devices, you need some sleep. If you don't care about how it behaves right after boot, then no sleep is needed. For example, you have a heater. For safety, it can make sense to turn it off if you reboot (because running code has lost state). The scene would only contain 1 line of code to send "turn off". Try it, it won't work, because the code runs before Z-wave is active. Then reboot again with some sleep.

  • 0
Posted

An autostart scene starts when you reboot or turn on your HC2. If your scene checks and controls devices, you need some sleep. If you don't care about how it behaves right after boot, then no sleep is needed. For example, you have a heater. For safety, it can make sense to turn it off if you reboot (because running code has lost state). The scene would only contain 1 line of code to send "turn off". Try it, it won't work, because the code runs before Z-wave is active. Then reboot again with some sleep.

 

Okay i will give it a try

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" /> But when i add autostart and detect change on an value also the script should be fine right?

  • 0
Posted

You can leave out the delay, if you don't care what this scrip does after a reboot. Judging from what's posted on this forum, most people don't think or care about this.

There is a way to determine if the script was started by autostart or by value trigger, so technically it is possible to add the sleep only for "autostart". I can give you an example when I am home.

  • 0
Posted

You can leave out the delay, if you don't care what this scrip does after a reboot. Judging from what's posted on this forum, most people don't think or care about this.

There is a way to determine if the script was started by autostart or by value trigger, so technically it is possible to add the sleep only for "autostart". I can give you an example when I am home.

 

Perfect! Thank you.

 

So i think its the "fiber:getSourceTriggerType" to detect where the trigger comes from?

 

But i just will wait for your script.

  • 0
  • Inquirer
  • Posted

    Thank you for your feedback! The thing about the sleep on autostart is very usefull to know, too.

    • 0
    Posted

    Yep seems to be very useful. Thank you for that info. If you for example start a raspberry power it needs some time to boot. If i add some scripts on the raspberry i need to wait that sleep time to be able to fire the scripts! Perfect solution

    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

    Her's a demo script, that you can use to find out why a scene started. Throw in some device triggers at the top, instead of the 9999 and my global variable. Set "Max. running instances" to at least 2.

     

    Please login or register to see this code.

    • 0
    Posted

    Her's a demo script, that you can use to find out why a scene started. Throw in some device triggers at the top, instead of the 9999 and my global variable. Set "Max. running instances" to at least 2.

     

    Please login or register to see this code.

     

    Thank you for the example. Btw i added you on skype if its okay for you

    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" />

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