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

Return LightEntityFeature(0) zero value in supported_features when there are no effects #826

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

djhworld
Copy link

@djhworld djhworld commented Jan 4, 2025

Fixes #825

In HA 2025.1 support for using integers in supported_features was removed home-assistant/core#132371

@goldnaegele
Copy link

Works fine for me. Thank you!

@pgarciafc
Copy link

pgarciafc commented Jan 5, 2025

Hi,

Thanks for your contribution. Indeed, changing from 0 to list, brought the light entity back to HASS.

However, on my L530 entities that are part of a group (e.g. three L530 grouped as "Living room"), the entity is still unavailable. The error I see is:

File "/usr/src/homeassistant/homeassistant/components/group/light.py", line 304, in async_update_group_state self._attr_supported_features |= support TypeError: unsupported operand type(s) for |=: 'LightEntityFeature' and 'list'

Any ideas?

Thank you!

@Adagis-MC
Copy link

As above, where the entities are part of a group, they are identified as "Unavailable" although it appears that selecting the group triggers the default action for the group (turning on and off).
I have also noticed that brightness is now displayed as a value between 0 and 255 rather than a percentage.

@pgarciafc
Copy link

pgarciafc commented Jan 5, 2025

For my particular case, since all my lights are 530E, I simply replaced lines 54-56 with
self._attr_supported_features = (LightEntityFeature.EFFECT) and now everything is working fine, even groups.

@Av4K100
Copy link

Av4K100 commented Jan 5, 2025

I am also having issue's with a group of 3 L630 spotlight's, the change to light.py does resolve the individual bulbs not showing up however the entity which has all three grouped is no longer recognised. Deleting the group and setting up again causes the group to fail to setup correctly. Any ideas's on how to fix this?

@Av4K100
Copy link

Av4K100 commented Jan 5, 2025

Change mentioned by pgarciafc seems to have also done the trick for me, light groups have returned to working and everything seems to be working okay so far

@djhworld
Copy link
Author

djhworld commented Jan 5, 2025

I've updated the PR to return (LightEntityFeature.EFFECT) when self._effects has stuff and () when it does not

Does this fix the issue with the groups?

@Av4K100
Copy link

Av4K100 commented Jan 5, 2025

Have just updated the config to the new code you have posted in the PR and restarted however that does not allow the light groups to work unfortunately, after changing the code back to that noted by pgarciafc the groups are working again

@pgarciafc
Copy link

Exactly, and probably that's due to () representing tuples while LightEntityFeature's type is enum.

Just want to highlight that my solution is likely going to bring other hidden issues / lack of functionalities especially to those with multiple light types. It just works for me (and others in this thread) because 1) we run the same lights model or 2) we are just validating very basic functionalities.

@djhworld
Copy link
Author

djhworld commented Jan 5, 2025

I wonder if there's something broken/changed with these two lines

supported_effects = _components_to_light_effects(device)
self._effects = {effect.name.lower(): effect for effect in supported_effects}

because just setting

self._attr_supported_features = (LightEntityFeature.EFFECT)

suggests to me self._effects is returning an empty dict. I'm not super familiar with this code or HA code

@djhworld djhworld marked this pull request as draft January 5, 2025 10:36
@djhworld
Copy link
Author

djhworld commented Jan 5, 2025

I've moved this PR to Draft for the time being until we can get to the proper fix.

@djhworld djhworld changed the title Return empty list when there are no effects Return LightEntityFeature(0) zero value in supported_features when there are no effects Jan 5, 2025
@djhworld
Copy link
Author

djhworld commented Jan 5, 2025

I've updated the PR again to return LightEntityFeature(0) for the no effects case - this fixes the issue with my light (not in a group)

but the issue aroudn groups etc - I've not got the setup to test it and not sure what's going wrong, I think we need to figure out what self._effects was set to in the previous version of HA for these cases, maybe there's something broken there

@Adagis-MC
Copy link

@djhworld I've retested your latest PR and it resolves the issue with the lights individually but also retains the functionality of the light groups.

Also noted (coincidence?) that an updated version of HACS seems to have resolved the display of percentages instead of 0-255.

@djhworld
Copy link
Author

djhworld commented Jan 5, 2025

@Adagis-MC just to confirm, latest change works for the groups case?

@Adagis-MC
Copy link

@djhworld Correct. the latest change works for the groups case.

@djhworld
Copy link
Author

djhworld commented Jan 5, 2025

Nice!

OK I'll move the PR out of draft state.

@djhworld djhworld marked this pull request as ready for review January 5, 2025 11:06
@djhworld
Copy link
Author

djhworld commented Jan 5, 2025

For reference looks like this issue was caused by this home-assistant/core#132371

@Av4K100
Copy link

Av4K100 commented Jan 5, 2025

Can confirm this has also resolved the issue for myself :)

@kris-kuiper
Copy link

For my particular case, since all my lights are 530E, I simply replaced lines 54-56 with self._attr_supported_features = (LightEntityFeature.EFFECT) and now everything is working fine, even groups.

This worked for me as well. I have eight Tapo L630 lights in two separate groups. I can control each device and per group with this fix.

@LightJack05
Copy link

Works like a charm for my L530 lamps!

@algopt
Copy link

algopt commented Jan 6, 2025

For my particular case, since all my lights are 530E, I simply replaced lines 54-56 with self._attr_supported_features = (LightEntityFeature.EFFECT) and now everything is working fine, even groups.

This worked for me as well. I have eight Tapo L630 lights in two separate groups. I can control each device and per group with this fix.

Thank you, this made it simpler for me, opened my prompt, and found the light.py file, edited the mentioned line and voilá! 👍

@pgarciafc
Copy link

For my particular case, since all my lights are 530E, I simply replaced lines 54-56 with self._attr_supported_features = (LightEntityFeature.EFFECT) and now everything is working fine, even groups.

This worked for me as well. I have eight Tapo L630 lights in two separate groups. I can control each device and per group with this fix.

Thank you, this made it simpler for me, opened my prompt, and found the light.py file, edited the mentioned line and voilá! 👍

You are welcome but the solution provided by @djhworld through this Pull Request is probably the best one!

@Lockie85
Copy link

Lockie85 commented Jan 7, 2025

Sorry to ask, but any idea when a solution might be published? Appreciate the work that goes into this project.

@indomitorum
Copy link

HA 2025.1.1 and we are back to square one. Light entity not recognized.

@djhworld
Copy link
Author

djhworld commented Jan 7, 2025

It looks like they reverted the change around deprecating the constants

home-assistant/core#134927

@Av4K100
Copy link

Av4K100 commented Jan 7, 2025

Does this mean we should revert the changes made to light.py if wanting to upgrade to 2025.1.1

@djhworld
Copy link
Author

djhworld commented Jan 7, 2025

I've just updated to 2025.1.1 with the changes from this PR and my lights still work

Given the HA repo has had this change reverted I think we could just go back to returning 0 like before, but I suspect they might deprecate support for integers again in in the future so we'll have to support that

@djhworld
Copy link
Author

djhworld commented Jan 7, 2025

HA 2025.1.1 and we are back to square one. Light entity not recognized.

@indomitorum Do you see an exception in the logs? I just updated and things are still working.

Copy link

@aminhusni aminhusni left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@edgicat
Copy link

edgicat commented Jan 21, 2025

Just updated to 2025.1.3 and the problem is back...

Updated light py with:
self._attr_supported_features = (LightEntityFeature.EFFECT)

Seems to work again. Any idea when long term fix will be push out. I take it 3.1.5?

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

Successfully merging this pull request may close these issues.

Light entity is no longer provided by the tapo integration