@@ -673,11 +673,7 @@ function updateComponent(cd) {
673
673
updateInnerText ( el ( c , "head" ) , headText ) ;
674
674
setValueIfNotModified ( el ( c , "name" ) , cd . name ) ;
675
675
el ( c , "state" ) . checked = cd . state ;
676
- if ( cd . apower !== undefined ) {
677
- updateInnerText (
678
- el ( c , "power_stats" ) , `${ Math . round ( cd . apower ) } W, ${ cd . aenergy } Wh` ) ;
679
- el ( c , "power_stats_container" ) . style . display = "block" ;
680
- }
676
+ updatePowerStats ( c , cd ) ;
681
677
if ( cd . type == Component_Type . kLightBulb ) {
682
678
checkIfNotModified ( el ( c , "svc_hidden" ) , cd . svc_hidden ) ;
683
679
if ( cd . hap_optional !== undefined && cd . hap_optional == 0 ) {
@@ -739,12 +735,7 @@ function updateComponent(cd) {
739
735
updateInnerText ( el ( c , "head" ) , headText ) ;
740
736
setValueIfNotModified ( el ( c , "name" ) , cd . name ) ;
741
737
el ( c , "state" ) . checked = cd . state ;
742
- if ( cd . apower !== undefined ) {
743
- updateInnerText (
744
- el ( c , "power_stats" ) ,
745
- `${ Math . round ( cd . apower ) } W, ${ cd . aenergy } Wh` ) ;
746
- el ( c , "power_stats_container" ) . style . display = "block" ;
747
- }
738
+ updatePowerStats ( c , cd ) ;
748
739
slideIfNotModified ( el ( c , "color_temperature" ) , cd . color_temperature ) ;
749
740
slideIfNotModified ( el ( c , "hue" ) , cd . hue ) ;
750
741
slideIfNotModified ( el ( c , "saturation" ) , cd . saturation ) ;
@@ -1069,6 +1060,15 @@ function updateElement(key, value, info) {
1069
1060
}
1070
1061
}
1071
1062
1063
+ function updatePowerStats ( c , cd ) {
1064
+ if ( cd . apower === undefined ) return ;
1065
+
1066
+ apower = Math . round ( cd . apower * 10 ) / 10 ;
1067
+ console . log ( apower )
1068
+ updateInnerText ( el ( c , "power_stats" ) , `${ apower } W, ${ cd . aenergy } Wh` ) ;
1069
+ el ( c , "power_stats_container" ) . style . display = "block" ;
1070
+ }
1071
+
1072
1072
function getInfo ( ) {
1073
1073
return new Promise ( function ( resolve , reject ) {
1074
1074
if ( pendingGetInfo ) {
0 commit comments