Skip to content

Commit

Permalink
Merge pull request #199 from puddly/rc
Browse files Browse the repository at this point in the history
0.18.0 Release
  • Loading branch information
puddly authored Jun 27, 2022
2 parents 6f9b0bf + f092729 commit f236e8d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
13 changes: 5 additions & 8 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,12 @@ async def test_start_network(app, proto_ver, nwk_state, error):
with patch.object(application.DeconzDevice, "initialize", AsyncMock()):
await app.start_network()
assert app.load_network_info.await_count == 1
assert app._change_network_state.await_count == 1

if nwk_state != deconz_api.NetworkState.CONNECTED:
assert app._change_network_state.await_count == 1
assert (
app._change_network_state.await_args_list[0][0][0]
== deconz_api.NetworkState.CONNECTED
)
else:
assert app._change_network_state.await_count == 0
assert (
app._change_network_state.await_args_list[0][0][0]
== deconz_api.NetworkState.CONNECTED
)

if proto_ver >= application.PROTO_VER_NEIGBOURS:
assert app.restore_neighbours.await_count == 1
Expand Down
2 changes: 1 addition & 1 deletion zigpy_deconz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# coding: utf-8
MAJOR_VERSION = 0
MINOR_VERSION = 17
MINOR_VERSION = 18
PATCH_VERSION = "0"
__short_version__ = f"{MAJOR_VERSION}.{MINOR_VERSION}"
__version__ = f"{__short_version__}.{PATCH_VERSION}"
26 changes: 8 additions & 18 deletions zigpy_deconz/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ async def _reset_watchdog(self):
await self._api.write_parameter(
NetworkParameter.watchdog_ttl, self._config[CONF_WATCHDOG_TTL]
)
except (asyncio.TimeoutError, zigpy.exceptions.ZigbeeException):
LOGGER.warning("No watchdog response")
except Exception as e:
LOGGER.warning("Failed to reset watchdog", exc_info=e)

await asyncio.sleep(self._config[CONF_WATCHDOG_TTL] * 0.75)

async def connect(self):
Expand All @@ -95,15 +96,7 @@ async def disconnect(self):
if self._reset_watchdog_task is not None:
self._reset_watchdog_task.cancel()

if self._api is None:
return

try:
if self._api.protocol_version >= PROTO_VER_WATCHDOG:
await self._api.write_parameter(NetworkParameter.watchdog_ttl, 1)
except zigpy_deconz.exception.CommandError:
pass
finally:
if self._api is not None:
self._api.close()

async def permit_with_key(self, node: t.EUI64, code: bytes, time_s=60):
Expand All @@ -113,13 +106,10 @@ async def start_network(self):
await self.register_endpoints()
await self.load_network_info(load_devices=False)

device_state, _, _ = await self._api.device_state()

if device_state.network_state != NetworkState.CONNECTED:
try:
await self._change_network_state(NetworkState.CONNECTED)
except asyncio.TimeoutError as e:
raise FormationFailure() from e
try:
await self._change_network_state(NetworkState.CONNECTED)
except asyncio.TimeoutError as e:
raise FormationFailure() from e

coordinator = await DeconzDevice.new(
self,
Expand Down

0 comments on commit f236e8d

Please sign in to comment.