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


Question

Posted

Pfff can somebody help me..... somehow i'm stuck in my very limited lua knowledge, running version 4.049

 

Converting the brightness level from the hue 0-255 to the variable "Lights" to 0-100 is working

 

What doesn't work is the using the variable to update the dim level of ID 223

 

Hope somebody can help me out? 

Please login or register to see this image.

/emoticons/default_icon_rolleyes.gif" alt=":roll:" />

 

 

Please login or register to see this code.

10 answers to this question

Recommended Posts

  • 0
Posted

Please try this. Convert your calculated dimming level to the lowest integer, like this:

 

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    wow! thanks it works 

    Please login or register to see this image.

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

     

    Could you explain why this works?

    • 0
    Posted

    Certainly. The call to do a "setValue" expects an integer. Lua is dynamically typed, which means in this case that it deduces from the division by 2.55 that the resulting variable has to be a float. This makes the call fail silently. Using math.floor solves this and also makes printing or displaying the number a lot prettier. Have fun!

    • 0
  • Inquirer
  • Posted

    Ok thanx!

     

    My next issue...

     

    I'm reading out the status of the Hue plugin and want use that as a on/off trigger for the fibaro dimmer. 

     

    When I read out fibaro:getValue(370, "on"). I see in a VD label it changing from 0 to 1 when switching on.

    So tried to write to local variable and used it as a trigger if (Lightstatus == 1)

     

    Doesn't work, copied to a globalvariable and now it's showing "nil" 

    Please login or register to see this image.

    /emoticons/default_icon_neutral.gif" alt=":-|" />

    • 0
    Posted

    I'm not sure I follow but "So tried to write to local variable and used it as a trigger" sounds suspicious. Only Global Variable (in the Variables Panel) can trigger scenes.

    If you export and upload your virtual device (vfib) here, I can have a look at your code.

    • 0
  • Inquirer
  • Posted

    -

    • 0
  • Inquirer
  • Posted

    Managed to get it working by trying building something in a block scene and converting to lua,..

     

    This the code now... that synchronize the dimmer with philips hue bulb

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

    Many thanx for the help! 

    • 0
    Posted

    Glad I could help! Maybe two last things: you don't need "fibaro:call(223, "turnOn");" because the next line turns on the dimmer, if the level is between 1 and 99 (full on). And level 0 turns it off. Also the line beginning with "local trigger" isn't needed. You'll find some scripts that test or a certain value, but then you'll see an "if" statement referring to it. Have fun!

    • 0
    Posted
    On 5.8.2015 at 11:56 PM, sebaszz said:

    Managed to get it working by trying building something in a block scene and converting to lua,..

     

    This the code now... that synchronize the dimmer with philips hue bulb

    Please login or register to see this code.

    Hi

    Tried to use your LUA code to controll three HUE light with a dimmer, but get an error code in debug:

    [DEBUG] 22:14:10: line 16: attempt to perform arithmetic on local 'Dimminglevel' (a nil value)

     

    The code I tried is:

     

    --[[
    %% autostart
    %% properties
    25 ui.brightness.value
    25 on
    %% globals
    --]]

    local trigger = fibaro:getSourceTrigger()

    if (fibaro:countScenes()>1) then
      fibaro:abort();
    end

    local Dimminglevel = fibaro:getValue(25, "ui.brightness.value")
    fibaro:setGlobal("Lights", math.floor(Dimminglevel / 2.55))

    local Dimminglevel2 = fibaro:getGlobal("Lights")


    local LightStatus = fibaro:getValue(25, "on")

    if
     ( tonumber(fibaro:getValue(25, "on")) > 0 )
    then
        fibaro:call(175, "turnOn");
          fibaro:call(175, "setValue", Dimminglevel2 )
        fibaro:call(176, "turnOn");
          fibaro:call(176, "setValue", Dimminglevel2 )
        fibaro:call(177, "turnOn");
          fibaro:call(177, "setValue", Dimminglevel2 )  
    else
        fibaro:call(175, "turnOff")
          fibaro:call(176, "turnOff")
          fibaro:call(177, "turnOff")
    end

     

    I had regular lights in the room, but changed them to HUE E27 and wanted to control them with the dimmer/ add them to scenes ++.

     

    Can you help me? Thanks

    -KH

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