Reverts unit conversions in TP-Link bulb (#11381)

Reverts energy and power unit conversions added in #10979 as they break
early devices.

A proper fix should be implemented in the pyhs100 library which should
return common units across all devices/firmwares.
This commit is contained in:
Dan Nixon 2017-12-31 14:58:22 +00:00 committed by Martin Hjelmare
parent 7759ab6919
commit fcbf7abdaa

View file

@ -167,16 +167,16 @@ class TPLinkSmartBulb(Light):
self._rgb = hsv_to_rgb(self.smartbulb.hsv) self._rgb = hsv_to_rgb(self.smartbulb.hsv)
if self.smartbulb.has_emeter: if self.smartbulb.has_emeter:
self._emeter_params[ATTR_CURRENT_POWER_W] = '{:.1f}'.format( self._emeter_params[ATTR_CURRENT_POWER_W] = '{:.1f}'.format(
self.smartbulb.current_consumption() / 1e3) self.smartbulb.current_consumption())
daily_statistics = self.smartbulb.get_emeter_daily() daily_statistics = self.smartbulb.get_emeter_daily()
monthly_statistics = self.smartbulb.get_emeter_monthly() monthly_statistics = self.smartbulb.get_emeter_monthly()
try: try:
self._emeter_params[ATTR_DAILY_ENERGY_KWH] \ self._emeter_params[ATTR_DAILY_ENERGY_KWH] \
= "{:.3f}".format( = "{:.3f}".format(
daily_statistics[int(time.strftime("%d"))] / 1e3) daily_statistics[int(time.strftime("%d"))])
self._emeter_params[ATTR_MONTHLY_ENERGY_KWH] \ self._emeter_params[ATTR_MONTHLY_ENERGY_KWH] \
= "{:.3f}".format( = "{:.3f}".format(
monthly_statistics[int(time.strftime("%m"))] / 1e3) monthly_statistics[int(time.strftime("%m"))])
except KeyError: except KeyError:
# device returned no daily/monthly history # device returned no daily/monthly history
pass pass