feat(config)!: Put automation modules in namespace
All lua modules that originate from automation_rs are now prefixed with `automation:`.
This commit is contained in:
@@ -40,7 +40,7 @@ pub fn load_modules(lua: &mlua::Lua) -> mlua::Result<()> {
|
|||||||
for module in inventory::iter::<Module> {
|
for module in inventory::iter::<Module> {
|
||||||
debug!(name = module.get_name(), "Loading module");
|
debug!(name = module.get_name(), "Loading module");
|
||||||
let table = module.register(lua)?;
|
let table = module.register(lua)?;
|
||||||
lua.register_module(module.get_name(), table)?;
|
lua.register_module(&format!("automation:{}", module.get_name()), table)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
12
config.lua
12
config.lua
@@ -1,8 +1,8 @@
|
|||||||
local devices = require("devices")
|
local devices = require("automation:devices")
|
||||||
local device_manager = require("device_manager")
|
local device_manager = require("automation:device_manager")
|
||||||
local utils = require("utils")
|
local utils = require("automation:utils")
|
||||||
local secrets = require("secrets")
|
local secrets = require("automation:secrets")
|
||||||
local debug = require("variables").debug or false
|
local debug = require("automation:variables").debug or false
|
||||||
|
|
||||||
print(_VERSION)
|
print(_VERSION)
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ local fulfillment = {
|
|||||||
openid_url = "https://login.huizinga.dev/api/oidc",
|
openid_url = "https://login.huizinga.dev/api/oidc",
|
||||||
}
|
}
|
||||||
|
|
||||||
local mqtt_client = require("mqtt").new({
|
local mqtt_client = require("automation:mqtt").new({
|
||||||
host = ((host == "zeus" or host == "hephaestus") and "olympus.lan.huizinga.dev") or "mosquitto",
|
host = ((host == "zeus" or host == "hephaestus") and "olympus.lan.huizinga.dev") or "mosquitto",
|
||||||
port = 8883,
|
port = 8883,
|
||||||
client_name = "automation-" .. host,
|
client_name = "automation-" .. host,
|
||||||
|
|||||||
@@ -154,12 +154,12 @@ async fn app() -> anyhow::Result<()> {
|
|||||||
Ok(WrappedAsyncClient(client))
|
Ok(WrappedAsyncClient(client))
|
||||||
})?;
|
})?;
|
||||||
mqtt.set("new", mqtt_new)?;
|
mqtt.set("new", mqtt_new)?;
|
||||||
lua.register_module("mqtt", mqtt)?;
|
lua.register_module("automation:mqtt", mqtt)?;
|
||||||
|
|
||||||
lua.register_module("device_manager", device_manager.clone())?;
|
lua.register_module("automation:device_manager", device_manager.clone())?;
|
||||||
|
|
||||||
lua.register_module("variables", lua.to_value(&config.variables)?)?;
|
lua.register_module("automation:variables", lua.to_value(&config.variables)?)?;
|
||||||
lua.register_module("secrets", lua.to_value(&config.secrets)?)?;
|
lua.register_module("automation:secrets", lua.to_value(&config.secrets)?)?;
|
||||||
|
|
||||||
let entrypoint = Path::new(&config.entrypoint);
|
let entrypoint = Path::new(&config.entrypoint);
|
||||||
let fulfillment_config: mlua::Value = lua.load(entrypoint).eval_async().await?;
|
let fulfillment_config: mlua::Value = lua.load(entrypoint).eval_async().await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user