mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
switch.tplink: expect daily stats to be empty (#4504)
Signed-off-by: Martin Weinelt <hexa@darmstadt.ccc.de>
This commit is contained in:
parent
835577b2bc
commit
a73fbbaf7a
@ -97,8 +97,12 @@ class SmartPlugSwitch(SwitchDevice):
|
|||||||
= "%.1f A" % emeter_readings["current"]
|
= "%.1f A" % emeter_readings["current"]
|
||||||
|
|
||||||
emeter_statics = self.smartplug.get_emeter_daily()
|
emeter_statics = self.smartplug.get_emeter_daily()
|
||||||
self._emeter_params[ATTR_DAILY_CONSUMPTION] \
|
try:
|
||||||
= "%.2f kW" % emeter_statics[int(time.strftime("%e"))]
|
self._emeter_params[ATTR_DAILY_CONSUMPTION] \
|
||||||
|
= "%.2f kW" % emeter_statics[int(time.strftime("%e"))]
|
||||||
|
except KeyError:
|
||||||
|
# device returned no daily history
|
||||||
|
pass
|
||||||
|
|
||||||
except OSError:
|
except OSError:
|
||||||
_LOGGER.warning('Could not update status for %s', self.name)
|
_LOGGER.warning('Could not update status for %s', self.name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user