From c051211342595f5726c615437402dcc9033b658b Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Sun, 3 Sep 2017 14:03:43 +0200 Subject: [PATCH] The value of the property "current" is misleading for countries with 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. --- mirobo/plug.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/mirobo/plug.py b/mirobo/plug.py index a524452de..9fab5e265 100644 --- a/mirobo/plug.py +++ b/mirobo/plug.py @@ -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 = "" % \ + s = "" % \ (self.power, self.temperature, - self.current) + self.load_power) return s