Zum Hauptinhalt springen

KEF Wireless Speakers Smart-Home-Integration, kostenlos und Open Source

KEF Wireless Speakers-Integration für Gladys Assistant

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

Info

Die Dokumentation dieser Integration wird von ihrem Autor geschrieben und ist bisher nur auf Englisch verfügbar.

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.

Konfigurationseinstellungen​

Diese Einstellungen fragt KEF Wireless Speakers in seinem Konfigurationsbildschirm in Gladys ab.

EinstellungTypPflichtfeldBeschreibung
Your KEF speakers, on your local networksectionNeinPower 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 speakersstringNeinSeparated by commas, for example 192.168.1.50, 192.168.1.51.
Volume cap (%)numberNeinThe 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)numberNeinHow often each speaker is read, from 5 to 300 seconds. A speaker is never read sooner, whatever the buttons or a restart.

So installierst du KEF Wireless Speakers in Gladys​

  1. Öffne in Gladys Integrationen: KEF Wireless Speakers erscheint im Katalog neben den nativen Integrationen, mit einem Community-Badge.
  2. Klicke auf Installieren. Gladys lädt das Docker-Image (ghcr.io/lm1lc3n7/gladys-kef:0.1.2) herunter, startet es in einer vom Kern isolierten Sandbox und erzeugt die Oberfläche der Integration (Geräte, Erkennung und Konfiguration).
  3. Öffne den Bildschirm Konfiguration der Integration, fülle die Einstellungen aus und speichere.
  4. Du kannst sie auch direkt über die URL ihres Repositorys installieren: https://github.com/LM1LC3N7/gladys-kef.

KEF Wireless Speakers benötigt Gladys >=5.1.0. Der Katalog in Gladys wird stündlich aktualisiert, eine neue Version ist also spätestens eine Stunde nach ihrer Veröffentlichung verfügbar.

Du nutzt Gladys noch nicht? Es ist kostenlos und Open Source: folge der Installationsanleitung, um loszulegen.

Über externe Integrationen​

KEF Wireless Speakers ist eine externe Integration: eine Community-Integration, die als Docker-Container verpackt und auf GitHub veröffentlicht wird. Gladys installiert sie mit einem Klick und führt sie in einer vom Kern isolierten Sandbox aus. Sie wird von LM1LC3N7 veröffentlicht und gepflegt, nicht vom Gladys-Kernteam.

Abonniere den Newsletter von Gladys Assistant

Ein paar E-Mails im Monat zu neuen Releases und Neuigkeiten aus dem Projekt. Verschickt von Pierre-Gilles Leymarie, dem Gründer des Projekts. Jederzeit abbestellbar 🙂