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,5 +1,6 @@
use std::time::Duration;
use async_trait::async_trait;
use pollster::FutureExt;
use rumqttc::{AsyncClient, matches};
use tokio::task::JoinHandle;
@@ -9,6 +10,7 @@ use crate::{config::{MqttDeviceConfig, PresenceDeviceConfig}, mqtt::{OnMqtt, Con
use super::Device;
#[derive(Debug)]
pub struct ContactSensor {
identifier: String,
mqtt: MqttDeviceConfig,
@@ -42,8 +44,9 @@ impl Device for ContactSensor {
}
}
#[async_trait]
impl OnPresence for ContactSensor {
fn on_presence(&mut self, presence: bool) {
async fn on_presence(&mut self, presence: bool) {
self.overall_presence = presence;
}
}