feat(config)!: In config devices can now also be a (table of) function(s)
This function receives the mqtt client as an argument. In the future this will be the only way to create devices that require the mqtt client.
This commit is contained in:
@@ -139,8 +139,10 @@ async fn app() -> anyhow::Result<()> {
|
||||
let entrypoint = Path::new(&setup.entrypoint);
|
||||
let config: Config = lua.load(entrypoint).eval_async().await?;
|
||||
|
||||
for device in config.devices {
|
||||
device_manager.add(device).await;
|
||||
if let Some(devices) = config.devices {
|
||||
for device in devices.get(&lua, &config.mqtt).await? {
|
||||
device_manager.add(device).await;
|
||||
}
|
||||
}
|
||||
|
||||
start_scheduler(config.schedule).await?;
|
||||
|
||||
Reference in New Issue
Block a user