Compare commits

...

2 Commits

Author SHA1 Message Date
f7ba602762 chore: Removed dotenvy
All checks were successful
Build and deploy / build (push) Successful in 10m21s
Build and deploy / Deploy container (push) Has been skipped
Since secrets can now be set from automation.toml the .env file was no
longer used, so dotenvy can be removed.
2025-10-15 01:18:09 +02:00
929007d8c2 feat: Use Typed type_name for registering proxy 2025-10-15 01:01:10 +02:00
4 changed files with 13 additions and 20 deletions

7
Cargo.lock generated
View File

@@ -96,7 +96,6 @@ dependencies = [
"automation_lib",
"axum",
"config",
"dotenvy",
"git-version",
"google_home",
"mlua",
@@ -433,12 +432,6 @@ dependencies = [
"syn 2.0.106",
]
[[package]]
name = "dotenvy"
version = "0.15.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1aaf95b3e5c8f23aa320147307562d361db0ae0d51242340f558153b4eb2439b"
[[package]]
name = "dyn-clone"
version = "1.0.20"

View File

@@ -23,7 +23,6 @@ automation_lib = { path = "./automation_lib" }
automation_macro = { path = "./automation_macro" }
axum = "0.8.4"
bytes = "1.10.1"
dotenvy = "0.15.7"
dyn-clone = "1.0.20"
eui48 = { version = "1.1.0", features = [
"disp_hexstring",
@@ -75,7 +74,6 @@ config = { version = "0.15.15", default-features = false, features = [
"async",
"toml",
] }
dotenvy = { workspace = true }
git-version = "0.3.9"
google_home = { workspace = true }
mlua = { workspace = true }

View File

@@ -20,7 +20,7 @@ use tracing::debug;
macro_rules! register_device {
($device:ty) => {
::inventory::submit!(crate::RegisteredDevice::new(
stringify!($device),
<$device as ::lua_typed::Typed>::type_name,
::mlua::Lua::create_proxy::<$device>
));
@@ -30,20 +30,24 @@ macro_rules! register_device {
pub(crate) use register_device;
type DeviceNameFn = fn() -> String;
type RegisterDeviceFn = fn(lua: &mlua::Lua) -> mlua::Result<mlua::AnyUserData>;
pub struct RegisteredDevice {
name: &'static str,
name_fn: DeviceNameFn,
register_fn: RegisterDeviceFn,
}
impl RegisteredDevice {
pub const fn new(name: &'static str, register_fn: RegisterDeviceFn) -> Self {
Self { name, register_fn }
pub const fn new(name_fn: DeviceNameFn, register_fn: RegisterDeviceFn) -> Self {
Self {
name_fn,
register_fn,
}
}
pub const fn get_name(&self) -> &'static str {
self.name
pub fn get_name(&self) -> String {
(self.name_fn)()
}
pub fn register(&self, lua: &mlua::Lua) -> mlua::Result<mlua::AnyUserData> {
@@ -58,9 +62,10 @@ pub fn create_module(lua: &mlua::Lua) -> mlua::Result<mlua::Table> {
debug!("Loading devices...");
for device in inventory::iter::<RegisteredDevice> {
debug!(name = device.get_name(), "Registering device");
let name = device.get_name();
debug!(name, "Registering device");
let proxy = device.register(lua)?;
devices.set(device.get_name(), proxy)?;
devices.set(name, proxy)?;
}
Ok(devices)

View File

@@ -17,7 +17,6 @@ use axum::http::StatusCode;
use axum::routing::post;
use axum::{Json, Router};
use config::Config;
use dotenvy::dotenv;
use google_home::{GoogleHome, Request, Response};
use mlua::LuaSerdeExt;
use rumqttc::AsyncClient;
@@ -75,8 +74,6 @@ async fn fulfillment(
}
async fn app() -> anyhow::Result<()> {
dotenv().ok();
tracing_subscriber::fmt::init();
info!(version = VERSION, "automation_rs");