Python library to control KEF wireless speakers (W2 platform) over the local network.
It provides an asyncio client and a blocking client with the same API, and covers power, sources,
volume, playback, EQ/DSP settings, speaker settings and live updates pushed by the speaker.
Version 1.0 is a full rewrite with breaking changes: upgrading from 0.9? See the migration guide. It has been validated on an LS50 Wireless II (firmware 4.1.192); reports for other models are welcome.
LS50 Wireless II, LS60 Wireless, LSX II, LSX II LT, XIO and LS LUXE. Other W2-platform speakers should work in a generic mode.
Not supported: Coda W and Muo (Bluetooth only), first generation LS50 Wireless and LSX (see aiokef).
pip install pykefcontrol
pip install "pykefcontrol[discovery]" # with network discovery (mDNS)Requires Python 3.12 or newer.
from pykefcontrol import KefClient
with KefClient("192.168.1.20") as speaker:
speaker.power_on()
speaker.set_volume(30)
print(speaker.get_player_state().track)from pykefcontrol import KefAsyncClient
async def main():
async with KefAsyncClient("192.168.1.20") as speaker:
await speaker.set_volume(30)
async for state in speaker.watch(): # pushed by the speaker on every change
print(state)A command line tool is included: pykefcontrol --help.
- Power, source selection, volume and mute
- Playback control, track information, shuffle and repeat
- Full EQ / DSP profile (desk and wall modes, treble, bass extension, subwoofer settings...)
- Typed catalogue of speaker settings (standby, LEDs, remote, volume limits...)
- Live updates through the speaker's event queue, with automatic reconnection
- HTTPS API of recent firmware (signed requests, KEF certificate) with fallback to HTTP
- Model and firmware capabilities, device and network information
- Speaker discovery (mDNS) and raw access to the speaker's API
- Documentation: complete guide and reference
- Migration guide: upgrading from 0.9
- Changelog
For Home Assistant, see hass-kef-connector.
uv sync
uv run pytest
uv run ruff check . && uv run mypyThe blocking client (pykefcontrol/_sync/) is generated from the async one (pykefcontrol/_async/) by
scripts/gen_sync.py; edit the async code and regenerate.
MIT. pykefcontrol is an independent project and is not affiliated with KEF.