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

HC3, repeat action in LUA scene ???


Question

Posted

Hi.

 

how can i repeat this action 10x, with a delay of 2sec ???

 

ACTION:

 

fibaro.call(429'turnOn')
fibaro.setTimeout(5000function()
fibaro.call(429'turnOff')
end)
 
TNX again.

11 answers to this question

Recommended Posts

  • 0
Posted

Simple way to do it

 

for i=1,10 do

fibaro.call(429'turnOn')
fibaro.sleep(5000)
fibaro.call(429'turnOff')
fibaro.sleep(2000)
end
 
The question how your scene is triggered? HC3 allows only one scene instance... new instance kills previous...
 
  • 0
  • Inquirer
  • Posted

    I thought so, but it didn't work. so i asked this question.

    Looks like it must be for each delay individually one " end)"

     

    example:

    fibaro.call(188'turnOn')
    fibaro.setTimeout(2000function()
    fibaro.call(189'turnOn')
    fibaro.setTimeout(2000function()
    fibaro.call(429'turnOn')
    fibaro.setTimeout(10000function()
    fibaro.call(429'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(429'turnOn')
    fibaro.setTimeout(10000function()
    fibaro.call(429'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(429'turnOn')
    fibaro.setTimeout(10000function()
    fibaro.call(429'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(429'turnOn')
    fibaro.setTimeout(10000function()
    fibaro.call(429'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(429'turnOn')
    fibaro.setTimeout(10000function()
    fibaro.call(429'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(429'turnOn')
    fibaro.setTimeout(10000function()
    fibaro.call(429'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(429'turnOn')
    fibaro.setTimeout(10000function()
    fibaro.call(429'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(189'turnOff')
    fibaro.setTimeout(2000function()
    fibaro.call(188'turnOff')
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    end)
    • 0
    Posted

    It works for me.. I mean the for i... loop

    • 0
  • Inquirer
  • Posted

    No problem, this are probably differences between HC2 & HC3.

     

    I wanted a simple scene for a hunter watering system which I can activate with a virtual switch

     

    when:
    virtual switch to ON

     

    then:
    - Submersible pump ON
    - delay 2s
    - water supply ON 
    - delay 2s
    - watering line 1 ON
    - delay 30min
    - watering line 1 OFF
    - delay 2s
    .
    .
    .
    - watering line 7 ON
    - delay 30min
    - watering line 7 OFF
    - delay 2s
    - Submersible pump OFF
    - delay 2s
    - Water supply OFF
    - delay 2s
    - virtual switch OFF

    • 0
    Posted
    1 hour ago, interested said:

    No problem, this are probably differences between HC2 & HC3.

    I've tested that on HC3 (not HC2)

    • 0
  • Inquirer
  • Posted (edited)

     

    cag014,

     

    however, I tested again your way, but is not working (2.example & debugger)

     

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Edited by interested
    • 0
    Posted (edited)

    The error that you have  end on line 10... why you have end while no loop or if defined. remove it.

    In addition you didn't tested my way... I did it in loop.

    Anyhow just remove end at line 10.

    Another "issue", as I mentioned if the scene triggered again, previous scene's instance is killed and the loop will start over again. Be careful...

    Edited by cag014
    • 0
  • Inquirer
  • Posted

    cag014,

     

    I followed your example and since you had an end at the end, of course I used it to :) 

     

    TNX for time & the help ... my example is working now.

     

    • 0
    Posted (edited)

    Hi!

    @cag014, please help

    I need to make some timeout between sending z-wave commands fibaro.call(id, "turnOff"in scene, but got timeout ONLY before sending the first of z-wave command :( 

    What wrong ?

     

    devices=fibaro.getDevicesID({
    visible = true
    enabled = true
    roomID = 239,
    properties = {dead=false , isLight=true}
    }) 
    for _,id in ipairs(devices) do 
        fibaro.setTimeout(1000function() 
         if fibaro.getValue(id, "state")
          then fibaro.call(id, "turnOff")
              fibaro.debug("MasterOFF""TurningOFF:", id, fibaro.getName(id))
          end
         end)
    end
    Edited by vsokolov
    • 0
    Posted (edited)

    You can use fibaro.sleep() function

     

     

    for _,id in ipairs(devices) do
         if fibaro.getValue(id, "state")
          then fibaro.sleep(1000)
              fibaro.call(id, "turnOff")
              fibaro.debug("MasterOFF""TurningOFF:", id, fibaro.getName(id))
          end
    end
    Edited by cag014
    • 0
    Posted (edited)

    @interestedI have in my pieces of code a library whose one function could perhaps interest you :)

     

    Executes a combined function (sequence) with specified interval

     

    arg1: sequence array

    arg2: beginCallback

    arg3: endingCallback

    Please login or register to see this code.

    image.png.46113a636fcbc433396b1ca298a56cdf.png

     

    Lib: (Just add the library to the top of the scene)

     

    Please login or register to see this code.

     

    Edited by Krikroff
    • Thanks 1

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