Moved schedule config from yml to lua

This commit is contained in:
2024-04-26 23:16:39 +02:00
parent 3225dbdda9
commit 5069d1b0e7
6 changed files with 23 additions and 26 deletions

View File

@@ -6,7 +6,7 @@ use async_trait::async_trait;
use enum_dispatch::enum_dispatch;
use futures::future::join_all;
use google_home::traits::OnOff;
use mlua::FromLua;
use mlua::{FromLua, LuaSerdeExt};
use rumqttc::{matches, AsyncClient, QoS};
use tokio::sync::{RwLock, RwLockReadGuard};
use tokio_cron_scheduler::{Job, JobScheduler};
@@ -261,6 +261,12 @@ impl mlua::UserData for DeviceManager {
Ok(this.add(device).await)
},
)
);
methods.add_async_method("add_schedule", |lua, this, schedule| async {
let schedule = lua.from_value(schedule)?;
this.add_schedule(schedule).await;
Ok(())
})
}
}