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

Integration will not add any "Light" entities during setup #12

Open
irish-david opened this issue Feb 24, 2021 · 5 comments
Open

Integration will not add any "Light" entities during setup #12

irish-david opened this issue Feb 24, 2021 · 5 comments

Comments

@irish-david
Copy link

LEDFxRm 0.2.6 (Running on RPi4 2Gb, Hassio 2021.2.3, Home Assistant OS 5.12, Frontend version: 20210127.7 - latest)
LEDFx 0.10.0 (Running on a RPi4 2Gb, Rasperry Pi OS Lite, Python 3.7.3)

Describe the bug

After the integration is added only the binary and sensor entities are added (4 in total) and there are no entities for the lights or switches so LEDFx cannot be controlled from Home assistant.

Debug log

After the integration is configured the following is in the log for LEDFxRm:

Logger: homeassistant.config_entries
Source: loader.py:480
First occurred: 3:13:58 PM (1 occurrences)
Last logged: 3:13:58 PM

Error setting up entry LedFx Controller for light
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 239, in async_setup
result = await component.async_setup_entry(hass, self) # type: ignore
File "/usr/src/homeassistant/homeassistant/components/light/init.py", line 268, in async_setup_entry
return await hass.data[DOMAIN].async_setup_entry(entry)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 140, in async_setup_entry
platform = await async_prepare_setup_platform(
File "/usr/src/homeassistant/homeassistant/setup.py", line 298, in async_prepare_setup_platform
platform = integration.get_platform(domain)
File "/usr/src/homeassistant/homeassistant/loader.py", line 475, in get_platform
cache[full_name] = self._import_platform(platform_name)
File "/usr/src/homeassistant/homeassistant/loader.py", line 480, in _import_platform
return importlib.import_module(f"{self.pkg_path}.{platform_name}")
File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1014, in _gcd_import
File "", line 991, in _find_and_load
File "", line 975, in _find_and_load_unlocked
File "", line 671, in _load_unlocked
File "", line 779, in exec_module
File "", line 916, in get_code
File "", line 846, in source_to_code
File "", line 219, in _call_with_frames_removed
File "/config/custom_components/ledfxrm/light.py", line 185
if self.deviceconfig.has_key("icon_name")
^
SyntaxError: invalid syntax


@Codename-11
Copy link

I'm having the same issue :(

@irish-david
Copy link
Author

Looks like the issue is around the light.py file that lives in the custom components folder that defines the properties of the light entity when it's created by the integration. It appears that in one of the recent home assistant updates that was meant to secure how it interfaces with customs components the syntax for defining the icon of the entity has changed and this has broken the LEDFxrm integration.

When integration is defining the light entity it looks like it's looking to see if an icon has already been used for the lights strips and, if it has, it uses the custom icon that's been used in the light strips and if not then it uses a normal home assistant "scene" icon.

I've found a workaround that involves deleting the routine that looks for this custom icon and just using the default icon. The icon can still be changed after the entity is created in home assistant so it shouldn't have any permanent affects. The first thing you need to do is open the light.py file located at /config/custom_components/ledfxrm/light.py in a text editor. Scroll down to around line 180 and you'll see the following block of text:

@property
def icon(self):
    """Return the icon of this light."""
    if self.deviceconfig.has_key("icon_name")
        if self.deviceconfig["icon_name"].startswith("mdi:"):
            return self.deviceconfig["icon_name"]
        else:
            return ICON_STRIP_DEVICE
    else:
        return ICON_STRIP_DEVICE

Edit that block so it reads:

@property
def icon(self):
    """Return the icon of this light."""
    return ICON_STRIP_DEVICE

Then save the file, delete the integration and restart home assistant. When it's running again then re-install the integration and it should create a light entity which can be added to your dashboard.

I've haven't fully tested this yet so it might be a good idea to make a backup of the light.py file before you edit it.

Good luck

@BornTKill
Copy link

BornTKill commented Mar 13, 2021

Dear,

i tried process describe by @irish-david but still have the issue.

any idea ?

@BornTKill
Copy link

Ok fix with this PR

d4a3997

@PrathikGopal
Copy link

Same Here, nothing but the below.

Screenshot 2021-05-09 at 8 25 57 PM

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

4 participants