Switched to channels for communication between different parts of the code

This commit is contained in:
2023-01-09 23:50:50 +01:00
parent cf88768c15
commit 5b9d24e82f
18 changed files with 285 additions and 251 deletions

View File

@@ -1,3 +1,4 @@
use async_trait::async_trait;
use google_home::traits;
use rumqttc::{AsyncClient, matches};
use tracing::{error, warn, debug};
@@ -11,6 +12,7 @@ use super::Device;
// @TODO Ideally we store am Arc to the childern devices,
// that way they hook into everything just like all other devices
#[derive(Debug)]
pub struct AudioSetup {
identifier: String,
mqtt: MqttDeviceConfig,
@@ -71,8 +73,9 @@ impl OnMqtt for AudioSetup {
}
}
#[async_trait]
impl OnPresence for AudioSetup {
fn on_presence(&mut self, presence: bool) {
async fn on_presence(&mut self, presence: bool) {
// Turn off the audio setup when we leave the house
if !presence {
debug!(id = self.identifier, "Turning devices off");