Skip to main content

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).

Install

pip install pykef

Discussion

See home assistant thread

Examples

Setup:

host = '192.168.1.200'
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

Mute:

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

speaker.turnOff()

How to

Upload new release:

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

License

MIT License

Authors

  • Robin Grönberg

Release files for pykef 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pykef 1.3.0
File Size Uploaded
pykef-1.3.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pykef 1.3.0
File Interpreter ABI Platform
pykef-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.7 kB

Release files / pykef-1.3.0.tar.gz

Download URL pykef-1.3.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9d592f39035c42b247da29be037b27f3c8fc4bd92efd2b95ebcd5df83357aa47
BLAKE2b-256 checksum
How to use checksums
4e03d15c559b485594a57c3af2b24114d098d22c78b2eec1937b2901fe761348
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / pykef-1.3.0-py3-none-any.whl

Download URL pykef-1.3.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1989116b500ec40ab39098e9604835fe50eb629cf032d6a9f332fc652d3f4031
BLAKE2b-256 checksum
How to use checksums
8aa2df6eb56d204545c9ee5c4c6993dd9731c996196cdc0b92ec5bc5286bfad2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page