Skip to content

Flux bug fix#14476

Merged
fabaff merged 7 commits intohome-assistant:devfrom
oblogic7:flux_bug_fix
May 18, 2018
Merged

Flux bug fix#14476
fabaff merged 7 commits intohome-assistant:devfrom
oblogic7:flux_bug_fix

Conversation

@oblogic7
Copy link
Copy Markdown
Contributor

@oblogic7 oblogic7 commented May 15, 2018

Description:

Fixes bugs introduced by changes on #13985

Specifically, this PR fixes issues with setting brightness and rgb values simultaneously (reported by kineticscreen on the original PR).

Also fixes issue (reported by tadly on original PR) with flux.switch component not setting white_value which is required after the orignal PR was merged.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass

@syssi
Copy link
Copy Markdown
Member

syssi commented May 16, 2018

./homeassistant/components/light/flux_led.py:255:5: E303 too many blank lines (2)


# white change only
elif white is not None:
if white is not None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes from elifs to ifs will make it do four color change calls to the bulb if rgb, brightness, effect and white are all set. Even with just rgb and brightness, it'll still go through the whole "fetch rgb" block. This method should only ever call a single setRgb, from the looks of it.

Simply returning after each setRgb would be one way to go here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, scratch that, as the first two ifs are mutually exclusive (I recommend switching that second block to elif to make that clearer.) It still seems like there's an issue if brightness and effect are both defined, as it'll make two .setRgb calls

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OverloadUT I was able to simplify the conditionals even further by specifying fallback brightness value if argument not passed. This allowed the use of a single call to setRgb as you mentioned.

Setting white value requires a separate call, so I left that as a separate conditional.

Effects override rgb, brightness and white levels so no need to support simultaneous setting of values when an effect is used.

self._bulb.setWarmWhite255(white)

# random color effect
elif effect == EFFECT_RANDOM:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better! However, since effects override all other options, move it up as the first conditional so that an unnecessary setRgb call doesn't get made. This current code will always make two calls when there is an effect.

Also, if effect completely overrides brightness and rgb, I think you should fire off a warning if those conflicting parameters are passed in, to ease troubleshooting for users. Not a hard requirement here as the previous code didn't have that, but if you're making changes anyway and feel like it... ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated effect conditionals for early return to prevent unnecessary call to setRgb. Also updated default value handling to support addition of the warning.


# preserve color on brightness/white level change
if rgb is None:
rgb = self._bulb.getRgb()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the brightness and rgb assignment to after the effect conditionals to avoid this logic. (Not sure if getRgb requires I/O, so it'd be nice to avoid that in case it does).

After that, I think this is good to go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. Thanks for the suggestions.

@OverloadUT
Copy link
Copy Markdown
Contributor

Looks good to me!

@fabaff fabaff merged commit 909f244 into home-assistant:dev May 18, 2018
@VegtMedia-Alex
Copy link
Copy Markdown

This does not work correct. When i put a flux light off and then i activate a scene with:

light.zithoek_sfeer_verlichting:
state: on
white_value: 50

Nothing happens because the brightness is 0, When i toggle the brightness to any number and then activate the scene with the white_value it works.

Really dont understand this PR, everything was working perfect and now so much issues...

@VegtMedia-Alex
Copy link
Copy Markdown

Also there is no toggle for the white value in the User interface, so how can we change the white brightness now from the UI?

@oblogic7
Copy link
Copy Markdown
Contributor Author

oblogic7 commented May 25, 2018

The issue that the original PR fixed was that the W channel on an RGBW capable controller used the brightness value alone. Setting white_value had no effect and W could not be controlled independently from RGB.

I set brightness to 0 (which HA interprets as off because brightness is coupled to on/off state) and then tested a service call with the following payload:

{
  "entity_id": "light.test_led",
  "white_value": 255
}

This resulted in W channel being set to full brightness as expected.

Regarding the interface, if you have a RGBW controller, then you should see a slider on the interface like in the screenshot below.

image

If you can provide more information about which controller you have and the config you are using, I'll be glad to try and reproduce the issues you report. Maybe start a topic on the forums so we can discuss there?

@VegtMedia-Alex
Copy link
Copy Markdown

I am using this component:

https://www.home-assistant.io/components/light.flux_led/ I have the magic light LED controller at home with a RGBW strip.

See screens below for my UI and configs

screen shot 2018-05-27 at 00 03 12

screen shot 2018-05-27 at 00 06 08

Hopefully you can fix this soon.

@oblogic7
Copy link
Copy Markdown
Contributor Author

The first thing I see is that you manually specify RGBW for the mode. Does the system behave differently if you remove that and allow it to detect the mode automatically?

Also, do you have a link to the specific controller you are using?

@VegtMedia-Alex
Copy link
Copy Markdown

VegtMedia-Alex commented May 26, 2018

Just removed the mode parameter. I have the white bar now, so guess this is an improvement already :)

I will try to check if the error still persists.

The controller is:
https://nl.aliexpress.com/item/DC5-24V-Wireless-WIFI-LED-RGB-Controller-RGBW-Controller-IR-RF-Remote-Control-IOS-Android-for/32827253255.html?spm=a2g0s.9042311.0.0.27424c4dKVcZ2K

@oblogic7
Copy link
Copy Markdown
Contributor Author

Definitely not the same controller I have so I just ordered one from Amazon. I should have it by May 30 and will figure out what the problem is shortly thereafter. Thanks for reporting the issue and for being patient.

@VegtMedia-Alex
Copy link
Copy Markdown

Np, in the meantime i will try to figure out of the bugs are still there or if they are gone with the automatic mode detection :)

@VegtMedia-Alex
Copy link
Copy Markdown

VegtMedia-Alex commented May 27, 2018

The bug is still there when the light is off and then i activate a scene withe white value. It gives a flash of white but then it stays off instead of on.

The second time i hit the scene on it works like it should be

@balloob balloob mentioned this pull request May 28, 2018
@oblogic7
Copy link
Copy Markdown
Contributor Author

@alexvandervegt I got my controller in today and I was able to reproduce the flash of light that you report. Will look into it more tonight, but wanted to provide an update.

@VegtMedia-Alex
Copy link
Copy Markdown

Thanks for the update! Hopefully we have a solution soon :)

@oblogic7
Copy link
Copy Markdown
Contributor Author

The PR below should correct the issues reported here.

#14713

@VegtMedia-Alex
Copy link
Copy Markdown

Great i will test it asap

@kineticscreen
Copy link
Copy Markdown

Yeah I have had the same issue with 0.70 - the brightness and RGB fix worked, but the RGB and W levels seem to be operating in an 'OR' scenario, toggling each other off.

@VegtMedia-Alex
Copy link
Copy Markdown

The issue is still present in 0.71.0. Hopefully this will be resolved soon :(

@oblogic7
Copy link
Copy Markdown
Contributor Author

@alexvandervegt #14713 did not make it into the 0.71 release.

@VegtMedia-Alex
Copy link
Copy Markdown

Is it included in 72?

@oblogic7
Copy link
Copy Markdown
Contributor Author

oblogic7 commented Jun 18, 2018 via email

@kineticscreen
Copy link
Copy Markdown

Any idea what's causing the 'snap-on' instead of fade-up with these controllers? Via the Magic Home app they fade up in the same way as they fade out on 'off'. With Hassio they snap on.

@oblogic7
Copy link
Copy Markdown
Contributor Author

@kineticscreen Just pushed a fix for this on #14713

Should be fixed when that PR is merged.

@fleshinachair
Copy link
Copy Markdown

any ideas when this will be released? Thanks!

@oblogic7
Copy link
Copy Markdown
Contributor Author

This went out on v0.70

@fleshinachair
Copy link
Copy Markdown

If you look up the thread it wasn't in 0.72, so I'm not sure it's in yet?

@oblogic7
Copy link
Copy Markdown
Contributor Author

That was referencing a separate PR...

#14713 did not make it into the 0.71 release.

This PR is #14476 and most definitely went out on 0.7.0

image

@fleshinachair
Copy link
Copy Markdown

Thankyou for confirming, I better figure out why it still doesnt work for me then! Cheers.

@kineticscreen
Copy link
Copy Markdown

Still having the issue where when a 'scene' is called from an off state, the RGB values are ignored. The colours are correctly set if the scene is called again.

@fleshinachair
Copy link
Copy Markdown

fleshinachair commented Jul 20, 2018 via email

@home-assistant home-assistant locked and limited conversation to collaborators Dec 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants