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
1 changed files with 6 additions and 2 deletions
|
@ -97,8 +97,12 @@ class SmartPlugSwitch(SwitchDevice):
|
|||
= "%.1f A" % emeter_readings["current"]
|
||||
|
||||
emeter_statics = self.smartplug.get_emeter_daily()
|
||||
self._emeter_params[ATTR_DAILY_CONSUMPTION] \
|
||||
= "%.2f kW" % emeter_statics[int(time.strftime("%e"))]
|
||||
try:
|
||||
self._emeter_params[ATTR_DAILY_CONSUMPTION] \
|
||||
= "%.2f kW" % emeter_statics[int(time.strftime("%e"))]
|
||||
except KeyError:
|
||||
# device returned no daily history
|
||||
pass
|
||||
|
||||
except OSError:
|
||||
_LOGGER.warning('Could not update status for %s', self.name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue