Change ZHA power unit from kW to W (#37896)
* Change ZHA power unit from kW to W * Use POWER_WATT * Move kW to W conversion; ignore unit for powerpull/37942/head
parent
24ed932b01
commit
8beaccf2dd
|
@ -3,7 +3,7 @@ import logging
|
|||
|
||||
import zigpy.zcl.clusters.smartenergy as smartenergy
|
||||
|
||||
from homeassistant.const import LENGTH_FEET, TIME_HOURS, TIME_SECONDS
|
||||
from homeassistant.const import LENGTH_FEET, POWER_WATT, TIME_HOURS, TIME_SECONDS
|
||||
from homeassistant.core import callback
|
||||
|
||||
from .. import registries, typing as zha_typing
|
||||
|
@ -60,7 +60,7 @@ class Metering(ZigbeeChannel):
|
|||
REPORT_CONFIG = [{"attr": "instantaneous_demand", "config": REPORT_CONFIG_DEFAULT}]
|
||||
|
||||
unit_of_measure_map = {
|
||||
0x00: "kW",
|
||||
0x00: POWER_WATT,
|
||||
0x01: f"m³/{TIME_HOURS}",
|
||||
0x02: f"{LENGTH_FEET}³/{TIME_HOURS}",
|
||||
0x03: f"ccf/{TIME_HOURS}",
|
||||
|
@ -135,6 +135,12 @@ class Metering(ZigbeeChannel):
|
|||
|
||||
def formatter_function(self, value):
|
||||
"""Return formatted value for display."""
|
||||
if self.unit_of_measurement == POWER_WATT:
|
||||
# Zigbee spec power unit is kW, but we show the value in W
|
||||
value_watt = value * 1000
|
||||
if value_watt < 100:
|
||||
return round(value_watt, 1)
|
||||
return round(value_watt)
|
||||
return self._format_spec.format(value).lstrip()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue