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


Ask for Scene by Lua


Recommended Posts

Hi guys I ask for Lua scene to control the lights automatically into star's by motion detection bt problem not for that 

The problem is I want that scene work between 6 pm to 7am and if motion detection don't detect any move then turn off light after 20 minutes 

Any one hare can help my to do that 

 

 And Thanks for every one 

Link to post
Share on other sites

You can do it with

Please login or register to see this link.

and many other actions... you can find an examples how to use it in

Please login or register to see this link.

Here is the solution for you:

Please login or register to see this code.

The light will turn off if no motion detected within 20-25 minutes.

Edited by cag014
Link to post
Share on other sites
  • Topic Author
  • --[[
    %% autostart
    %% properties
    %% events
    %% globals

    --]]
    jS2n={stairMS=110,stairSoptLight=266,stairHiddenLight=263} --please change stairMS and stairLight to your real device ID

    jM = {{
    {5,"stairMS",{state="value=true",timeSlot="18:00~07:00",timeSpanOn=true,
    trueAct={"stairSoptLight","stairHiddenLight","turnOn","",""},
    timeLoopAct={"stairSoptLight","stairHiddenLigh","turnOff","","",
    {"stairMS:valueModified>1200|stairSoptLight,stairHiddenLigh:value=true"}}}

    }

     

    Please login or register to see this attachment.

    Edited by mohamedsalah
    Link to post
    Share on other sites

    Please login or register to see this code.

    Please pay attention that any device name should be within back apostrophe ` (located on same key with ~)

    Edited by cag014
    Link to post
    Share on other sites
    25 minutes ago, cag014 said:

    Please login or register to see this code.

    Please pay attention that any device name should be within back apostrophe ` (located on same key with ~)

    I have edited the post probably after you have saw it...

    Edited by cag014
    Link to post
    Share on other sites
    • 2 weeks later...
  • Topic Author
  • What's defrant between that scene 

     

    --[[
    %% autostart
    %% properties
    110 value
    266 value
    263 value
    %% events
    %% globals

    --]]
    jS2n={stairMS=110,stairSoptLight=266,stairHiddenLight=263} --please change stairMS and stairLight to your real device ID

    jM = {
    {5,"`stairMS`",{state="value=true",timeSlot="17:00~07:00",timeSpanOn=true,
    trueAct={"`stairSoptLight`|`stairHiddenLight`","turnOn",""},
    timeLoopAct={"`stairSoptLight`|`stairHiddenLigh`","turnOff","","{`stairMS`:valueModified>1200|`stairSoptLight`,`stairHiddenLigh`:value=true}"}}},
    }
    And that scene 

     

    --[[
    %% autostart
    %% properties
    110 value
    %% weather
    %% events
    %% globals
    --]]

    local sourceTrigger = fibaro:getSourceTrigger();
    function tempFunc()
    local currentDate = os.date("*t");
    local startSource = fibaro:getSourceTrigger();
    if (
     ( tonumber(fibaro:getValue(110, "value")) > 0  and  (math.floor(os.time()/60)-math.floor(1582381980/60))%60 == 0 )
    )
    then
        fibaro:call(263, "turnOn");
        fibaro:call(266, "turnOn");
    end

    setTimeout(tempFunc, 60*1000)
    end
    if (sourceTrigger["type"] == "autostart") then
    tempFunc()
    else

    local currentDate = os.date("*t");
    local startSource = fibaro:getSourceTrigger();
    if (
     ( tonumber(fibaro:getValue(110, "value")) > 0  and  true )
    or
    startSource["type"] == "other"
    )
    then
        fibaro:call(263, "turnOn");
        fibaro:call(266, "turnOn");
    end

    end

     

    The images for scend scene

    The target for the first one is make light on if motion detection detact any move from 17 pm to 7 am and if no motion after 20 minutes the light it will be off but the code is run success but light don't work

    Scand scene light work but all the time in day 

    Wath should I do to solve this problem problem 😅🤔

    Please login or register to see this attachment.

    Link to post
    Share on other sites
    10 minutes ago, mohamedsalah said:

    but the code is run success but light don't work

    Do you mean that lights don't turned ON?

    What exactly doesn't work?

     

    Regarding block scene: Looks OK, but you need to create another block scene that turns lights off when sensor back to safe

    Edited by cag014
    Link to post
    Share on other sites

    Are you sure it work at all or shows an error?

    The reason to my question is that you have typo error

    jS2n={stairMS=110,stairSoptLight=266,stairHiddenLight=263} --please change stairMS and stairLight to your real device ID

    jM = {
    {5,"`stairMS`",{state="value=true",timeSlot="17:00~07:00",timeSpanOn=true,
    trueAct={"`stairSoptLight`|`stairHiddenLight`","turnOn",""},
    timeLoopAct={"`stairSoptLight`|`stairHiddenLigh`","turnOff","","{`stairMS`:valueModified>1200|`stairSoptLight`,`stairHiddenLigh`:value=true}"}}},
    }

    instead stairHiddenLigh it should be stairHiddenLight. Missing 't'

    Link to post
    Share on other sites

    Regarding block scene: Looks OK, but you need to create another block scene that turns lights off when sensor back to safe. It should be a same scene. Replace Breached to Safe,  TurnON to TurnOff and set 1200 s

    Please login or register to see this spoiler.

     

    Edited by cag014
    Link to post
    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
    Reply to this topic...

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