We have moved at community.getvera.com

Author Topic: (SOLVED) Workaround for Flickering LED lights when set above ~90%  (Read 4926 times)

Offline big517

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Quote
I want to set a "rule" if you will that if ANY dimmer in the house is set >90% then the dimmer is set back down to =90%.  OR make it so that its not possible to set the brightness over 90%.  I'm using the GE/Jasco Dimmers, and the CreeLR6/EcoSmart LED downlights.

For Example....  Someone holds the "up" button on the dimmer it gets past 90%, when they let go, I want it to drop back down to 90%, OR never go above 90% in the first place...

In case your wondering "why"...  I purchased over 50 of the Cree LR6, AKA Home Depot EcoSmart LED retrofit downlights, and they CANNOT be set at a brightness over 90% (with the GE dimmers at least) otherwise they Flicker and dim up and down to about 80% brightness...  real fun...

This "global rule" i'm dreaming of will solve all my problems.  I've researched the advanced settings on the GE switches and cannot find any type of brightness governor.

As always any help is appreciated.  Thanks!

So after a month of searching for this answer, waiting on MCV to respond to my ticket (too busy with UI5 it seems), and diving deep into a lot of code that I was way over my head, I finally stumbled onto a post and used their similar situation to figure it out!
Thanks to Guard and ZMaF (http://forum.micasaverde.com/index.php?topic=5300.0)

Here is my modified code, there is some unused code / variables in there that I wanted to leave for future reference or more advanced scripting

This must be set in your Startup LUA which will create this globally
Dashboard - Mios Developers - Startup LUA

Code: [Select]
--Original Source: http://forum.micasaverde.com/index.php?topic=5300.0
--Currently Dimmers Flicker around 90% some at 93 so were setting all dimmers/led switches to 90% if they ever exceed that %


--Set this line for each device you want governed by this rule
luup.variable_watch ('no_dimming', 'urn:upnp-org:serviceId:Dimming1', 'LoadLevelStatus', 65)
luup.variable_watch ('no_dimming', 'urn:upnp-org:serviceId:Dimming1', 'LoadLevelStatus', 86)

--These lul variables can be used for more advanced settings so I wanted to keep them in this post
function no_dimming (lul_device, lul_service, lul_variable, lul_value_old, lul_value_new)
--If ANY of the devices watched in the first line(s) are set over 90% (which causes the flickering)
  if ( tonumber( lul_value_new ) > 90 ) then
    luup.call_action('urn:upnp-org:serviceId:Dimming1', 'SetLoadLevelTarget', { newLoadlevelTarget='90' }, lul_device)
--Take it back down to 90 (flicker free max)
  else
    end
end

Now there does seem to be some bug (or feature?) that if a switch is "held" for a period longer than 1 second it gets excluded from triggering a scene, and this is no exception, therefore if someone does hold this button over 1 second and it sets over 90% it will stay there  :-\ but if you hit the up button again, the rule is caught and it drops back down to the 90% value in the code... 

I'm hoping this will help others out, and also create some other useful settings, or cool scenarios.  One thing I want to implement is to avoid a "range" of level for example, I have a bank of 4 leds that will flicker between 55% and 67% so maybe someone can help me with the if/then statement for only a select device while still being part of this code since it's part of the startup lua. 

Thanks all!
« Last Edit: October 08, 2011, 07:33:08 am by big517 »

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: (SOLVED) Workaround for Flickering LED lights when set above ~90%
« Reply #1 on: October 10, 2011, 12:32:07 pm »
@big517 - what led lights are you using? After trying different ones I tried the Philips LED Ambient light and it works well for me...
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline big517

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 576
  • Karma: +1/-4
Re: (SOLVED) Workaround for Flickering LED lights when set above ~90%
« Reply #2 on: November 02, 2011, 07:06:44 am »
I wanted to follow up with code that works for Min and Max, and also allows for a "Range" to be avoided when dimming...  This is the best "Software" solution I've found for flickering LED lights, there is a Thread by TimALLs regarding an in-line capacitor which sounds like a great permanent solution.  In the meantime here is the code i've just updated thanks to all the contributors in this forum:

Code: [Select]
luup.variable_watch ('alterLoadLevelTarget', 'urn:upnp-org:serviceId:Dimming1', 'LoadLevelStatus', 10)
luup.variable_watch ("alterLoadLevelTarget", 'urn:upnp-org:serviceId:Dimming1', 'LoadLevelStatus', 49)
luup.variable_watch ('alterLoadLevelTarget', 'urn:upnp-org:serviceId:Dimming1', 'LoadLevelStatus', 91)

local PARAMS = {
    [91] = {             -- Device number (Kitchen LED Lights)
        MIN_VALUE = 0, -- Minimum value
        MAX_VALUE = 80  -- Maximum value
        -- Exclusion range is missing, so it won't be used. If any parameter is missing, it means it won't be used.
    },
    [10] = { --Butler Pantry LED Lights
        MIN_VALUE = 0,
        MAX_VALUE = 88,
        EXCL_RANGE = {
            START = 45,
            STOP = 75
        }
    }


}

local altered = {}

function alterLoadLevelTarget (device, service, variable, valueOld, valueNew )

    if (not altered[device]) then
        value = tonumber (valueNew, 10)

        if (PARAMS[device].MIN_VALUE ~= nil and value < PARAMS[device].MIN_VALUE) then
            altered[device] = true
            luup.call_action (service, "SetLoadLevelTarget", {newLoadlevelTarget = tostring (PARAMS[device].MIN_VALUE)}, device)
        elseif (PARAMS[device].MAX_VALUE ~= nil and value > PARAMS[device].MAX_VALUE) then
            altered[device] = true
            luup.call_action (service, "SetLoadLevelTarget", {newLoadlevelTarget = tostring (PARAMS[device].MAX_VALUE)}, device)
        elseif (PARAMS[device].EXCL_RANGE ~= nil and (value >= PARAMS[device].EXCL_RANGE.START and value <= PARAMS[device].EXCL_RANGE.STOP)) then
            altered[device] = true
            luup.call_action (service, "SetLoadLevelTarget", {newLoadlevelTarget = tostring (valueOld)}, device)
        end
    else
        altered[device] = false
    end
end
« Last Edit: February 01, 2012, 08:59:37 pm by big517 »