Skip to content

Commit 521e425

Browse files
authored
Properly disconnect on connection failure (#161)
1 parent eb4d141 commit 521e425

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

zigpy_zigate/zigbee/application.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,16 @@ async def _watchdog_feed(self):
4141

4242
async def connect(self):
4343
api = await ZiGate.new(self._config[zigpy.config.CONF_DEVICE], self)
44-
await api.set_raw_mode()
45-
await api.set_time()
4644

47-
(_, version), lqi = await api.version()
45+
try:
46+
await api.set_raw_mode()
47+
await api.set_time()
48+
49+
(_, version), lqi = await api.version()
50+
except Exception:
51+
await api.disconnect()
52+
raise
53+
4854
major, minor = version.to_bytes(2, "big")
4955
self.version = f"{major:x}.{minor:x}"
5056

0 commit comments

Comments
 (0)