Everything needed to construct a new device is passed in through lua

This commit is contained in:
2024-04-25 01:35:23 +02:00
parent bfc73c7bd3
commit f4a1b507e5
22 changed files with 493 additions and 259 deletions

View File

@@ -9,7 +9,7 @@ use automation::devices::{
LightSensor, Ntfy, Presence, WakeOnLAN, Washer,
};
use automation::error::ApiError;
use automation::mqtt;
use automation::mqtt::{self, WrappedAsyncClient};
use axum::extract::FromRef;
use axum::http::StatusCode;
use axum::response::IntoResponse;
@@ -85,6 +85,8 @@ async fn app() -> anyhow::Result<()> {
let automation = lua.create_table()?;
automation.set("device_manager", device_manager.clone())?;
automation.set("mqtt_client", WrappedAsyncClient(client.clone()))?;
automation.set("event_channel", device_manager.event_channel())?;
let util = lua.create_table()?;
let get_env = lua.create_function(|_lua, name: String| {