Skip to content

Commit 154a097

Browse files
committed
Revert all no_node_response_expected changes
1 parent 3e3a5ad commit 154a097

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

plugwise_usb/connection/queue.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ async def submit(self, request: PlugwiseRequest) -> PlugwiseResponse | None:
9494

9595
await self._add_request_to_queue(request)
9696
try:
97-
if not request.node_response_expected:
98-
return None
9997
response: PlugwiseResponse = await request.response_future()
10098
return response
10199
except (NodeTimeout, StickTimeout) as exc:

plugwise_usb/connection/sender.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ async def write_request_to_port(self, request: PlugwiseRequest) -> None:
8181
serialized_data = request.serialize()
8282
_LOGGER.debug("write_request_to_port | Write %s to port as %s", request, serialized_data)
8383
self._transport.write(serialized_data)
84-
if request.node_response_expected:
85-
request.start_response_timeout()
84+
request.start_response_timeout()
8685

8786
# Wait for USB stick to accept request
8887
try:

plugwise_usb/messages/requests.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ def __init__(
6868
send_fn: Callable[[PlugwiseRequest, bool], Awaitable[PlugwiseResponse | None]]
6969
| None,
7070
mac: bytes | None,
71-
node_response=True,
7271
) -> None:
7372
"""Initialize request message."""
7473
super().__init__()
@@ -105,12 +104,9 @@ def __init__(
105104
self._unsubscribe_stick_response: Callable[[], None] | None = None
106105
self._unsubscribe_node_response: Callable[[], None] | None = None
107106
self._response_timeout: TimerHandle | None = None
108-
self._response_future: Future[PlugwiseResponse] | None = None
109-
if node_response:
110-
self._response_future = self._loop.create_future()
107+
self._response_future: Future[PlugwiseResponse] = self._loop.create_future()
111108
self._waiting_for_response = False
112109

113-
self.node_response_expected: bool = node_response
114110

115111
def __repr__(self) -> str:
116112
"""Convert request into writable str."""
@@ -176,13 +172,12 @@ async def subscribe_to_response(
176172
self._unsubscribe_stick_response = await stick_subscription_fn(
177173
self._process_stick_response, self._seq_id, None
178174
)
179-
if self.node_response_expected:
180-
self._unsubscribe_node_response = await node_subscription_fn(
181-
self.process_node_response,
182-
self._mac,
183-
(self._reply_identifier,),
184-
self._seq_id,
185-
)
175+
self._unsubscribe_node_response = await node_subscription_fn(
176+
self.process_node_response,
177+
self._mac,
178+
(self._reply_identifier,),
179+
self._seq_id,
180+
)
186181

187182
def _unsubscribe_from_stick(self) -> None:
188183
"""Unsubscribe from StickResponse messages."""
@@ -227,8 +222,7 @@ def _response_timeout_expired(self, stick_timeout: bool = False) -> None:
227222
)
228223
self._seq_id = None
229224
self._unsubscribe_from_stick()
230-
if self.node_response_expected:
231-
self._unsubscribe_from_node()
225+
self._unsubscribe_from_node()
232226
if stick_timeout:
233227
self._response_future.set_exception(
234228
StickTimeout(f"USB-stick responded with time out to {self}")
@@ -244,8 +238,7 @@ def assign_error(self, error: BaseException) -> None:
244238
"""Assign error for this request."""
245239
self.stop_response_timeout()
246240
self._unsubscribe_from_stick()
247-
if self.node_response_expected:
248-
self._unsubscribe_from_node()
241+
self._unsubscribe_from_node()
249242
if self._response_future.done():
250243
return
251244
self._waiting_for_response = False
@@ -274,8 +267,7 @@ async def process_node_response(self, response: PlugwiseResponse) -> bool:
274267
self._response = copy(response)
275268
self.stop_response_timeout()
276269
self._unsubscribe_from_stick()
277-
if self.node_response_expected:
278-
self._unsubscribe_from_node()
270+
self._unsubscribe_from_node()
279271
if self._send_counter > 1:
280272
_LOGGER.debug(
281273
"Received %s after %s retries as reply to %s",

0 commit comments

Comments
 (0)