diff --git a/miio/chuangmi_plug.py b/miio/chuangmi_plug.py index 3260c6a42..c2859146a 100644 --- a/miio/chuangmi_plug.py +++ b/miio/chuangmi_plug.py @@ -61,10 +61,10 @@ def usb_power(self) -> Optional[bool]: return None @property - def load_power(self) -> Optional[int]: + def load_power(self) -> Optional[float]: """Current power load, if available.""" if "load_power" in self.data and self.data["load_power"] is not None: - return self.data["load_power"] + return float(self.data["load_power"]) return None @property @@ -134,7 +134,7 @@ def status(self) -> ChuangmiPlugStatus: load_power = self.send("get_power", []) # Response: [300] if len(load_power) == 1: properties.append('load_power') - values.append(load_power[0]) + values.append(load_power[0] * 0.01) return ChuangmiPlugStatus( defaultdict(lambda: None, zip(properties, values))) diff --git a/miio/tests/test_chuangmi_plug.py b/miio/tests/test_chuangmi_plug.py index dd922ffc0..84f4c4ff1 100644 --- a/miio/tests/test_chuangmi_plug.py +++ b/miio/tests/test_chuangmi_plug.py @@ -144,7 +144,7 @@ def test_off(self): def test_status(self): self.device._reset_state() - load_power = self.device._get_load_power().pop(0) + load_power = float(self.device._get_load_power().pop(0) * 0.01) start_state_extended = self.device.start_state.copy() start_state_extended['load_power'] = load_power