Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.
/ pykef Public archive

A python implementation to interface Kef speakers over tcp/ip

License

Notifications You must be signed in to change notification settings

Gronis/pykef

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python interface to control KEF speakers

Unmaintained

Since I recently sold of my KEF LS50 Wireless speakers, I will no longer maintain this repository. I suggest that you check out aiokef which is a newer implementation which supports asyncio while also being more feature rich.

Supported devices:

  • KEF LS50 Wireless (Requires firmware June 2018 or later)
  • 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
  • Turn on (KEF LSX only)

Features unfortunatly unsupported

  • Turn on is impossible over tcp/ip (KEF LS50 Wireless) 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:

from pykef import KefSpeaker, InputSource
host = '192.168.1.200'
port = 50001
speaker = KefSpeaker(host, port)
speaker.source = InputSource.Bluetooth

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