Skip to content

Commit

Permalink
The value of the property "current" is misleading for countries with …
Browse files Browse the repository at this point in the history
…230V mains because it was calculated with a wrong reference voltage (110V) already. (#50)

As workaround a calculated property "load_power" is provided now. It's a firmware issue of the Xiaomi strip.
  • Loading branch information
syssi authored and rytilahti committed Sep 3, 2017
1 parent 2147a88 commit c051211
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions mirobo/plug.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ def temperature(self) -> float:
return self.data["temperature"]

@property
def current(self) -> float:
return self.data["current"]
def load_power(self) -> float:
if self.data["current"] is not None:
# The constant of 110V is used intentionally. The current was
# calculated with a wrong reference voltage already.
return self.data["current"] * 110

def __str__(self) -> str:
s = "<PlugStatus power=%s, temperature=%s, current=%s>" % \
s = "<PlugStatus power=%s, temperature=%s, load_power=%s>" % \
(self.power,
self.temperature,
self.current)
self.load_power)
return s


Expand Down

0 comments on commit c051211

Please sign in to comment.