Skip to content

Commit

Permalink
Chuangmi Plug V3: Fix measurement unit (W) of the power consumption (…
Browse files Browse the repository at this point in the history
…load_power) (#338)
  • Loading branch information
syssi authored Jun 16, 2018
1 parent a68eba5 commit fb595be
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions miio/chuangmi_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion miio/tests/test_chuangmi_plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fb595be

Please sign in to comment.