An async python library for controlling HEOS devices through the HEOS CLI Protocol (version 1.17 for players with firmware 2.41.140 or newer).
pip install pyheos
or
pip install --use-wheel pyheos
The Heos
class is the implementation providing control to all HEOS compatible devices on the local network through a single network connection. It is suggested to connect to a device that is hard-wired.
Coroutine that accepts the host and options arguments (as defined in the pyheos.HeosOptions
below), creates an instance of Heos
and connects, returning the instance.
options: HeosOptions
: An instance of HeosOptions that encapsulates options and configuration (see below)
Connect to the specified host. This method is a coroutine.
Disconnect from the specified host. This method is a coroutine.
Retrieve the available players as a dict[int, pyheos.Heos.HeosPlayer]
where the key represents the player_id
and the value the HeosPlayer
instance. This method is a coroutine. This method will populate the players
property and will begin tracking changes to the players.
refresh
: Set toTrue
to retrieve the latest available players from the CLI. The default isFalse
and will return the previous loaded players.
This class encapsulates the options and configuration for connecting to a HEOS system.
pyheos.HeosOptions(host, *, timeout, heart_beat, heart_beat_interval, dispatcher, auto_reconnect, auto_reconnect_delay, auto_reconnect_max_attempts, credentials)
host: str
: A host name or IP address of a HEOS-capable device. This parameter is required.timeout: float
: The timeout in seconds for opening a connectoin and issuing commands to the device. Default ispyheos.const.DEFAULT_TIMEOUT = 10.0
. This parameter is required.heart_beat: bool
: Set toTrue
to enable heart beat messages,False
to disable. Used in conjunction withheart_beat_delay
. The default isTrue
.heart_beat_interval: float
: The interval in seconds between heart beat messages. Used in conjunction withheart_beat
. Default ispyheos.const.DEFAULT_HEART_BEAT = 10.0
events: bool
: Set toTrue
to enable event updates,False
to disable. The default isTrue
.all_progress_events: bool
: Set toTrue
to receive media progress events,False
to only receive media changed events. The default isTrue
.dispatcher: pyheos.Dispatcher | None
: The dispatcher instance to use for event callbacks. If not provided, an internally created instance will be used.auto_reconnect: bool
: Set toTrue
to automatically reconnect if the connection is lost. The default isFalse
. Used in conjunction withauto_reconnect_delay
.auto_reconnect_delay: float
: The number of seconds to wait before attempting to reconnect upon a connection failure. The default isDEFAULT_RECONNECT_DELAY = 10.0
. Used in conjunction withauto_reconnect
.auto_reconnect_max_attempts: float
: The maximum number of reconnection attempts before giving up. Set to0
for unlimited attempts. The default is0
(unlimited).credentials
: credentials to use to automatically sign-in to the HEOS account upon successful connection. If not provided, the account will not be signed in.
import pyheos
heos = await Heos.create_and_connect('172.16.0.1', auto_reconnect=True)
players = await heos.get_players()
...
await heos.disconnect()