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

Missing opton Start when Home Center 2 starts for Lua Scene


Question

Posted

Hi guys,

How can I auto activate LUA scene on HC start?

This is graphic blocks scene, it start fine with HC

Please login or register to see this image.

This is LUA scene, there's no such option

fFADmkX.png

This is my code, how can I add some script to make it run on HC start?

Please login or register to see this code.

Thank you.

7 answers to this question

Recommended Posts

  • 0
Guest GG
Posted

It is already autostarting with hc2.

%% autostart is the key to that.

But why do you want it to autostart?

The scene will stop immediately as there is no while loop .

What are you trying to achieve here?.

  • 0
Posted
...

The scene will stop immediately as there is no while loop .

What are you trying to achieve here?.

Example af that: wrap you code in an infinite loop

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    Thank guys, I've made it working!!!

    This is my Scene, I'm a noob in Lua programming but I just post my Scene here and hope you guys help me improve it.

    Goal:

    There are a Motion Sensor and Light Dimmer in the terrace.

    If someone go to the terrace, set Light Dimmer to the brightest value,

    If someone leave the terrace, set Light Dimmer to previous value.

    First I made 2 variables:

    TerraceDimmeValue: Standard Variable that store CURRENT Dimmer Value

    SceneEnabled: Predefined Variable that only have two value On and Off

    Now that my code, I hope you guys can help me make it better

    This is how I turn Dimmer Light to Max when Motion detected

    Please login or register to see this code.

    This is how I turn DimmerValue to PREVIOUS value when Montion is NOT detected

    Please login or register to see this code.

    I'm a total idiot on Scene Programming, but I just post it here and hope you guys help me improve it.

    Thank you

    Please login or register to see this image.

    /emoticons/default_biggrin.png" alt=":D" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    • 0
    Posted

    Not bad at all, not bad at all.

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" /> I like the idea of using triggers without the often used while-true-sleep pattern. I'd say it would be close to what you want, but I need to let it bounce a bit in my head. I think there is an issue with timing (motion off -> lamp off scheduled. What happens when motion is detected in the interval between "motion off" and "lamp off"?)

    Some quick thoughts. The incantation (startSource["type"] == "other") means "when I started the scene with the start button" (and not via some trigger or autostart). It may help you in debugging, but I often don't have it in my scripts.

    I wouldn't mess with the starting comment of the script ( --[[ %% properties etc...) since it has special meaning. So I'd write:

    Please login or register to see this code.

    But you are right that is a comment section... I use it to comment out larger blocks.

    • 0
  • Inquirer
  • Posted
    I think there is an issue with timing (motion off -> lamp off scheduled. What happens when motion is detected in the interval between "motion off" and "lamp off"?)

    Thank you petergebruers to help me out. I think this case never happen because the Scene Motion only run when Motion in Safe Mode

    Please login or register to see this code.

    I have one more question, it better to check variable priority to save battery?

    First Check condition on Home Center (SceneEnabled variable in this case)

    Then Check condition on Wire Device (Dimmer value in this case)

    Last Check condition on Battery Powered Device (Motion Sensor in this case) - if the 2 above condition is not meet than we don't have to check Motion Sensor = less data query = less battery consumed?

    Or that doesn't matter to check condition priority at all, Fibaro System handle all these?

    Sorry for too many noob questions, I just got my hand on the HC2 yesterday and falling in love with it

    Please login or register to see this image.

    /emoticons/default_biggrin.png" alt=":D" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    • 0
    Posted

    tuanha,

    I guess you could combine the two scenes into one

    Please login or register to see this code.

    Don't worry about battery consumption as you only get the last value of the sensor cached in the server

    • 0
  • Inquirer
  • Posted

    Thank you jgab,

    I've learn a few trick from your code just posted above

    Please login or register to see this image.

    /emoticons/default_biggrin.png" alt=":D" 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...