Skip to content

Commit 5f6f208

Browse files
committed
Add plus_pair_request function
1 parent cc6dd34 commit 5f6f208

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

plugwise_usb/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,14 @@ def port(self, port: str) -> None:
176176

177177
self._port = port
178178

179+
async def plus_pair_request(self, mac: str) -> bool:
180+
"""Send a pair request to a Plus device."""
181+
try:
182+
await self._network.pair_plus_device(mac)
183+
except NodeError as exc:
184+
raise NodeError(f"{exc}") from exc
185+
return True
186+
179187
async def set_energy_intervals(
180188
self, mac: str, cons_interval: int, prod_interval: int
181189
) -> bool:

plugwise_usb/network/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,21 @@ def registry(self) -> list[str]:
152152

153153
# endregion
154154

155+
aync def pair_plus_device(self, mac: str) -> bool:
156+
"""Register node to Plugwise network."""
157+
_LOGGER.debug("Pair Plus-device with mac: %s", mac)
158+
if not validate_mac(mac):
159+
raise NodeError(f"MAC {mac} invalid")
160+
161+
request = CirclePlusConnectRequest(self._controller.send, bytes(mac, UTF8))
162+
if (response := await request.send()) is None:
163+
raise NodeError("No response for CirclePlusConnectRequest.")
164+
165+
# how do we check for a succesfull pairing?
166+
# there should be a 0005 wxyz 0001 response
167+
# followed by a StickInitResponse (0011)?
168+
169+
155170
async def register_node(self, mac: str) -> bool:
156171
"""Register node to Plugwise network."""
157172
try:

0 commit comments

Comments
 (0)