Improved how devices are created, ntfy and presence are now treated like any other device

This commit is contained in:
2024-04-27 02:55:53 +02:00
parent 5069d1b0e7
commit 3e4ea8952a
22 changed files with 423 additions and 528 deletions

View File

@@ -65,18 +65,6 @@ async fn app() -> anyhow::Result<()> {
let event_channel = device_manager.event_channel();
// Create and add the presence system
{
let presence = Presence::new(config.presence, &event_channel);
device_manager.add(Box::new(presence)).await;
}
// Start the ntfy service if it is configured
if let Some(config) = config.ntfy {
let ntfy = Ntfy::new(config, &event_channel);
device_manager.add(Box::new(ntfy)).await;
}
// Lua testing
{
let lua = mlua::Lua::new();
@@ -102,6 +90,8 @@ async fn app() -> anyhow::Result<()> {
lua.globals().set("automation", automation)?;
// Register all the device types
Ntfy::register_with_lua(&lua)?;
Presence::register_with_lua(&lua)?;
AirFilter::register_with_lua(&lua)?;
AudioSetup::register_with_lua(&lua)?;
ContactSensor::register_with_lua(&lua)?;