pub struct AirTouch5 { /* private fields */ }Expand description
An AirTouch 5 console that we are interacting with.
This is the primary structure for interacting with the console. See the crate-level docs for usage and examples.
Implementations§
Source§impl AirTouch5
impl AirTouch5
Sourcepub async fn with_ipaddr(addr: IpAddr) -> Result<Self>
pub async fn with_ipaddr(addr: IpAddr) -> Result<Self>
Connect to an AirTouch 5 console at the given IP address.
let console_addr = IpAddr::V4(Ipv4Addr::new(192, 0, 2, 123));
let at5 = AirTouch5::with_ipaddr(console_addr).await?;Sourcepub fn subscribe_changes(&self) -> Option<Receiver<StatusChange>>
pub fn subscribe_changes(&self) -> Option<Receiver<StatusChange>>
Returns a receiver for a broadcast channel, whose values represent
asynchronous updates to the current system state. Each update may be for
or more AC units, or for one or more zones.
let at5 = AirTouch5::with_ipaddr(console_addr).await?;
if let Some(mut changes) = at5.subscribe_changes() {
let change = changes.recv().await?;
match change {
StatusChange::AcStatusChange(acs) => {
// handle the new AC state(s)
},
StatusChange::ZoneStatusChange(zones) => {
// handle the new zone state(s)
},
_ => {
// a change other than AC or zone state;
// reserved for future use
},
}
}None may be returned if the channel has already been closed (for example,
if the connection has been lost).
Sourcepub fn subscribe_status(&self) -> Option<Receiver<CurrentStatus>>
pub fn subscribe_status(&self) -> Option<Receiver<CurrentStatus>>
Returns a recevier for a watch channel, whose value represents the
current known state of the system.
let at5 = AirTouch5::with_ipaddr(console_addr).await?;
if let Some(mut watch) = at5.subscribe_status() {
let current = watch.borrow_and_update();
println!("{} AC units and {} zones are on",
current.acs().values()
.filter(|a| a.power.is_some() && a.power != Some(AcPower::Off))
.count(),
current.zones().values()
.filter(|z| z.power != ZonePower::Off)
.count(),
);
}None may be returned if the channel has already been closed (for example,
if the connection has been lost).
Calling both ac_status() and zone_status() will ensure that the
state is fully known.
let at5 = AirTouch5::with_ipaddr(console_addr).await?;
let _ = at5.ac_status().await?;
let _ = at5.zone_status().await?;
let mut watch = at5.subscribe_status();Sourcepub async fn shutdown(&mut self) -> Result<()>
pub async fn shutdown(&mut self) -> Result<()>
Gracefully shut down the connection to the console.
Sourcepub async fn zone_status(&self) -> Result<ZoneStatusMessage>
pub async fn zone_status(&self) -> Result<ZoneStatusMessage>
Request the current status of all zones.
Sourcepub async fn zone_status_timeout(
&self,
duration: Duration,
) -> Result<ZoneStatusMessage>
pub async fn zone_status_timeout( &self, duration: Duration, ) -> Result<ZoneStatusMessage>
Request the current status of all zones, with timeout.
Sourcepub async fn ac_status(&self) -> Result<AcStatusMessage>
pub async fn ac_status(&self) -> Result<AcStatusMessage>
Request the current status of all AC units.
Sourcepub async fn ac_status_timeout(
&self,
duration: Duration,
) -> Result<AcStatusMessage>
pub async fn ac_status_timeout( &self, duration: Duration, ) -> Result<AcStatusMessage>
Request the current status of all AC units, with timeout.
Sourcepub async fn ac_capabilities(&self) -> Result<AcCapabilityResponse>
pub async fn ac_capabilities(&self) -> Result<AcCapabilityResponse>
Request the capabilities of all AC units.
Sourcepub async fn ac_capabilities_timeout(
&self,
duration: Duration,
) -> Result<AcCapabilityResponse>
pub async fn ac_capabilities_timeout( &self, duration: Duration, ) -> Result<AcCapabilityResponse>
Request the capabilities of all AC units, with timeout.
Sourcepub async fn ac_capability(&self, ac_index: u8) -> Result<AcCapability>
pub async fn ac_capability(&self, ac_index: u8) -> Result<AcCapability>
Request the capabilities of a specific AC unit.
Sourcepub async fn ac_capability_timeout(
&self,
ac_index: u8,
duration: Duration,
) -> Result<AcCapability>
pub async fn ac_capability_timeout( &self, ac_index: u8, duration: Duration, ) -> Result<AcCapability>
Request the capabilities of a specific AC unit, with timeout.
Sourcepub async fn console_version(&self) -> Result<ConsoleVersionResponse>
pub async fn console_version(&self) -> Result<ConsoleVersionResponse>
Request the version information of the AirTouch 5 system.
Sourcepub async fn console_version_timeout(
&self,
duration: Duration,
) -> Result<ConsoleVersionResponse>
pub async fn console_version_timeout( &self, duration: Duration, ) -> Result<ConsoleVersionResponse>
Request the version information of the AirTouch 5 system, with timeout.
Sourcepub async fn zone_names(&self) -> Result<ZoneNameResponse>
pub async fn zone_names(&self) -> Result<ZoneNameResponse>
Request the names of all zones.
Sourcepub async fn zone_names_timeout(
&self,
duration: Duration,
) -> Result<ZoneNameResponse>
pub async fn zone_names_timeout( &self, duration: Duration, ) -> Result<ZoneNameResponse>
Request the names of all zones, with timeout.