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

Start Scene on Boot


Question

Posted

Hi,

i am using HC2. How can i start a scene once on boot?

I want to initialize a global variable. I think after an upgrade process, the varible was wrong initialized.

By the way... what is the default value for initialisation of an variable?

6 answers to this question

Recommended Posts

  • 0
Posted

For scene to start at boot or after saving you need to add %% autostart to scene header like this:

Please login or register to see this code.

I don't understand your next question about default initialization of global variable, you must be more specific what it is about, but to set value to global variable you use following command:

Please login or register to see this code.

 

  • 0
  • Inquirer
  • Posted

    Hi. Thank you! 

    So what is %%events 

    Used for? 

     

    I had the feeling that my global variables values reset after System Update. But i xm not sure. So i wonder what values tgey get if they are resetted

    • 0
    Posted

    Global variables in general keep their values after system reset with few exceptions. There are two types of global variables on Fibaro system:

     

    1) Predefined global variables and they usually have several predefined values (string type).

        They can also contain only one value in which is then stored table type value and they

        keep same value after rebooting the system

    2) global variables are supposed to keep numerical values but they actually store numeric

        and string values as strings and as such stored values will stay same after system is

        rebooted. But if you store table type value in this type of global variable it will be

        destroyed after rebooting or even pressing save button on variable panel.

     

    So, if you are not using any table type values stored in global variables then you should not worry about global variables because they will keep their stored value after system reboot including shutdown.

     

    Regarding %% events it is used to trigger scene by centralSceneEvent generated by some devices like Fibaro swipe, if there is more than that I don't know.

    • 0
    Posted

    Hi @

    Please login or register to see this link.

    Is your point 2) also true then the HC2 crashes and reboots?

    • 0
    Posted
    13 hours ago, tnesheim said:

    Hi @

    Please login or register to see this link.

    Is your point 2) also true then the HC2 crashes and reboots?

     

    Hi @tnesheim,

     

    My HC2 crashed only three times, once on 4.120, once on 4.130 and recently on 4.140. In all three occasions I haven't noticed any problems with global variables, but that is not enough to be the rule. I believe that it is still possible that some global variable get corrupted by the system when it freezes or crashes.

     

    Rebooting should not affect any global variables and they should keep their values stored intact. But still, if reboot happens in same time when some global variable should change value according to the schedule, then it is possible that change will not occur and after reboot it will have then wrong (old) value. This is definitely problem for block scenes with timers since they are very strict with time set, while with LUA it only depends on code how is written.

     

    Just for example, this code in LUA changes global variable value only at specific time:

    Please login or register to see this code.

    So if reboot happens at just before 19:00 or 07:00 then global variable Darkness value will not change as expected. To avoid such problems it is better to change above code to be more flexible:

    Please login or register to see this code.

    This other example will still set global variable to proper value no matter when HC was rebooted!

     

    Hope this shed some light on this matter.

     

    Enjoy coding :-) 

    • Like 1
    • 0
    Posted (edited)

    Hi!

    Thanks for thorough answer! I realize that I also should have explained the background of my question. I´m about to implement a more advanced heat control in my home. I have about 8 heating devices(floors, heat pump, ventilation) and first step is to make individual setpoints for all units on normal and eco-mode. These setpoints need to be tuned to get right (I can probably guess quite right, but fine tuning is most likely  required). The setpoints will be stored in global variables. (tables is erased at reboot).

     

    But what happens at a crash is my consern. Since I do not know to mechanisms storing global variables when rebooting where might be an internal function in HC2 that in the shutdown sequence stores the values to a non-volatile storage, and retrieves them at reboot.. If so, values at sudden crash are not stored and I will loose my fine tuned setpoints. Or, the global variable might be store in eg a flash and stored for every change.

    Edited by tnesheim
    typos

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