Fix for DTE Energy Bridge returning the wrong units from time to time (#9246)

The DTE Energy Bridge seems to return the current energy
usage randomly in either W or kW.  The only way to tell the difference
is if there is a decimal or not in the result.

Also added some tests.
This commit is contained in:
Kyle Hendricks authored and Paulus Schoutsen committed 2017-09-15 23:12:06 -07:00
1 parent 04bed51277
commit 7b0628421d
2 files changed
+74 -1

No files matched your search

@@ -91,4 +91,9 @@ class DteEnergyBridgeSensor(Entity):
response.text, self._name)
return
self._state = float(response_split[0])
val = float(response_split[0])
# A workaround for a bug in the DTE energy bridge.
# The returned value can randomly be in W or kW. Checking for a
# a decimal seems to be a reliable way to determine the units.
self._state = val if '.' in response_split[0] else val / 1000