File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -92,16 +92,23 @@ impl Z2mBackend {
9292 drop ( lock) ;
9393
9494 /* step 1: send generic light update */
95+ let transition = upd
96+ . dynamics
97+ . as_ref ( )
98+ . and_then ( |d| d. duration . map ( |duration| f64:: from ( duration) / 1000.0 ) )
99+ . or_else ( || {
100+ if upd. dimming . is_some ( ) || upd. color_temperature . is_some ( ) || upd. color . is_some ( ) {
101+ Some ( 0.4 )
102+ } else {
103+ None
104+ }
105+ } ) ;
95106 let mut payload = DeviceUpdate :: default ( )
96107 . with_state ( upd. on . map ( |on| on. on ) )
97108 . with_brightness ( upd. dimming . map ( |dim| dim. brightness / 100.0 * 254.0 ) )
98109 . with_color_temp ( upd. color_temperature . and_then ( |ct| ct. mirek ) )
99110 . with_color_xy ( upd. color . map ( |col| col. xy ) )
100- . with_transition (
101- upd. dynamics
102- . as_ref ( )
103- . and_then ( |d| d. duration . map ( |duration| f64:: from ( duration) / 1000.0 ) ) ,
104- ) ;
111+ . with_transition ( transition) ;
105112
106113 // We don't want to send gradient updates twice, but if hue
107114 // effects are not supported for this light, this is the best
You can’t perform that action at this time.
0 commit comments