aiokef package

A module for asynchronously interacting with KEF wireless speakers.

class aiokef.AsyncKefSpeaker(host: str, port: int = 50001, volume_step: float = 0.05, maximum_volume: float = 1.0, standby_time: Optional[int] = None, inverse_speaker_mode: bool = False, *, loop: Optional[asyncio.events.AbstractEventLoop] = None)[source]

Bases: object

Asynchronous KEF speaker class.

Parameters
  • host (str) – The IP of the speaker.

  • port (int, optional) – The port used for the communication, the default is 50001.

  • volume_step (float, optional) – The volume change when calling increase_volume or decrease_volume, by default 0.05.

  • maximum_volume (float, optional) – The maximum allow volume, between 0 and 1. Use this to avoid accidentally setting very high volumes, by default 1.0.

  • loop (asyncio.BaseEventLoop, optional) – The eventloop to use.

  • standby_time (int, optional) – Put the speaker in standby when inactive for standby_time minutes. The only options are None (default), 20, and 60.

  • inverse_speaker_mode (bool, optional) – Reverse L/R to R/L.

sync

Run any method that the AsyncKefSpeaker has in a synchronous way. For example kef_speaker.sync.mute().

Type

aiokef.SyncKefSpeaker

async decrease_volume() → float[source]

Decrease volume by self.volume_step.

async get_desk_db() → int[source]
async get_high_hz() → int[source]
async get_low_hz() → int[source]
get_mode() → Union[aiokef.aiokef.Mode, str][source]
get_play_pause() → str[source]
async get_source() → None[source]
get_state()aiokef.aiokef.State[source]
async get_sub_db() → int[source]
async get_treble_db() → int[source]
async get_volume() → Optional[float][source]

Volume level of the media player (0..1). None if muted.

get_volume_and_is_muted(scale=True) → Tuple[Union[float, int], bool][source]

Return volume level (0..1) and is_muted (in a single call).

async get_wall_db() → int[source]
async increase_volume() → float[source]

Increase volume by self.volume_step.

async is_muted() → bool[source]
async is_on() → bool[source]
async is_online() → bool[source]
async mute() → None[source]
next_track() → None[source]
prev_track() → None[source]
async set_desk_db(db) → None[source]
async set_high_hz(hz) → None[source]
async set_low_hz(hz) → None[source]
async set_mode(desk_mode=None, wall_mode=None, phase_correction=None, high_pass=None, sub_polarity=None, bass_extension=None) → None[source]

Set the mode of the speaker.

Leave option None to keep the setting the same.

set_play_pause() → None[source]
set_source(source: str, *, state='on') → None[source]
async set_sub_db(db) → None[source]
async set_treble_db(db) → None[source]
async set_volume(value: float) → float[source]
async set_wall_db(db) → None[source]
async turn_off() → None[source]
async turn_on(source: Optional[str] = None) → None[source]

The speaker can be turned on by selecting an INPUT_SOURCE.

async unmute() → None[source]
class aiokef.SyncKefSpeaker(async_speaker: aiokef.aiokef.AsyncKefSpeaker)[source]

Bases: object

A synchronous KEF speaker class.

This has the same methods as aiokef.AsyncKefSpeaker, however, it wraps all async methods and call them in a blocking way.