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


Recommended Posts

Posted

got a question about debug

 

if got a script with

 

local lamp = {22,55,66}

for i = 1,#lamp do

lightItems = lamp

if...... etc

 

when i debug this i get three times the same debug

if i change local lamp = {22,55,66} to local lamp = {22,55}

i get two debugs

and when there is only 22 i get one debug

 

how can i change this to always one debug

 

thanks

Posted

I don't understand the question. If the "debug" is in the loop, then you get a line for each member of the array. If you don't want that, use an "accumulator string". That is: make an empty string before the loop. In the loop, add data to it. After the loop print (debug) the string. Can you please post some runnable code? Or use your actual code (10 lines max), but remove the non interesting parts?

  • Topic Author
  • Posted

    i think that is exactly it (you do understand me

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" /> )

     

    the code partly

    local lampBuiten = {22,55,66}

    local sunrise       = fibaro:getValue(1, "sunriseHour")
    local sunset        = fibaro:getValue(1, "sunsetHour")

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

    local timeUit        =  os.date("%H:%M", os.time()-60*60)

     

    -------------------------------------------------------------
    --Buiten lampen
    -------------------------------------------------------------
    for i = 1,#lampBuiten do
      buitenLampItems = lampBuiten;
        if (((sunset > timeNow and sunrise > timeUit)
                or (sunset < timeNow and sunrise < timeNow)))
            and fibaro:getValue(buitenLampItems, "value") == "0"
          then fibaro:call(buitenLampItems, "turnOn")
          fibaro:debug("Buitenlicht gaat aan.")
        end
        if (sunrise < timeUit and sunset > timeNow and sunset > timeUit)
            and fibaro:getValue(buitenLampItems, "value") == "1"
          then fibaro:call(buitenLampItems, "turnOff")
          fibaro:debug("Buitenlicht gaat uit.")
        end
    end

    Posted

    Please login or register to see this code.

    local lampBuiten = {22,55,66}

    local sunrise = fibaro:getValue(1, "sunriseHour")

    local sunset = fibaro:getValue(1, "sunsetHour")

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

    local timeUit = os.date("%H:%M", os.time()-60*60)

    -------------------------------------------------------------

    --Buiten lampen

    -------------------------------------------------------------

    if (((sunset > timeNow and sunrise > timeUit) or (sunset < timeNow and sunrise < timeNow)))

    then

    for i = 1,#lampBuiten do

    buitenLampItems = lampBuiten;

    if fibaro:getValue(buitenLampItems, "value") == "0" then

    fibaro:call(buitenLampItems, "turnOn")

    end

    end

    fibaro:debug("Buitenlicht gaat aan.")

    elseif (sunrise < timeUit and sunset > timeNow and sunset > timeUit)

    then

    for i = 1,#lampBuiten do

    buitenLampItems = lampBuiten;

    if fibaro:getValue(buitenLampItems, "value") == "1" then

    fibaro:call(buitenLampItems, "turnOff")

    end

    end

    fibaro:debug("Buitenlicht gaat uit.")

    end

  • Topic Author
  • Posted

    Please login or register to see this image.

    /emoticons/default_icon_idea.gif" alt=":idea:" />  TOP

     

    zie het nu. zat hem zoals peter al zei "Het zit in de loop"

     

    Stom van me

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