Skip to content

Commit a181166

Browse files
committed
Implement StickInitShortResponse-handling in class StickController
1 parent 10b3119 commit a181166

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

plugwise_usb/connection/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
NodePingResponse,
2424
PlugwiseResponse,
2525
StickInitResponse,
26+
StickInitShortResponse,
2627
)
2728
from .manager import StickConnectionManager
2829
from .queue import StickQueue
@@ -172,7 +173,9 @@ async def initialize_stick(self) -> None:
172173

173174
try:
174175
request = StickInitRequest(self.send)
175-
init_response: StickInitResponse | None = await request.send()
176+
init_response: (
177+
StickInitResponse | StickInitShortResponse | None
178+
) = await request.send()
176179
except StickError as err:
177180
raise StickError(
178181
"No response from USB-Stick to initialization request."
@@ -188,10 +191,11 @@ async def initialize_stick(self) -> None:
188191
self._mac_stick = init_response.mac_decoded
189192
self.stick_name = f"Stick {self._mac_stick[-5:]}"
190193
self._network_online = init_response.network_online
194+
if self._network_online:
195+
# Replace first 2 characters by 00 for mac of circle+ node
196+
self._mac_nc = init_response.mac_network_controller
197+
self._network_id = init_response.network_id
191198

192-
# Replace first 2 characters by 00 for mac of circle+ node
193-
self._mac_nc = init_response.mac_network_controller
194-
self._network_id = init_response.network_id
195199
self._is_initialized = True
196200

197201
# Add Stick NodeInfoRequest
@@ -201,9 +205,6 @@ async def initialize_stick(self) -> None:
201205
hardware, _ = version_to_model(node_info.hardware)
202206
self._hw_stick = hardware
203207

204-
if not self._network_online:
205-
raise StickError("Zigbee network connection to Circle+ is down.")
206-
207208
async def pair_plus_device(self, mac: str) -> bool:
208209
"""Pair Plus-device to Plugwise Stick.
209210

0 commit comments

Comments
 (0)