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

local triggers


goolliver

Question

Hallo,

I'm looking for a way how to make a local variable a trigger in a LUA scene. For global variable it's easy, you declare it in "%%globals", how about local?

Can you help?

Thanx

mark

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

you got

Please login or register to see this code.

after it use name of that variable

Link to comment
Share on other sites

  • 0
  • Inquirer
  • you got

    Please login or register to see this code.

    after it use name of that variable

    Hallo,

    Thanx for the answer. Do You mean sth like that:

    %%globals

    example_of_a_global_variable

    example_of_the_local_variable

    Is that what you mean?

    Link to comment
    Share on other sites

    • 0

    global yes, local no (remember when script is ending you lose all local variables)

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Ok, Can you look at the script below and tell me why the local in bold (full_hour) doesn't

    want to work as a trigger. I mean it works, but only when the global HeatTime is frequently refreshed within another scene in a loop.

    Thanx so much.

    --[[

    %% properties

    3105 value

    3119 value

    %% globals

    HeatTime

    --]]

    local sourceTrigger = fibaro:getSourceTrigger();

    local time = os.date ("*t");

    local day = tonumber(os.date("%w"));

    local hour = tonumber (os.date("%I"));

    local minute = tonumber (os.date("%M"));

    local night_day = (os.date "%p");

    local full_hour = tonumber (hour..minute);

    fibaro:debug(hour..night_day);

    fibaro:debug(day);

    if

    (tonumber(fibaro:getValue(3105, "value")) > 0 )

    and

    ((full_hour) > 449)

    and

    ( tonumber(fibaro:getGlobalValue("HeatTime")) == tonumber("225") )

    and day < (6) and day > (0))

    and ( tonumber(fibaro:getValue(3119, "value")) == 0 )

    then

    fibaro:setGlobal("Heating", "on");

    fibaro:debug("On");

    Link to comment
    Share on other sites

    • 0

    It will only be triggered by 3105, 3119 and Heattime, so if these values changes the scene is triggered.

    Maybe you can tell us what you want to achieve, so we can help you.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Hi,

    Thanks.

    Yeah, this is the thing I want the scene to be triggered not only by the globals

    (3105, 3119 and Heattime) but also by the "full_hour" which is a local variable.

    How to trigger it by the local variable?

    mark

    Link to comment
    Share on other sites

    • 0

    goolliver, use time as a trigger

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • ok.

    But

    " local time = os.date ("*t"); "

    returns table not a string. What format of time do you suggest I use in

    "if (time =="xx")" ??

    mark

    Link to comment
    Share on other sites

    • 0

    I use:

    local currentTime = os.date("%H:%M");

    then you can use:

    if ( currentTime == "09:00" )

    then

    ....

    end

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