AudioSetup now takes the name of two already created devices and stores a reference to the devices instead of creating and owning the devices directly

This commit is contained in:
2023-08-14 01:51:45 +02:00
parent 76b75b0cfb
commit e38c5eed31
12 changed files with 151 additions and 77 deletions

View File

@@ -8,6 +8,7 @@ use tracing::{debug, error, trace, warn};
use crate::{
config::{CreateDevice, MqttDeviceConfig},
device_manager::DeviceManager,
devices::DEFAULT_PRESENCE,
error::{CreateDeviceError, MissingWildcard},
event::EventChannel,
@@ -72,15 +73,17 @@ pub struct ContactSensor {
handle: Option<JoinHandle<()>>,
}
#[async_trait]
impl CreateDevice for ContactSensor {
type Config = ContactSensorConfig;
fn create(
async fn create(
identifier: &str,
config: Self::Config,
_event_channel: &EventChannel,
client: &AsyncClient,
presence_topic: &str,
_device_manager: &DeviceManager,
) -> Result<Self, CreateDeviceError> {
trace!(id = identifier, "Setting up ContactSensor");