use automation_cast::Cast; use automation_macro::google_home_traits; use google_home::errors::ErrorCode; use google_home::traits::AvailableSpeeds; google_home_traits! { GoogleHomeDevice { "action.devices.traits.OnOff" => trait OnOff { command_only_on_off: bool, // This one is optional query_only_on_off: Option, async fn is_on(&self) -> Result => on, "action.devices.commands.OnOff" => async fn set_on(&self, on: bool) -> Result<(), ErrorCode>, }, "action.devices.traits.Scene" => trait Scene { scene_reversible: Option, "action.devices.commands.ActivateScene" => async fn set_active(&self, activate: bool) -> Result<(), ErrorCode>, }, "action.devices.traits.FanSpeed" => trait FanSpeed { reversible: Option, command_only_fan_speed: Option, available_fan_speeds: AvailableSpeeds, fn get_fan_speed(&self) -> Result => current_fan_speed_setting, "action.devices.commands.SetFanSpeed" => fn set_speed(&self, fan_speed: String), }, "action.devices.traits.HumiditySetting" => trait HumiditySetting { query_only_humidity_setting: Option, fn get_humidity(&self) -> Result => humidity_ambient_percent, } } } trait Casts: Cast + Cast + Cast + Cast { } trait GoogleHomeDevice: Casts {} struct Device {} #[async_trait::async_trait] impl OnOff for Device { fn command_only_on_off(&self) -> bool { false } async fn is_on(&self) -> Result { Ok(true) } async fn set_on(&self, _on: bool) -> Result<(), ErrorCode> { Ok(()) } } fn main() {}