Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions zigpy_deconz/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _missing_(cls, value):
Command.change_network_state: (t.uint8_t,),
Command.device_state: (t.uint8_t, t.uint8_t, t.uint8_t),
Command.read_parameter: (t.uint16_t, t.uint8_t, t.Bytes),
Command.version: (),
Command.version: (t.uint32_t,),
Command.write_parameter: (t.uint16_t, t.uint8_t, t.Bytes),
}

Expand Down Expand Up @@ -212,15 +212,21 @@ def __init__(self, app: Callable, device_config: Dict[str, Any]):
self._device_state = DeviceState(NetworkState.OFFLINE)
self._seq = 1
self._proto_ver: Optional[int] = None
self._firmware_version: Optional[int] = None
self._uart: Optional[zigpy_deconz.uart.Gateway] = None

@property
def firmware_version(self) -> Optional[int]:
"""Return ConBee firmware version."""
return self._firmware_version

@property
def network_state(self) -> NetworkState:
"""Return current network state."""
return self._device_state.network_state

@property
def protocol_version(self):
def protocol_version(self) -> Optional[int]:
"""Protocol Version."""
return self._proto_ver

Expand Down Expand Up @@ -418,13 +424,13 @@ def _handle_write_parameter(self, data):

async def version(self):
(self._proto_ver,) = await self[NetworkParameter.protocol_version]
version = await self._command(Command.version)
(self._firmware_version,) = await self._command(Command.version, 0)
if (
self.protocol_version >= MIN_PROTO_VERSION
and (version[0] & 0x0000FF00) == 0x00000500
and (self.firmware_version & 0x0000FF00) == 0x00000500
):
self._aps_data_ind_flags = 0x04
return version[0]
return self.firmware_version

def _handle_version(self, data):
LOGGER.debug("Version response: %x", data[0])
Expand Down