@@ -390,21 +390,27 @@ async fn put_api_user_resource_id(
390390 ApiResourceType :: Groups => {
391391 let upd: ApiGroupUpdate2 = serde_json:: from_value ( req) ?;
392392
393- let uuid = state . res . lock ( ) . await . from_id_v1 ( id) ? ;
393+ let mut v1res = V1Reply :: for_group ( id) ;
394394
395- let action = if upd. stream . active {
396- EntertainmentConfigurationAction :: Start
397- } else {
398- EntertainmentConfigurationAction :: Stop
399- } ;
395+ let mut ecupd = EntertainmentConfigurationUpdate :: new ( ) ;
400396
401- let ecupd = EntertainmentConfigurationUpdate {
402- configuration_type : None ,
403- metadata : None ,
404- action : Some ( action) ,
405- stream_proxy : None ,
406- locations : None ,
407- } ;
397+ let lock = state. res . lock ( ) . await ;
398+
399+ let uuid = lock. from_id_v1 ( id) ?;
400+
401+ ecupd. action = upd. stream . map ( |stream| {
402+ if stream. active {
403+ EntertainmentConfigurationAction :: Start
404+ } else {
405+ EntertainmentConfigurationAction :: Stop
406+ }
407+ } ) ;
408+
409+ if let Some ( lights) = & upd. lights {
410+ ecupd. locations = Some ( lights_v1_to_ec_locations ( lights, & lock) ?. into ( ) ) ;
411+ }
412+
413+ drop ( lock) ;
408414
409415 let rlink = RType :: EntertainmentConfiguration . link_to ( uuid) ;
410416
@@ -415,14 +421,15 @@ async fn put_api_user_resource_id(
415421 )
416422 . await ?;
417423
418- if resp. 0 . errors . is_empty ( ) {
419- let v1res = V1Reply :: for_group ( id)
420- . add ( "stream/active" , upd. stream . active ) ?
421- . json ( ) ;
422- Ok ( Json ( v1res) )
423- } else {
424- Err ( HueApiV1Error :: BridgeInternalError ) ?
424+ if !resp. 0 . errors . is_empty ( ) {
425+ Err ( HueApiV1Error :: BridgeInternalError ) ?;
425426 }
427+
428+ if let Some ( stream) = & upd. stream {
429+ v1res = v1res. add ( "stream/active" , stream. active ) ?;
430+ }
431+
432+ Ok ( Json ( v1res. json ( ) ) )
426433 }
427434 ApiResourceType :: Config
428435 | ApiResourceType :: Lights
0 commit comments