Kef ls50 Wireless

@chimpy, this is is really interesting. I can only think that there is older and newer hardware that behaves differently. In your case though I would also check for newer firmware - see https://uk.kef.com/pages/product-support.

There is an October 2018 version available, yours seems to be older. Check in the app or here http:///index.asp.I have p6.2101809171.105039422 on mine.

I was checking if there is some mentioning of a HW version but couldn’t find anything on the outside. There is a label at the bottom but it doesn’t seem to indicate such a version.

As said above it isn’t 100% reliable for me either, from time to time the speakers seem to refuse to be switched on via LAN - then you have to manually (remote/keypad) turn them on.

Hi all,

I have created a custom_component for the KEF speakers (media_player.kef) based on the work of @chimpy, @Gronis, and bastianbeggel. I started with the existing pykef library but I have since rewritten 90% of it. I am currently rewriting the communication part to use asyncio, but the current version works fully.

Using the latest firmware, I am now able to turn on the speaker with any source selected.

Check out my repository here. You can also install the KEF integration from the HACS store.

Installing the integration amounts to copying the custom_components/kef folder into custom_components and adding this to your configuration.yaml:

media_player:
  - platform: kef
    host: 192.168.x.x  # the IP of your speaker
    name: MyAwesomeSpeaker  # optional, the name in Home Assistant
    maximum_volume: 0.5  # optional, to avoid extremely loud volumes
    volume_step: 0.05  # optional

I hope someone will find it useful! Please let me know if you experience any issues :slight_smile:

Hi @basnijholt

Good job! A port to asyncio and distribution via hacs is a perfect next step for this integration. Unfortunately I have sold off my KEF speakers so I won’t be able to test it out, but I’m glad you took your time investing in further development in this integration :slightly_smiling_face:

@Gronis , I have the KEF speakers API now fully implemented using asyncio!

I actually also simplified the byte sequences that are send.

Additionally, I figured out how to turn on the speaker to the previously used source.

It is similar to the way the speaker is muted, just add 128 to the source number and it will turn off.

The only thing I still want to find out is how to PLAY and PAUSE, because judging from the app, that should also be possible. You guys used Wireshark for this right?

Hi @basnijholt,

Great. Now I can retire my half-baked private modifications I did to @Gronis implementation.

Before doing so though - I have to get this working though. Right now it complains about “module tenacity not found”. I guess I would have to add this library to Python.

Is there a proper way to do this in hass.io such that it is sticky on updates ?

@basnijholt Sweeeeeet I am looking forward to testing this! Thank you!

I plugged in my iPhone via USB to log the packets, noted down the actions I made in the app, and then loaded up the dump in Wireshark afterwards. There is perhaps a more efficient way to do it :slight_smile:

Hi @mleiber, great to hear that you are using it! I will continue to improve the module.

About the dependencies, I am using hass.io too and I installed it with HACS, but that should be identical to installing it by moving the folder to the correct place.

Home Assistant should automatically detect the dependencies (specified in manifest.json and install them.

For me, initially, this didn’t seem to happen, but after a few restarts, it worked. This is probably a bug in HA and I am not sure how to solve it.

I’ll find out in case the restarting doesn’t do it.

I have used the integration for some time now, an it works very well so far.

Therefore, I have submitted a Pull Request to the main Home-Assistant library! :tada:

It would be great to get some feedback in that Pull Request.

Additionally, I have created the aiokef Python package that is on PyPI too.

1 Like

Hi @basnijholt, I have used your integration now for a while - seems to work flawlessly so far.

Great work, thank you so much for investing time into making these wonderful speakers available in the wonderful Home Assistant ;-).

Seems you keep adding stuff to it - great. Did you see the new firmware that was released a few days ago ? Seems to have brought a few good things especially towards WiFi stability and utility.

Hi @mleiber, I am glad that someone else finds it useful!

I have indeed also upgraded to the latest firmware and it works beautifully.

Additionally, I have also added configuration options to inverse the left and right channel and added standby options. It should also work with the LSX now.

It would be really great if you could leave a message at my Pull Request, telling that the integration works for you :slight_smile:

I just discovered this integration via HACS and installed it.

Unfortunately it is erroring out:

Platform error media_player.kef - No module named ‘aiokef’

I have HA running on a docker container so I’m limited RE module additions etc. Is there any way to get this integration to run on a docker install or the only option is to wait until it gets accepted into HA?

Another note - regarding the ability to turn on the speakers via API, see the release note that came with the Nov19’19 firmware release (very recent)

Support wake-up speaker by KEF Control app, Spotify Connect and DLNA (only applicable for speaker serial number after LS50W13074K24L/R2G)

My ls50w are running the latest fw and the App seems unable to wake them up over wifi. I’m guessing my pair is too old for this (2.5 years old or so)

Hi @ariel,

I’m happy you are trying it out! That the package doesn’t automatically install is a bug of Home Assistant. Restarting HA a few times should eventually make it install aiokef.

I am not sure whether that feature of the new firmware will work for you. But luckily, now that there is a HA integration, you don’t need it. You should still be able to turn it on from standby and then switch source.

Let me know if restarting does the trick and if so, please leave a message at my Pull Request. In that way the core developers will know that it works :smile:

In the same situation haha, installed HACS and now waiting for the Kef integration to show up :slight_smile:

@basnijholt Hey man, thanks for the component! I have an LS50 on the latest firmware, but serial number less than LS50W13074K24L/R2G.

The component manages it perfectly whilst it is on, but is unable to wake it from sleep (expected, as the FW release notes say). Nevermind! I will have to continue starting it up with IR.

Thanks again for the effort :slight_smile:

@basnijholt I upgraded to 104.1 today.

The component works, but it has a strange behavior after hitting “power off” in the media control card. My LS50W hardware is the older one that cannot be powered up via wifi / app.

What happens is: after using HA to power off the KEFs, if I manually power the speakers on, and then open the “Details” view of the LS50W in lovelace, then HA powers off the speakers immediately, without me pressing the power icon, it’s very strange. It’s like HA thinks the power should be off, and keeps sending the speakers the command to shutdown. If I power on manually, HA will power the speakers off by itself again after I open the KEF media player details view.

Is there a way to prevent this? maybe via an optional parameter to disable power on/off integration for those people with the older hardware model that’s different from yours.

@basnijholt another issue I notice, that could be related to the above, is that if I manually turn off the speaker, HA doesn’t notice anthing (still shows it as ON) for a few minutes, and then when it finally notices the change, it shows “Unavailable” instead of Off

image

For comparison, my denon receiver shows “off” when it’s off:

image

Hi @ariel, I’ve opened this Pull Request. I hope that satisfies your needs. Unfortunately, I can’t test it.

I’ve also updated the custom_component, could you try https://github.com/basnijholt/media_player.kef ?

@basnijholt thanks for the fast response! I tried installing the custom component with HACS and HA inside the container instance no longer comes up. I am (was? :slight_smile: running 104.1 which already included Kef support and I thought HACS newer version would override it.

Do you know if anything can be done to tell HA to use the custom module to override the built-in kef integration? So I can test it.

Also do I need to add anything to my kef configuration, I
E. Do I need

supports_on_off = false

Note that the old version I have supports off. It only lacks support for On.

@basnijholt I could manage to remove the HACS custom KEF module and got HA to start clean again. Then I tried to find the changed KEF code in your various GitHub repos to manually edit the python files inside my HA container - I am familiar with this but I got confused with so many git repos and branches related to KEF within your GitHub account.

I am running HA 104.1. If you could post here links to the Python raw files with the latest code in your GitHub repo that need to be used for 104.1, I can manually get that code inside my HA container replacing their current version, and then restart the container and test. I know this is not the ideal way to test but this is something I have done before and can manage. I believe it’s only 3 files that I will need to edit (aiokef.py, and two for your module inside the HA code tree)

The easiest is probably downloading it with HACS.
Then if you just rename the custom_components/kef -> custom_components/kef_custom and in your configuration

media_player:
  - platform: kef_custom  #<---- new name
    type: LS50
    name: KEF
    host: 192.168.1.5

Sorry if it is a lot of hassle! I had to go through it as well :stuck_out_tongue_winking_eye: