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

The component does not load in HASS v0.115.3 #3

Closed
eugenet8k opened this issue Sep 30, 2020 · 5 comments
Closed

The component does not load in HASS v0.115.3 #3

eugenet8k opened this issue Sep 30, 2020 · 5 comments

Comments

@eugenet8k
Copy link

I put the component into custome_components and configured the media-player entries, but upon HASS restart it gives me this error in logs:

 Sep 30 12:05:06 raspberrypi hass[29538]:     return _bootstrap._gcd_import(name[level:], package, level)
Sep 30 12:05:06 raspberrypi hass[29538]:   File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
Sep 30 12:05:06 raspberrypi hass[29538]:   File "<frozen importlib._bootstrap>", line 983, in _find_and_load
Sep 30 12:05:06 raspberrypi hass[29538]:   File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
Sep 30 12:05:06 raspberrypi hass[29538]:   File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
Sep 30 12:05:06 raspberrypi hass[29538]:   File "<frozen importlib._bootstrap_external>", line 728, in exec_module
Sep 30 12:05:06 raspberrypi hass[29538]:   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
Sep 30 12:05:06 raspberrypi hass[29538]:   File "/home/pi/.homeassistant/custom_components/kef/media_player.py", line 10, in <module>
Sep 30 12:05:06 raspberrypi hass[29538]:     from custom_components.kef_custom.aiokef import (
Sep 30 12:05:06 raspberrypi hass[29538]: ModuleNotFoundError: No module named 'custom_components.kef_custom'
@eugenet8k
Copy link
Author

eugenet8k commented Sep 30, 2020

I found the following solution:

  1. Install aiokef directly into OS where HomeAssistant is running, because some dependencies are missing:
> pip3 install aiokef
  1. update media_player.py from this repo.

Replace

from custom_components.kef_custom.aiokef import (
    AsyncKefSpeaker,
    DSP_OPTION_MAPPING,
)

with

from aiokef import AsyncKefSpeaker

def arange(start, end, step):
    return [x * step for x in range(int(start / step), int(end / step) + 1)]

# DSP options
_DESK_WALL_DB_OPTIONS = arange(-6, 0, 0.5)
_TREBLE_DB_OPTIONS = arange(-2, 2, 0.5)
_HIGH_HZ_OPTIONS = arange(50, 120, 5)
_LOW_HZ_OPTIONS = arange(40, 250, 5)
_SUB_DB_OPTIONS = arange(-10, 10, 1)

DSP_OPTION_MAPPING = {
    "desk_db": _DESK_WALL_DB_OPTIONS,
    "wall_db": _DESK_WALL_DB_OPTIONS,
    "treble_db": _TREBLE_DB_OPTIONS,
    "high_hz": _HIGH_HZ_OPTIONS,
    "low_hz": _LOW_HZ_OPTIONS,
    "sub_db": _SUB_DB_OPTIONS,
}

And also, replace MediaPlayerDevice with MediaPlayerEntity, to avoid HASS warning of deprecation.

And also, replace ioloop into loop all over the file

    media_player = KefMediaPlayer(
        name,
        host,
        port,
        maximum_volume,
        volume_step,
        standby_time,
        inverse_speaker_mode,
        supports_on,
        sources,
        loop=hass.loop,
        unique_id=unique_id,
    )

That made it start with HASS, and I am able to control my KEF LSX. I guess I might just do a fork of this repo.

@basnijholt
Copy link
Owner

Check out https://www.home-assistant.io/integrations/kef/

@eugenet8k
Copy link
Author

@basnijholt oh, what the hell! I was searching for one and couldn't find anything... Truly blind I was! I guess it's not in the Integrations catalog yet.

@eugenet8k
Copy link
Author

@basnijholt maybe, if that makes sense, it would be reasonable to have some top-level comment in this repo README.md. That this is a deprecated repo and we should just use the official HASS component. Thanks for pointing it out!

@basnijholt
Copy link
Owner

fbff670

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