Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

light_store.py and RGBW lights-problem #157

Open
aracdin opened this issue May 23, 2020 · 3 comments
Open

light_store.py and RGBW lights-problem #157

aracdin opened this issue May 23, 2020 · 3 comments

Comments

@aracdin
Copy link

aracdin commented May 23, 2020

Hi,
Thanks for the useful routine. I tried using this with an RGBW light in Home-Assistant and it would restore the brightness, but not the colour. Python isn't one of my languages yet, but I eventually tracked the problem to "they will be saved: brightness, effect, and one of the following (in order of precedence): white_value, color_temp, hs_color" - an RGBW has both white level AND the RGB/HS value - and light_store only brings back the first it finds. I temporarily fixed my problem by altering the precedence to COLOR_ATTRS = [ATTR_HS_COLOR, ATTR_COLOR_TEMP, ATTR_WHITE_VALUE], but unfortunately my python isn't good enough for a full fix :-(

@pnbruckner
Copy link
Owner

I don't have any RGBW lights, so I can't test with it, but maybe try changing this:

# Save any of these attributes.
GEN_ATTRS = [ATTR_BRIGHTNESS, ATTR_EFFECT]
# Save only one of these attributes, in order of precedence.
COLOR_ATTRS = [ATTR_WHITE_VALUE, ATTR_COLOR_TEMP, ATTR_HS_COLOR]

to this:

# Save any of these attributes.
GEN_ATTRS = [ATTR_BRIGHTNESS, ATTR_EFFECT, ATTR_WHITE_VALUE]
# Save only one of these attributes, in order of precedence.
COLOR_ATTRS = [ATTR_COLOR_TEMP, ATTR_HS_COLOR]

@aracdin
Copy link
Author

aracdin commented May 23, 2020

As near as I can tell that works - so thank you! I guess we might have a similar problem with RGBWW where it stores (I believe) RGB and White Temperature, but I don't have one set up... yet ;-)

@aracdin aracdin closed this as completed May 23, 2020
@aracdin
Copy link
Author

aracdin commented Jul 23, 2020

I looked at RGBWW, and then at https://github.com/home-assistant/core/blob/dev/homeassistant/components/light/reproduce_state.py - it looks like that defines the order HA looks at the parameters and I think it has been updated. I copied their order and it works with an RGBWW for both Colour and White states. I ended up with these two parameter sets. I also had a ATTR_BRIGHTNESS_PCT parameter in my automation which caused some confusion as it is deprecated.

GEN_ATTRS = [ATTR_BRIGHTNESS, ATTR_EFFECT, ATTR_TRANSITION, ATTR_PROFILE, ATTR_WHITE_VALUE, ATTR_BRIGHTNESS_PCT, ATTR_BRIGHTNESS_STEP, ATTR_BRIGHTNESS_STEP_PCT, ATTR_FLASH]

COLOR_ATTRS = [ATTR_HS_COLOR, ATTR_COLOR_TEMP, ATTR_RGB_COLOR, ATTR_XY_COLOR, ATTR_PROFILE, ATTR_COLOR_NAME, ATTR_KELVIN]

One again - thanks

@aracdin aracdin reopened this Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants