pytheos Package¶
pytheos
Module¶
Provides the primary interface into the library
-
class
pytheos.pytheos.
Pytheos
(server: Optional[Union[str, pytheos.networking.types.SSDPResponse]] = None, port: Optional[int] = 1255)¶ Bases:
object
Pytheos interface
-
DEFAULT_PORT
= 1255¶
-
static
check_channel_availability
(channel: pytheos.networking.connection.Connection)¶ Checks to make sure that the provided channel is available.
- Parameters
channel – Channel connection
- Raises
ChannelUnavailableError
- Returns
None
-
property
log_level
¶
-
property
connected
¶
-
property
signed_in
¶
-
property
username
¶
-
async
connect
(enable_event_connection: bool = True, refresh: bool = True) → pytheos.pytheos.Pytheos¶ Connect to our HEOS device.
- Parameters
enable_event_connection – Enables establishing an additional connection for system events
refresh – Determines if the system state should be automatically refreshed
- Returns
self
-
close
()¶ Close the connection to our HEOS device
- Returns
None
-
subscribe
(event_name: str, callback: Callable)¶ Subscribe a callback function to a specific event
- Parameters
event_name – Event name
callback – Callback function
- Returns
None
-
async
refresh
()¶ Refreshes internal information from the HEOS system.
- Returns
None
-
async
reboot
()¶ Instructs the system to reboot.
- Returns
None
-
async
check_account
() → tuple¶ Checks if the system is logged into HEOS and returns the status and account name, if available.
- Returns
tuple
-
async
sign_in
(username: str, password: str)¶ Signs the system into the HEOS service.
- Parameters
username – Username
password – Password
- Returns
None
-
async
sign_out
()¶ Signs out from the HEOS service.
- Returns
None
-
async
get_players
()¶ Retrieves a mapping of IDs to Players present in the HEOS system.
- Returns
dict
-
async
get_group
(group_id)¶ Retrieve a specific group by ID.
- Parameters
group_id – Group ID
- Returns
PytheosGroup
-
async
get_groups
()¶ Retrieves a mapping of IDs to Groups present in the HEOS system.
- Returns
dict
-
async
get_sources
()¶ Retrieves a mapping of IDs to Sources present in the HEOS system.
- Returns
-
is_receiving_events
()¶ Retrieves whether or not we’re receiving events.
- Returns
bool
-
async
enable_event_reception
(value)¶ Enables or disables event reception.
- Parameters
value – True or False
- Returns
None
-
-
async
pytheos.pytheos.
connect
(host: Union[pytheos.networking.types.SSDPResponse, str], port: int = 1255) → pytheos.pytheos.Pytheos¶ Connect to the provided host and return a context manager for use with the connection.
- Parameters
host – Host to connect to
port – Port to connect to
- Raises
ValueError
- Returns
The Pytheos instance
pytheos.errors
Module¶
Errors generated by Pytheos
-
exception
pytheos.errors.
PytheosError
¶ Bases:
Exception
Base Pytheos error class
pytheos.utils
Module¶
General utility functions
-
pytheos.utils.
extract_host
(url: str) → Optional[str]¶ Extracts the hostname or IP address from the supplied URL.
- Parameters
url – URL string
- Returns
Matching string or None if not found
-
pytheos.utils.
build_command_string
(group: str, command: str, **kwargs) → str¶ Builds the command string to send to the HEOS service.
- Parameters
group – Group name (e.g. system, player, etc)
command – Command name (e.g. heart_beat)
kwargs – Any parameters that should be sent along with the command
- Returns
The command string
-
pytheos.utils.
parse_var_string
(input_string: str) → dict¶ Parses a URL parameter string (sorta) like “var1=’val1’&var2=’val2’” - also supports the special case where there is no value specified, such as “signed_in&un=username”, for the player/signed_in command.
- Parameters
input_string – Input string to parse
- Returns
dict
-
pytheos.utils.
get_default_ip
(address_family: socket.AddressFamily) → str¶ Retrieves the IP address on the default interface
- Parameters
address_family – Address family
- Returns
str
-
pytheos.utils.
get_interface_ip
(interface: str, address_family: socket.AddressFamily) → Optional[str]¶ Retrieves the IP address of the specified interface.
- Parameters
interface – Interface name
address_family – Address family
- Returns
str or None if not found
-
pytheos.utils.
get_default_interface
(address_family: socket.AddressFamily) → tuple¶ Retrieves the default gateway and interface for the specified address family.
- Parameters
address_family – Address family
- Returns
tuple