Skip to content

Commit

Permalink
Initial support for the Conbee III
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Nov 10, 2023
1 parent e793bf8 commit e6c6543
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
17 changes: 17 additions & 0 deletions zigpy_deconz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class DeviceState(t.Struct):
class FirmwarePlatform(t.enum8):
Conbee = 0x05
Conbee_II = 0x07
Conbee_III = 0x09


class FirmwareVersion(t.Struct, t.uint32_t):
Expand Down Expand Up @@ -689,6 +690,21 @@ async def _data_poller(self):
status=rsp["status"], device_state=rsp["device_state"]
)

def _handle_device_state(
self,
status: t.Status,
device_state: DeviceState,
reserved1: t.uint8_t,
reserved2: t.uint8_t,
) -> None:
if (
self.firmware_version.platform == FirmwarePlatform.Conbee_III
and self.firmware_version == 0x26450900
):
# Initial firmware for the device accidentally used the `device_state`
# command instead of `device_state_changed` to indicate state changes
self._handle_device_state_changed(status=status, device_state=device_state)

def _handle_device_state_changed(
self,
status: t.Status,
Expand All @@ -704,6 +720,7 @@ def _handle_device_state_changed(

self._device_state = device_state
self._data_poller_event.set()
LOGGER.debug("Poking data poller")

if (
DeviceStateFlags.APSDE_DATA_REQUEST_FREE_SLOTS_AVAILABLE
Expand Down
14 changes: 12 additions & 2 deletions zigpy_deconz/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ async def change_loop():
" 2.4GHz routers, motherboards, etc."
)

if self._api.protocol_version < PROTO_VER_WATCHDOG:
if self._api.protocol_version < PROTO_VER_WATCHDOG or (
self._api.firmware_version.platform == FirmwarePlatform.Conbee_III
and self._api.firmware_version == 0x26450900
):
return

if self._reset_watchdog_task is not None:
Expand Down Expand Up @@ -286,6 +289,9 @@ async def write_network_info(self, *, network_info, node_info):
await self._change_network_state(NetworkState.CONNECTED)

async def load_network_info(self, *, load_devices=False):
if self._api.firmware_version.platform == FirmwarePlatform.Conbee_III:
await self._change_network_state(NetworkState.CONNECTED)

network_info = self.state.network_info
node_info = self.state.node_info

Expand Down Expand Up @@ -601,7 +607,11 @@ def __init__(self, version: FirmwareVersion, device_path: str, *args):
super().__init__(*args)
is_gpio_device = re.match(r"/dev/tty(S|AMA|ACM)\d+", device_path)
self._model = "RaspBee" if is_gpio_device else "ConBee"
self._model += " II" if version.platform == FirmwarePlatform.Conbee_II else ""
self._model += {
FirmwarePlatform.Conbee: "",
FirmwarePlatform.Conbee_II: " II",
FirmwarePlatform.Conbee_III: " III",
}[version.platform]

async def add_to_group(self, grp_id: int, name: str = None) -> None:
group = self.application.groups.add_group(grp_id, name)
Expand Down

0 comments on commit e6c6543

Please sign in to comment.