aiokef.aiokef module

A module for asynchronously interacting with KEF wireless speakers.

class aiokef.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[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]
async get_mode() Union[Mode, str][source]
async get_play_pause() str[source]
async get_source() None[source]
async get_state() 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.

async 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]
async next_track() None[source]
async 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.

async set_play_pause() None[source]
async 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.aiokef.Mode(desk_mode, wall_mode, phase_correction, high_pass, sub_polarity, bass_extension)

Bases: tuple

property bass_extension

Alias for field number 5

property desk_mode

Alias for field number 0

property high_pass

Alias for field number 3

property phase_correction

Alias for field number 2

property sub_polarity

Alias for field number 4

property wall_mode

Alias for field number 1

class aiokef.aiokef.State(source, is_on, standby_time, orientation)

Bases: tuple

property is_on

Alias for field number 1

property orientation

Alias for field number 3

property source

Alias for field number 0

property standby_time

Alias for field number 2

class aiokef.aiokef.SyncKefSpeaker(async_speaker: 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.

aiokef.aiokef.arange(start, end, step)[source]
aiokef.aiokef.bits_to_mode(bits: int) Mode[source]
aiokef.aiokef.mode_to_bits(mode: Mode) int[source]