Made the impl_device macro more explicit about the implemented traits

This also converts impl_device into a procedural macro and get rid of a
lot of "magic" that was happening.
This commit is contained in:
2025-08-28 03:02:45 +02:00
parent c5262dcf35
commit d2b01123b8
26 changed files with 197 additions and 208 deletions

View File

@@ -10,7 +10,7 @@ use automation_lib::device::{Device, LuaDeviceCreate};
use automation_lib::event::{OnMqtt, OnPresence};
use automation_lib::helpers::serialization::state_deserializer;
use automation_lib::mqtt::WrappedAsyncClient;
use automation_macro::LuaDeviceConfig;
use automation_macro::{LuaDeviceConfig, impl_device};
use google_home::device;
use google_home::errors::ErrorCode;
use google_home::traits::{Brightness, Color, ColorSetting, ColorTemperatureRange, OnOff};
@@ -96,8 +96,11 @@ pub struct Light<T: LightState> {
}
pub type LightOnOff = Light<StateOnOff>;
impl_device!(LightOnOff -> OnOff);
pub type LightBrightness = Light<StateBrightness>;
impl_device!(LightBrightness -> OnOff, Brightness);
pub type LightColorTemperature = Light<StateColorTemperature>;
impl_device!(LightColorTemperature -> OnOff, Brightness, ColorSetting);
impl<T: LightState> Light<T> {
async fn state(&self) -> RwLockReadGuard<'_, T> {