Skip to content

Commit

Permalink
Catch exceptions on device setup #809
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 4, 2022
1 parent 62707e7 commit 4548671
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions custom_components/sonoff/core/ewelink/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,24 @@ def setup_devices(self, devices: List[XDevice]):
from ..devices import get_spec

for device in devices:
deviceid = device["deviceid"]
did = device["deviceid"]
try:
device.update(self.config["devices"][deviceid])
device.update(self.config["devices"][did])
except Exception:
pass

uiid = device['extra']['uiid']
_LOGGER.debug(f"{deviceid} UIID {uiid:04} | %s", device["params"])
try:
uiid = device['extra']['uiid']
_LOGGER.debug(f"{did} UIID {uiid:04} | %s", device["params"])

spec = get_spec(device)
entities = [cls(self, device) for cls in spec]
self.dispatcher_send(SIGNAL_ADD_ENTITIES, entities)

spec = get_spec(device)
entities = [cls(self, device) for cls in spec]
self.dispatcher_send(SIGNAL_ADD_ENTITIES, entities)
self.devices[did] = device

self.devices[deviceid] = device
except Exception as e:
_LOGGER.warning(f"{did} !! can't setup device", exc_info=e)

async def stop(self, *args):
self.devices.clear()
Expand Down

0 comments on commit 4548671

Please sign in to comment.