@@ -47,6 +47,27 @@ impl GroupedLight {
4747 }
4848}
4949
50+ #[ derive( Debug , Default , Serialize , Deserialize , Clone ) ]
51+ pub struct GroupedLightDynamicsUpdate {
52+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
53+ pub duration : Option < u32 > ,
54+ }
55+
56+ impl GroupedLightDynamicsUpdate {
57+ #[ must_use]
58+ pub fn new ( ) -> Self {
59+ Self :: default ( )
60+ }
61+
62+ #[ must_use]
63+ pub fn with_duration ( self , duration : Option < impl Into < u32 > > ) -> Self {
64+ Self {
65+ duration : duration. map ( Into :: into) ,
66+ ..self
67+ }
68+ }
69+ }
70+
5071#[ derive( Debug , Serialize , Deserialize , Clone , Default ) ]
5172pub struct GroupedLightUpdate {
5273 #[ serde( skip_serializing_if = "Option::is_none" ) ]
@@ -59,6 +80,8 @@ pub struct GroupedLightUpdate {
5980 pub color_temperature : Option < ColorTemperatureUpdate > ,
6081 #[ serde( skip_serializing_if = "Option::is_none" ) ]
6182 pub owner : Option < ResourceLink > ,
83+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
84+ pub dynamics : Option < GroupedLightDynamicsUpdate > ,
6285}
6386
6487impl GroupedLightUpdate {
@@ -103,6 +126,11 @@ impl GroupedLightUpdate {
103126 ..self
104127 }
105128 }
129+
130+ #[ must_use]
131+ pub const fn with_dynamics ( self , dynamics : Option < GroupedLightDynamicsUpdate > ) -> Self {
132+ Self { dynamics, ..self }
133+ }
106134}
107135
108136/* conversion from v1 api */
@@ -113,5 +141,9 @@ impl From<&ApiLightStateUpdate> for GroupedLightUpdate {
113141 . with_brightness ( upd. bri . map ( |b| f64:: from ( b) / 2.54 ) )
114142 . with_color_xy ( upd. xy . map ( XY :: from) )
115143 . with_color_temperature ( upd. ct )
144+ . with_dynamics (
145+ upd. transitiontime
146+ . map ( |t| GroupedLightDynamicsUpdate :: new ( ) . with_duration ( Some ( t * 100 ) ) ) ,
147+ )
116148 }
117149}
0 commit comments