Reworked air filter integration
All checks were successful
Build and deploy / Build application (push) Successful in 5m8s
Build and deploy / Build container (push) Successful in 2m19s
Build and deploy / Deploy container (push) Successful in 35s

This commit is contained in:
2025-01-22 03:12:13 +01:00
parent 5af713cf8f
commit 3905df690b
13 changed files with 250 additions and 160 deletions

View File

@@ -11,7 +11,7 @@ pub trait Device: DeviceFulfillment {
fn get_device_type(&self) -> Type;
fn get_device_name(&self) -> Name;
fn get_id(&self) -> String;
fn is_online(&self) -> bool;
async fn is_online(&self) -> bool;
// Default values that can optionally be overridden
fn will_report_state(&self) -> bool {
@@ -37,29 +37,39 @@ pub trait Device: DeviceFulfillment {
}
device.device_info = self.get_device_info();
let (traits, attributes) = DeviceFulfillment::sync(self).await.unwrap();
device.traits = traits;
device.attributes = attributes;
// TODO: Return the appropriate error
if let Ok((traits, attributes)) = DeviceFulfillment::sync(self).await {
device.traits = traits;
device.attributes = attributes;
}
device
}
async fn query(&self) -> response::query::Device {
let mut device = response::query::Device::new();
if !self.is_online() {
if !self.is_online().await {
device.set_offline();
}
device.state = DeviceFulfillment::query(self).await.unwrap();
// TODO: Return the appropriate error
if let Ok(state) = DeviceFulfillment::query(self).await {
device.state = state;
}
device
}
async fn execute(&self, command: Command) -> Result<(), ErrorCode> {
DeviceFulfillment::execute(self, command.clone())
// TODO: Do something with the return value, or just get rut of the return value?
if DeviceFulfillment::execute(self, command.clone())
.await
.unwrap();
.is_err()
{
return Err(ErrorCode::DeviceError(
crate::errors::DeviceError::TransientError,
));
}
Ok(())
}

View File

@@ -140,7 +140,7 @@ impl GoogleHome {
if let Some(device) = devices.get(id.as_str())
&& let Some(device) = device.as_ref().cast()
{
if !device.is_online() {
if !device.is_online().await {
return (id, Ok(false));
}

View File

@@ -52,7 +52,7 @@ traits! {
// TODO: Add rename
temperatureUnitForUX: TemperatureUnit,
async fn temperature_ambient_celsius(&self) -> f32,
async fn temperature_ambient_celsius(&self) -> Result<f32, ErrorCode>,
}
}