Skip to content

Commit

Permalink
Revert watchdog back to once every 7.5 minutes (#239)
Browse files Browse the repository at this point in the history
* Revert watchdog back to once every 7.5 minutes

* Ensure unit tests reflect commands that are now sent
  • Loading branch information
puddly authored Dec 13, 2023
1 parent 83872b1 commit 09cd1b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ async def test_reset_watchdog(app):
app._api.write_parameter = AsyncMock()

await app._watchdog_feed()
assert len(app._api.get_device_state.mock_calls) == 1
assert len(app._api.get_device_state.mock_calls) == 0
assert len(app._api.write_parameter.mock_calls) == 1

app._api.protocol_version = application.PROTO_VER_WATCHDOG - 1
Expand Down
8 changes: 5 additions & 3 deletions zigpy_deconz/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class ControllerApplication(zigpy.application.ControllerApplication):
{zigpy.config.CONF_DEVICE_BAUDRATE: 115200},
]

_watchdog_period = 600 * 0.75

def __init__(self, config: dict[str, Any]):
"""Initialize instance."""

Expand All @@ -78,15 +80,15 @@ def __init__(self, config: dict[str, Any]):
self._written_endpoints = set()

async def _watchdog_feed(self):
await self._api.get_device_state()

if self._api.protocol_version >= PROTO_VER_WATCHDOG and not (
self._api.firmware_version.platform == FirmwarePlatform.Conbee_III
and self._api.firmware_version <= 0x26450900
):
await self._api.write_parameter(
NetworkParameter.watchdog_ttl, int(2 * self._watchdog_period)
NetworkParameter.watchdog_ttl, int(self._watchdog_period / 0.75)
)
else:
await self._api.get_device_state()

async def connect(self):
api = Deconz(self, self._config[zigpy.config.CONF_DEVICE])
Expand Down

0 comments on commit 09cd1b3

Please sign in to comment.