Skip to main content

A python implementation to interface Kef speakers over tcp/ip

Project description

Python interface to control KEF speakers

Supported: KEF LS50 Wireless (Requires firmware June 2018 or later)

Untested: KEF LSX

Features supported

  • Get and set volume
  • Mute and Unmute
  • Get and set source input
  • Get if the speakers are online
  • Automatically connects and disconnects when speakers goes online/offline
  • Turn off speaker

Features unfortunatly unsupported

  • Turn on is impossible over tcp/ip because the speaker turns off network interface when turned off. This is true for LS50 Wireless. LSX should be possible to turn on.

Note: One workaround to turning on is to use IR commands to turn on. I have included a lirc config with all the keys on the remote. Note that each command has to be sent twice to work (at least for me).


pip install pykef


See home assistant thread



host = ''
port = 50001
speaker = KefSpeaker(host, port)

Set volume:

speaker.volume = 0.5 # %50 vol

Get volume:

volume = speaker.volume

Set source:

speaker.source = InputSource.AUX

Get source:

source = speaker.source


speaker.volume = None
# Or
speaker.muted = True

Unmute (set to volume before mute):

speaker.muted = False

Step volume up

speaker.increseVolume() # 5% increase
speaker.increseVolume(0.10) # 10% increase

Step volume down

speaker.decreaseVolume() # 5% increase
speaker.decreaseVolume(0.10) # 10% increase

Turn off


How to

Upload new release:

  1. Update needed tools:
python3 -m pip install --user --upgrade setuptools wheel
  1. Build
python3 sdist bdist_wheel
  1. Upload (test)
twine upload --repository-url dist/*


MIT License


  • Robin Grönberg

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pykef, version 1.3.0
Filename, size File type Python version Upload date Hashes
Filename, size pykef-1.3.0.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View
Filename, size pykef-1.3.0-py3-none-any.whl (6.3 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page