Added brightness trait
This commit is contained in:
parent
41d2af655b
commit
8c9e93dcc4
|
@ -74,6 +74,26 @@ macro_rules! impl_device {
|
|||
.unwrap())
|
||||
});
|
||||
}
|
||||
|
||||
if impls::impls!($device: google_home::traits::Brightness) {
|
||||
methods.add_async_method("set_brightness", |_lua, this, brightness: u8| async move {
|
||||
(this.deref().cast() as Option<&dyn google_home::traits::Brightness>)
|
||||
.expect("Cast should be valid")
|
||||
.set_brightness(brightness)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
Ok(())
|
||||
});
|
||||
|
||||
methods.add_async_method("brightness", |_lua, this, _: ()| async move {
|
||||
Ok((this.deref().cast() as Option<&dyn google_home::traits::Brightness>)
|
||||
.expect("Cast should be valid")
|
||||
.brightness()
|
||||
.await
|
||||
.unwrap())
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -14,6 +14,11 @@ traits! {
|
|||
async fn on(&self) -> Result<bool, ErrorCode>,
|
||||
"action.devices.commands.OnOff" => async fn set_on(&self, on: bool) -> Result<(), ErrorCode>,
|
||||
},
|
||||
"action.devices.traits.Brightness" => trait Brightness {
|
||||
command_only_brightness: Option<bool>,
|
||||
async fn brightness(&self) -> Result<u8, ErrorCode>,
|
||||
"action.devices.commands.BrightnessAbsolute" => async fn set_brightness(&self, brightness: u8) -> Result<(), ErrorCode>,
|
||||
},
|
||||
"action.devices.traits.Scene" => trait Scene {
|
||||
scene_reversible: Option<bool>,
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user