forked from platypush/platypush
[switch.tplink] Better error handling.
The whole `_update_devices` for loop should be covered by a try-except block. That's because custom attribute getters may be invoked also after expanding the results, resulting in unhandled `SmartDeviceException`.
This commit is contained in:
parent
2883c4f086
commit
71bafec11e
1 changed files with 7 additions and 7 deletions
|
@ -86,16 +86,16 @@ class SwitchTplinkPlugin(RunnablePlugin, SwitchEntityManager):
|
|||
dev = info['type'](addr)
|
||||
self._alias_to_dev[info.get('name', dev.alias)] = dev
|
||||
self._ip_to_dev[addr] = dev
|
||||
|
||||
for ip, dev in (devices or {}).items():
|
||||
self._ip_to_dev[ip] = dev
|
||||
self._alias_to_dev[dev.alias] = dev
|
||||
|
||||
if devices and publish_entities:
|
||||
self.publish_entities(devices.values())
|
||||
except SmartDeviceException as e:
|
||||
self.logger.warning('Could not communicate with device %s: %s', addr, e)
|
||||
|
||||
for ip, dev in (devices or {}).items():
|
||||
self._ip_to_dev[ip] = dev
|
||||
self._alias_to_dev[dev.alias] = dev
|
||||
|
||||
if devices and publish_entities:
|
||||
self.publish_entities(devices.values())
|
||||
|
||||
def transform_entities(self, entities: Collection[SmartDevice]):
|
||||
from platypush.entities.switches import Switch
|
||||
|
||||
|
|
Loading…
Reference in a new issue