feat(config)!: Remove device manager lua code
With the recent changes the device manager no longer needs to be available in lua.
This commit is contained in:
@@ -2,8 +2,6 @@ use std::collections::HashMap;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use futures::future::join_all;
|
use futures::future::join_all;
|
||||||
use lua_typed::Typed;
|
|
||||||
use mlua::FromLua;
|
|
||||||
use tokio::sync::{RwLock, RwLockReadGuard};
|
use tokio::sync::{RwLock, RwLockReadGuard};
|
||||||
use tracing::{debug, instrument, trace};
|
use tracing::{debug, instrument, trace};
|
||||||
|
|
||||||
@@ -12,7 +10,7 @@ use crate::event::{Event, EventChannel, OnMqtt};
|
|||||||
|
|
||||||
pub type DeviceMap = HashMap<String, Box<dyn Device>>;
|
pub type DeviceMap = HashMap<String, Box<dyn Device>>;
|
||||||
|
|
||||||
#[derive(Clone, FromLua)]
|
#[derive(Clone)]
|
||||||
pub struct DeviceManager {
|
pub struct DeviceManager {
|
||||||
devices: Arc<RwLock<DeviceMap>>,
|
devices: Arc<RwLock<DeviceMap>>,
|
||||||
event_channel: EventChannel,
|
event_channel: EventChannel,
|
||||||
@@ -89,21 +87,3 @@ impl DeviceManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl mlua::UserData for DeviceManager {
|
|
||||||
fn add_methods<M: mlua::UserDataMethods<Self>>(methods: &mut M) {
|
|
||||||
methods.add_async_method("add", async |_lua, this, device: Box<dyn Device>| {
|
|
||||||
this.add(device).await;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
});
|
|
||||||
|
|
||||||
methods.add_method("event_channel", |_lua, this, ()| Ok(this.event_channel()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Typed for DeviceManager {
|
|
||||||
fn type_name() -> String {
|
|
||||||
"DeviceManager".into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
---@meta
|
|
||||||
|
|
||||||
---@class DeviceManager
|
|
||||||
local DeviceManager
|
|
||||||
---@param device DeviceInterface
|
|
||||||
function DeviceManager:add(device) end
|
|
||||||
|
|
||||||
return DeviceManager
|
|
||||||
@@ -132,8 +132,6 @@ async fn app() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
automation_lib::load_modules(&lua)?;
|
automation_lib::load_modules(&lua)?;
|
||||||
|
|
||||||
lua.register_module("automation:device_manager", device_manager.clone())?;
|
|
||||||
|
|
||||||
lua.register_module("automation:variables", lua.to_value(&setup.variables)?)?;
|
lua.register_module("automation:variables", lua.to_value(&setup.variables)?)?;
|
||||||
lua.register_module("automation:secrets", lua.to_value(&setup.secrets)?)?;
|
lua.register_module("automation:secrets", lua.to_value(&setup.secrets)?)?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user