Crate heos

Crate heos 

Source
Expand description

Rust bindings for the HEOS control protocol.

The published specifications for the latest version of the CLI (1.17 at time of writing) can be found here: https://rn.dmglobal.com/usmodel/HEOS_CLI_ProtocolSpecification-Version-1.17.pdf

If that links gets stale and no longer works, a newer version may be able to be found on the Denon support website, here: https://support.denon.com/app/answers/detail/a_id/6953/~/heos-control-protocol-%28cli%29

§Getting a Connection

A HEOS system on the local network can be found via SSDP discovery. The following initiates SSDP discovery and yields an asynchronous stream of possible HEOS connection endpoints as they’re discovered:

use heos::HeosConnection;
use std::time::Duration;

let endpoints = HeosConnection::scan(Duration::from_secs(10)).await?;

Once endpoints have been discovered, any of them can be chosen to be used as the connection. The HEOS CLI uses a distributed system where a connection to any HEOS device can control all HEOS devices on the same network.

use heos::{ConnectError, HeosConnection};
use std::time::Duration;
use tokio_stream::StreamExt;

let mut endpoints = HeosConnection::scan(Duration::from_secs(10)).await?;
let connection = endpoints.next().await
    .ok_or(ConnectError::NoDevicesFound)?
    .connect().await?;

Or, to do all of the above in one method:

use heos::HeosConnection;
use std::time::Duration;

let connection = HeosConnection::connect_any(Duration::from_secs(10)).await?;

§Stateful Connections

The HEOS system supports sending change events whenever any part of the internal state changes. Using these, we can maintain a stateful representation of the system without needing to re-query all the time.

A stateful connection can be initiated like so:

use heos::HeosConnection;
use std::time::Duration;

let connection = HeosConnection::connect_any(Duration::from_secs(10)).await?;
let stateful = connection.init_stateful().await?;

Modules§

channel
Command/response channels.
command
Commands that can be sent to HEOS devices.
data
Compound data types used or returned by HEOS commands.
mock
Mock HEOS system for testing purposes.
state
Stateful management of a connected HEOS system.

Structs§

AdHoc
Inner state for a HeosConnection object that is actively connected to a HEOS endpoint, but does not manage any state.
Created
Inner state for a HeosConnection object that has been created but not connected.
HeosConnection
Main connection object of the library.
Stateful
Inner state for a HeosConnection object that is actively connected to a HEOS endpoint, and is tracking the overall state of the HEOS system.

Enums§

ConnectError
Errors that can occur when connecting a HeosConnection.
ScanError
The Error type