Fix DTE Energy Bridge V2 scaling issue. (#18124) (#18129)

This commit is contained in:
mtl010957 2018-11-02 17:48:17 -04:00 committed by Paulus Schoutsen
parent 45484ba569
commit 03d94df3cd

View file

@ -109,4 +109,10 @@ class DteEnergyBridgeSensor(Entity):
# 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
# Limiting to version 1 because version 2 apparently always returns
# values in the format 000000.000 kW, but the scaling is Watts
# NOT kWatts
if self._version == 1 and '.' in response_split[0]:
self._state = val
else:
self._state = val / 1000