@@ -224,6 +224,20 @@ impl AddAssign<&LightUpdate> for Light {
224224 grad. points . clone_from ( & grupd. points ) ;
225225 }
226226 }
227+
228+ if let Some ( upd) = & upd. effects_v2 {
229+ if let Some ( effects) = & mut self . effects_v2 {
230+ * effects += upd;
231+ }
232+ if let Some ( effects) = & mut self . effects {
233+ let light_effect = upd
234+ . action
235+ . as_ref ( )
236+ . and_then ( |a| a. effect )
237+ . unwrap_or ( LightEffect :: NoEffect ) ;
238+ effects. status = light_effect;
239+ }
240+ }
227241 }
228242}
229243
@@ -537,7 +551,7 @@ impl LightEffects {
537551 }
538552}
539553
540- #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
554+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
541555pub struct LightEffectsV2 {
542556 pub action : LightEffectValues ,
543557 pub status : LightEffectStatus ,
@@ -575,6 +589,19 @@ pub struct LightEffectsV2Update {
575589 pub status : Option < Value > ,
576590}
577591
592+ impl AddAssign < & LightEffectsV2Update > for LightEffectsV2 {
593+ fn add_assign ( & mut self , upd : & LightEffectsV2Update ) {
594+ let light_effect = upd
595+ . action
596+ . as_ref ( )
597+ . and_then ( |a| a. effect )
598+ . unwrap_or ( LightEffect :: NoEffect ) ;
599+
600+ self . status . effect = light_effect;
601+ self . status . parameters = upd. action . as_ref ( ) . map ( |a| a. parameters . clone ( ) ) ;
602+ }
603+ }
604+
578605#[ derive( Debug , Serialize , Deserialize , Clone ) ]
579606#[ serde( deny_unknown_fields) ]
580607pub struct LightEffectActionUpdate {
@@ -583,12 +610,12 @@ pub struct LightEffectActionUpdate {
583610 pub parameters : LightEffectParameters ,
584611}
585612
586- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
613+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
587614#[ serde( deny_unknown_fields) ]
588615pub struct LightEffectParameters {
589- #[ serde( default ) ]
616+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
590617 pub color : Option < ColorUpdate > ,
591- #[ serde( default ) ]
618+ #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
592619 pub color_temperature : Option < ColorTemperatureUpdate > ,
593620 pub speed : Option < f32 > ,
594621}
@@ -598,12 +625,12 @@ pub struct LightEffectValues {
598625 pub effect_values : Vec < LightEffect > ,
599626}
600627
601- #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
628+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq ) ]
602629pub struct LightEffectStatus {
603630 pub effect : LightEffect ,
604631 pub effect_values : Vec < LightEffect > ,
605632 #[ serde( default , skip_serializing_if = "Option::is_none" ) ]
606- pub parameters : Option < Value > ,
633+ pub parameters : Option < LightEffectParameters > ,
607634}
608635
609636#[ derive( Debug , Default , Serialize , Deserialize , Clone , Copy , PartialEq , Eq ) ]
0 commit comments