refactor!: Rewrote device implementation macro once again
This time with a bit more though put into the design of the code, as a result the macro should be a lot more robust. This did result in the macro getting renamed from LuaDevice to Device as this should be _the_ Device macro. The attribute also got renamed from traits() to device(traits()) and the syntax got overhauled to allow for a bit more expression.
This commit is contained in:
@@ -10,7 +10,7 @@ use automation_lib::device::{Device, LuaDeviceCreate};
|
||||
use automation_lib::event::OnMqtt;
|
||||
use automation_lib::helpers::serialization::state_deserializer;
|
||||
use automation_lib::mqtt::WrappedAsyncClient;
|
||||
use automation_macro::{LuaDevice, LuaDeviceConfig, LuaSerialize};
|
||||
use automation_macro::{Device, LuaDeviceConfig, LuaSerialize};
|
||||
use google_home::device;
|
||||
use google_home::errors::ErrorCode;
|
||||
use google_home::traits::{Brightness, Color, ColorSetting, ColorTemperatureRange, OnOff};
|
||||
@@ -88,10 +88,10 @@ impl From<StateColorTemperature> for StateBrightness {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, LuaDevice)]
|
||||
#[traits(<StateOnOff>: OnOff)]
|
||||
#[traits(<StateBrightness>: OnOff, Brightness)]
|
||||
#[traits(<StateColorTemperature>: OnOff, Brightness, ColorSetting)]
|
||||
#[derive(Debug, Clone, Device)]
|
||||
#[device(traits(OnOff for <StateOnOff>, <StateBrightness>, <StateColorTemperature>))]
|
||||
#[device(traits(Brightness for <StateBrightness>, <StateColorTemperature>))]
|
||||
#[device(traits(ColorSetting for <StateColorTemperature>))]
|
||||
pub struct Light<T: LightState> {
|
||||
config: Config<T>,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user