Skip to main content

KEF Wireless Speakers smart home integration, free and open source

KEF Wireless Speakers integration for Gladys Assistant

KEF wireless speakers (LS50 Wireless II, LSX II, LS60), local: power, volume, source, playback.

Control your KEF wireless speakers (LS50 Wireless II, LSX II, LSX II LT, LS60) from Gladys, locally, without any cloud: power on, standby, volume, mute, source, play, pause, next, previous and the title playing.

Important. This integration has never been tested with a real speaker: it was written from the pykefcontrol library, and the KEF API it uses is not documented by KEF. It was tested against a fake speaker only. Your feedback is welcome. Unofficial integration, not affiliated with KEF. The XIO soundbar is not confirmed (pykefcontrol does not list it).

Setup​

  1. Give each speaker a fixed IP address in your router (reserved DHCP lease).
  2. In Gladys, install the KEF Wireless Speakers integration, then open its configuration.
  3. Type the IP addresses, separated by commas (for example 192.168.1.50, 192.168.1.51).
  4. Choose the volume cap (40 % by default) and the refresh interval (10 s by default, 5 to 300 s).
  5. The speakers appear in the Discovery tab: create them.

The integration reads each speaker over its HTTP API (http://<ip>/api/…, port 80) at the refresh interval. A change made on the speaker, its remote or the KEF Connect app shows in Gladys at the next read.

What you get​

FeatureGladys typeNote
Powerbinary state (read only)1 on, 0 in standby or not answering
Power onbuttonwakes the speaker up
Standbybuttonputs the speaker in standby; never waits, never blocked
Volumemusic / volume (0 to 100)capped
Mutebutton (television / mute)mutes (volume 0), or unmutes at most at the cap
Play, pausemusic buttonsthrough the play/pause toggle, only when it is needed
Next, previousmusic buttonsrefused in standby
Playbackmusic state (read only)1 playing, 0 otherwise
SourcedropdownWi-Fi, Bluetooth, TV, optical, coaxial, analog
Now playingtext (read only)"Artist - Title"; "—" when nothing plays or in standby

On purpose, no switch: an "everything off" or "everything on" from a voice assistant or a scene neither wakes nor cuts your speakers.

Volume cap​

The volume asked from Gladys (dashboard, scene, voice assistant) never goes above the cap of the configuration: a higher volume is set to the cap. The cap is read again just before sending: a new value saved applies at once. The volume set on the speaker itself (remote, app) is not changed, except when Gladys would make it heard:

  • Power on, or a source chosen while the speaker is in standby (it wakes it up): the volume is read after the wake-up and lowered to the cap when above it; the check is made again every 2.5 s for about 15 s, and a volume turned up above the cap during those 15 s is lowered too.
  • A lowering ignored: a volume sent and not read back (the speaker accepted it and ignored it) is "sent, without confirmation", and the same checks follow for about 15 s.
  • Unmute: the mute of this integration is a volume set to 0 (as pykefcontrol does); unmuting sets back the previous volume, at most the cap. A speaker muted by its own remote or app is left alone (the command is refused): unmute it there.

Commands​

Every command is answered within 4 seconds (Gladys waits 5 seconds).

  • Before each command, the MAC address of the speaker at the address is read again: when another speaker answers there (address changed), nothing is sent and the address is forgotten (type the new one in the configuration). An unreadable answer refuses the command, nothing sent, the address kept.
  • A command is confirmed only when the speaker gives back the value asked (power, volume, source, play state); otherwise it is reported "sent, without confirmation". A command that could not leave is reported "nothing sent", and a command still waiting at the end of its 4 seconds is dropped, never sent late.
  • Standby and Pause never wait behind another command. Standby cancels the commands still waiting that could wake the speaker (power on, source, play, next, previous); Pause cancels play, next and previous ("cancelled by Standby / Pause, nothing sent"). A Standby not confirmed (for example while the speaker is still waking up from a Power on) is asserted again for about 20 s whenever the speaker reads "on"; a Power on from Gladys ends it.
  • Play acts only when paused, Pause only when playing (the KEF API has a toggle only), one toggle at a time per speaker: two Pause presses, or a Pause right after a Play, end paused. Pause waits, within its 4 seconds, for a settled state (buffering ends); Play in another state is refused, nothing sent.
  • The order of the requests decides: a Power on asked after a Standby wins (the Standby is no longer asserted again), a Standby asked after a Power on wins. A Mute cancels the volumes asked before it and still waiting.

Reads​

  • A speaker is read every refresh interval, never sooner: neither the buttons, nor a Discovery scan, nor a reconnection to Gladys, nor a configuration saved again, nor a restart of the integration (the time of the last read is kept in /data) make it read sooner.
  • A speaker that does not answer twice in a row shows as off and is named in the integration status; it is then read at spaced intervals (doubled up to 5 minutes).

Configuration buttons​

  • Find the speakers: reads the addresses whose read is due, then publishes the Discovery list.
  • Check the speakers: the last read of each speaker (power, volume, source, how long ago) and the cap in force. It reads nothing.

Data and privacy​

The integration asks for no account and no password: the KEF API has none. It keeps in /data/kef.json the known speakers (MAC address, address, name, model, the volume replaced by a mute) and the time of the last read of each address. Nothing leaves your local network.

Known limits​

  • The KEF API is not documented: its answers may differ on a real speaker or after a firmware update.
  • No automatic search on the network yet: type the addresses.
  • No equalizer, presets, playlists, repeat or shuffle.
  • Never tested with a real device: no real KEF speaker was tried.

Configuration settings​

These are the settings KEF Wireless Speakers asks for in its configuration screen in Gladys.

SettingTypeRequiredDescription
Your KEF speakers, on your local networksectionNoPower on, standby, volume, mute, source, play, pause, next, previous and the title playing of each KEF wireless speaker (LS50 Wireless II, LSX II, LSX II LT, LS60; XIO not confirmed), through its local HTTP API, without any cloud. Give each speaker a fixed IP address in your router and type it below: the speakers then appear in the Discovery tab. The volume set from Gladys never goes above the cap below, also when a speaker wakes up or is unmuted. The KEF API is not documented: never tested with a real speaker. Unofficial integration, not affiliated with KEF.
IP addresses of the speakersstringNoSeparated by commas, for example 192.168.1.50, 192.168.1.51.
Volume cap (%)numberNoThe highest volume Gladys may set, from 1 to 100 % (100: no cap). A higher volume asked by a scene, a voice assistant or the dashboard is set to this cap; a speaker woken up or unmuted by Gladys is brought back under it. The volume set on the speaker itself (remote, app) is not changed.
Refresh interval (s)numberNoHow often each speaker is read, from 5 to 300 seconds. A speaker is never read sooner, whatever the buttons or a restart.

How to install KEF Wireless Speakers in Gladys​

  1. In Gladys, open Integrations: KEF Wireless Speakers appears in the catalog, next to the native integrations, with a community badge.
  2. Click Install. Gladys pulls the Docker image (ghcr.io/lm1lc3n7/gladys-kef:0.1.2), starts it in a sandbox isolated from the core, and generates the integration's interface (devices, discovery and configuration).
  3. Open the Configuration screen of the integration, fill in the settings, and save.
  4. You can also install it directly from its repository URL: https://github.com/LM1LC3N7/gladys-kef.

KEF Wireless Speakers requires Gladys >=5.1.0. The catalog inside Gladys refreshes every hour, so a new version becomes available at most one hour after its release.

Not running Gladys yet? It is free and open source: follow the installation guide to get started.

About external integrations​

KEF Wireless Speakers is an external integration: a community integration packaged as a Docker container and published on GitHub, that Gladys installs in one click and runs in a sandbox isolated from its core. It is published and maintained by LM1LC3N7, not by the Gladys core team.

Subscribe to the Gladys Assistant newsletter

A few emails per month about new releases and project news. Sent by Pierre-Gilles Leymarie, founder of the project. Unsubscribe anytime 🙂