jfarmer08 / ha-sengledapi

Home Assistant Integration for Sengled Bulbs. This is a custom component to allow control of Sengled Bulbs in Homeassistant using the unofficial Sengled API. Please note this mimics the Sengled app and therefore Sengled may cut off access at anytime.
Apache License 2.0
104 stars 34 forks source link

[Bug] Lights fail to load in the latest code #81

Open ryanwaldron opened 1 year ago

ryanwaldron commented 1 year ago

Describe the bug Lights fail to load with latest code.

To Reproduce Steps to reproduce the behavior: Install HA Manually install SengledApi Restart HA

Expected behavior Lights to show up in the UI

System configuration Home Assistant 2022.11.4 Frontend 20221108.0 - latest SengledApi Version: Latest Master

configuration.yaml

sengledapi:
  username: ********@gmail.com
  password: ***************
  country: us
  wifi: true

home-assistant.log

Logger: homeassistant.components.light
Source: custom_components/sengledapi/light.py:160
Integration: Light ([documentation](https://www.home-assistant.io/integrations/light), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+light%22))
First occurred: 9:17:23 AM (2 occurrences)
Last logged: 9:17:23 AM

Error adding entities for domain light with platform sengledapi
Error while setting up sengledapi platform for light
Traceback (most recent call last):
  File "/usr/local/share/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity_platform.py", line 428, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/local/share/homeassistant/lib/python3.10/site-packages/homeassistant/helpers/entity_platform.py", line 605, in _async_add_entity
    capabilities=entity.capability_attributes,
  File "/usr/local/share/homeassistant/lib/python3.10/site-packages/homeassistant/components/light/__init__.py", line 910, in capability_attributes
    supported_features = self.supported_features
  File "/home/homeassistant/homeassistant/custom_components/sengledapi/light.py", line 160, in supported_features
    features = ColorMode.BRIGHTNESS | ColorMode.COLOR_TEMP
TypeError: unsupported operand type(s) for |: 'ColorMode' and 'ColorMode'
HaydenAlbrey commented 1 year ago

I faced this issue today when trying to set up this integration. However I believe I have the solution.

The line referenced in the error File ".../light.py", line 160 is different in the version that is installed through HACS and that installed via direct download. The version on HACS does not have this bug. Try installing it though HACS and see if the issue goes away.