@@ -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 ) {
@@ -750,12 +746,7 @@ function updateComponent(cd) {
750
746
updateInnerText ( el ( c , "head" ) , headText ) ;
751
747
setValueIfNotModified ( el ( c , "name" ) , cd . name ) ;
752
748
el ( c , "state" ) . checked = cd . state ;
753
- if ( cd . apower !== undefined ) {
754
- updateInnerText (
755
- el ( c , "power_stats" ) ,
756
- `${ Math . round ( cd . apower ) } W, ${ cd . aenergy } Wh` ) ;
757
- el ( c , "power_stats_container" ) . style . display = "block" ;
758
- }
749
+ updatePowerStats ( c , cd ) ;
759
750
slideIfNotModified ( el ( c , "color_temperature" ) , cd . color_temperature ) ;
760
751
slideIfNotModified ( el ( c , "hue" ) , cd . hue ) ;
761
752
slideIfNotModified ( el ( c , "saturation" ) , cd . saturation ) ;
@@ -1080,6 +1071,15 @@ function updateElement(key, value, info) {
1080
1071
}
1081
1072
}
1082
1073
1074
+ function updatePowerStats ( c , cd ) {
1075
+ if ( cd . apower === undefined ) return ;
1076
+
1077
+ apower = Math . round ( cd . apower * 10 ) / 10 ;
1078
+ console . log ( apower )
1079
+ updateInnerText ( el ( c , "power_stats" ) , `${ apower } W, ${ cd . aenergy } Wh` ) ;
1080
+ el ( c , "power_stats_container" ) . style . display = "block" ;
1081
+ }
1082
+
1083
1083
function getInfo ( ) {
1084
1084
return new Promise ( function ( resolve , reject ) {
1085
1085
if ( pendingGetInfo ) {
0 commit comments