Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
196 commits
Select commit Hold shift + click to select a range
e842083
HOI debug
bouwew Apr 21, 2025
9f758d5
Full test-output
bouwew Apr 21, 2025
2015759
Call allow_join_request() via accept_join_request setter
bouwew Apr 21, 2025
7aaba03
Revert
bouwew Apr 21, 2025
ad0d3ec
Enable/disable automatic joining based on accept_join_request
bouwew Apr 21, 2025
b52e595
Limit sending allow_join_request()
bouwew Apr 21, 2025
b018792
Bump to a90
bouwew Apr 21, 2025
4224f07
Update _old_acc_join_req
bouwew Apr 21, 2025
dd57a00
Bump to a91
bouwew Apr 21, 2025
4aabdcc
Execute allow_join_requests() after network.is_running
bouwew Apr 21, 2025
d8e6748
Break out
bouwew Apr 22, 2025
e95494d
Execute allow_join_requests() with accept_join_request state being set
bouwew Apr 22, 2025
74df587
Clean up, add logger
bouwew Apr 22, 2025
324bac1
Bump to a92
bouwew Apr 22, 2025
10207b4
Handle async function-call properly
bouwew Apr 22, 2025
799a3e6
Correct syntax
bouwew Apr 22, 2025
abe6e62
Remove double code
bouwew Apr 22, 2025
e2267db
Try async setter construct
bouwew Apr 22, 2025
431e6a3
Fix testing
bouwew Apr 22, 2025
be61e3e
Try calling allow_join_requests via create_task()
bouwew Apr 22, 2025
c9bb411
Bump to a93
bouwew Apr 22, 2025
3f51f6b
Remove unused
bouwew Apr 23, 2025
2c7b1bb
Register node in node_join_available_message()
bouwew Apr 23, 2025
cd666f0
Bump to a94
bouwew Apr 23, 2025
0841fd6
Improve debug-message
bouwew Apr 23, 2025
50dc0b4
Add missing await
bouwew Apr 23, 2025
eb7593a
Bump to a95
bouwew Apr 23, 2025
b7ac5a1
Change debug-message
bouwew Apr 23, 2025
6131d93
Set asyncio_default_fixture_loop_scope to "session"
bouwew Apr 23, 2025
b657ad1
Update actions/* versions
bouwew Apr 23, 2025
6886d7e
More version-updates
bouwew Apr 23, 2025
ae8f0f2
Disable testcase
bouwew Apr 24, 2025
f46f008
Bump to a96
bouwew Apr 25, 2025
f22909f
Base NodeAddRequest on StickResponse
bouwew Apr 25, 2025
3e571fc
Add new found firmware version
bouwew Apr 25, 2025
a652f6c
Bump to a97
bouwew Apr 25, 2025
5c2eb79
Change max version to 2.5 for added firware
bouwew Apr 25, 2025
2913766
Bump to a98
bouwew Apr 25, 2025
53769ff
Correct corrected_pulses to 0 when negative
bouwew Apr 25, 2025
55d35da
Bump to a99
bouwew Apr 25, 2025
2865da0
Revert "Correct corrected_pulses to 0 when negative"
bouwew Apr 26, 2025
61fb618
Update __init__.py
bouwew May 1, 2025
380a354
Update connection-files
bouwew May 1, 2025
2d27c1a
Update messages files
bouwew May 1, 2025
6716707
Update network files
bouwew May 1, 2025
164f5ab
Update node-helper files
bouwew May 1, 2025
caaf0bc
Update test-files
bouwew May 1, 2025
9100cb6
Fix formatting
bouwew May 1, 2025
3cbfb90
Fix double logging
bouwew May 1, 2025
9e07186
Clean up
bouwew May 1, 2025
736ddb3
Update network-register_node fault handling
bouwew May 1, 2025
7b7a0a0
Back to normal test output
bouwew May 1, 2025
fc9e307
Set to latest a-version on testpypi
bouwew May 1, 2025
9cbc016
Revert back to standard uses: actions notation
bouwew May 1, 2025
45f481c
Fix typo
bouwew May 1, 2025
cc41fa1
Improve queue - submit()
bouwew May 1, 2025
5baeda3
Bump to a112
bouwew May 1, 2025
1ee8e13
Add CirclePlusAllowJoiningRequest with response to RESPONSE_MESSAGES
bouwew May 2, 2025
c9f7134
Alternative method of getting/setting accept_joiN_request
bouwew May 2, 2025
f8e210d
Test: move unneeded line
bouwew May 4, 2025
e2ffe88
Bump to a113
bouwew May 4, 2025
d5b0883
Update pyproject.toml - fix license
bouwew May 4, 2025
1a3ef23
Clean up packaging config
bouwew May 4, 2025
726aee7
Bump verify CACHE_VERSION
bouwew May 4, 2025
1bc3912
Update CODEOWNERS
bouwew May 4, 2025
fa5089e
pyproject corrections
bouwew May 4, 2025
c362969
Set setuptools to v80.3
bouwew May 4, 2025
c75bddb
Try v80.2
bouwew May 4, 2025
96d2b15
Hard-fix to v80.2.0
bouwew May 4, 2025
24a673c
Bump CACHE_VERSION
bouwew May 4, 2025
404b7ae
Force update
bouwew May 4, 2025
1df8429
Bump setuptools to v80.3.1
bouwew May 5, 2025
c121ca8
Guard subscribing to NODE_JOIN_ID
bouwew May 5, 2025
a6d9c4f
Clean up
bouwew May 5, 2025
70251be
Fix subscription-guarding
bouwew May 5, 2025
f272e62
Re-enable test_stick_node_join_subscription test case
bouwew May 5, 2025
229df24
Re-fix guarding
bouwew May 5, 2025
3997d0b
Revert "Re-enable test_stick_node_join_subscription test case"
bouwew May 5, 2025
6fe0240
Improve network.register_node()
bouwew May 5, 2025
1e226a2
Add NodeAddRequest with NodeJoinAckResponse
bouwew May 6, 2025
14e222a
Disable no_response_expected for NodeAddRequest
bouwew May 6, 2025
40d9b3f
Add back response-code to register_node()
bouwew May 6, 2025
650709f
Revert part of node_join_available_message() changes
bouwew May 6, 2025
9f9c8c6
Add NODE_REJOIN_ID indentifier and corresponding response
bouwew May 6, 2025
90f95ff
Enable test_stick_node_join_subscription test case
bouwew May 6, 2025
a68dcf5
Fixes
bouwew May 6, 2025
cf0a173
Don't check ack_id, might be not applicable
bouwew May 6, 2025
7328046
Bump to a114
bouwew May 6, 2025
fe36a36
Remove unused import
bouwew May 6, 2025
3d99942
Disable logger
bouwew May 6, 2025
f59bafa
Bump to a115
bouwew May 6, 2025
2359d9c
Walrus fix
bouwew May 6, 2025
c4c6ff7
Increase the node_response-timeout to 45 seconds
bouwew May 6, 2025
31b0c15
Create NodeResponseType REJOINING and use
bouwew May 7, 2025
89dc0b3
Import NodeResponseType
bouwew May 7, 2025
75ebdbb
Implement try-except for unregistering node
bouwew May 7, 2025
14bc897
Implement more try-excepts
bouwew May 7, 2025
5d22994
Add missing import
bouwew May 7, 2025
9f9e17c
Bump to a116
bouwew May 7, 2025
1efc2c3
Improve error-propagation
bouwew May 7, 2025
1017840
Bump to a117
bouwew May 7, 2025
c21b742
Handle last_address < first_address
bouwew May 8, 2025
3e3a5ad
Improve
bouwew May 8, 2025
345535f
Revert all no_node_response_expected changes
bouwew May 8, 2025
d5155d1
Fix NodeAddRequest response
bouwew May 8, 2025
bd55f07
Guard for 6015 to 1 address-rollover
bouwew May 8, 2025
f5953c1
Bump to a118
bouwew May 8, 2025
045f4e6
Don't guard in node_join_available_message()
bouwew May 10, 2025
eb9a315
Guard in register_node() instead
bouwew May 10, 2025
46e8b38
Bump to a119
bouwew May 10, 2025
27a6ec3
Make sure to return False
bouwew May 10, 2025
5ceb396
Remove unreachable code
bouwew May 10, 2025
c7eaf4e
Call register_node() in node_join_available_message()
bouwew May 10, 2025
56189ff
Disable test-code, fix seq_id
bouwew May 10, 2025
03eff66
Bump to a120
bouwew May 10, 2025
9860762
Fix log-message formatting
bouwew May 10, 2025
c52c9c3
Revert to async-original-like, add debug-logging to registry-register…
bouwew May 12, 2025
decd12b
Add more debug-logging
bouwew May 12, 2025
46e109c
Pylint fixes
bouwew May 12, 2025
b630104
Bump to a121
bouwew May 12, 2025
7e79a13
NodeAddRequest: change for testing
bouwew May 13, 2025
b8c5b4e
Also change register_node() for testing
bouwew May 13, 2025
3a0d8c3
Bump to a122
bouwew May 13, 2025
d59f550
Fix Priority class header
bouwew May 13, 2025
517c847
Set STICK_TIMEOUT to 30 secs
bouwew May 13, 2025
01f7bb6
Bump to a123
bouwew May 13, 2025
0cf0a70
Debug network_address()
bouwew May 13, 2025
e39c16f
Add missing "f"
bouwew May 13, 2025
ee14ebe
Fix typo
bouwew May 13, 2025
98e8445
Bump to a124
bouwew May 13, 2025
e90fa5d
Add register_rejoined_node() function
bouwew May 13, 2025
1050630
And implement
bouwew May 13, 2025
c516997
Bump to a125
bouwew May 14, 2025
5719970
Fix
bouwew May 14, 2025
b66cf22
Update debug-header message
bouwew May 14, 2025
f1d62c7
Revert STICK_TIMEOUT change
bouwew May 14, 2025
a430110
Improve register_node()
bouwew May 14, 2025
c23bd72
Improve unregister_node()
bouwew May 14, 2025
97bc022
Optimize: change function-name to update_node_registration
bouwew May 14, 2025
c1c509b
Increase timeouts for testing
bouwew May 14, 2025
73e9b41
Bump to a126
bouwew May 14, 2025
e723f7b
Add _reply_identifiler for NodeAddRequest
bouwew May 15, 2025
3e8f61b
NodeAddRequest: re-add responsetype-checking
bouwew May 15, 2025
54c8167
Remove unused constant
bouwew May 15, 2025
8b9851c
Bump to a127
bouwew May 15, 2025
5c234e4
Add noderesponse-type comments
bouwew May 15, 2025
1ac3c1a
Implement no_stick_response work-around for NodeAddRequest
bouwew May 15, 2025
4464af5
Fix ident
bouwew May 15, 2025
c32f80c
Add missing return
bouwew May 15, 2025
474c689
Bump to a128
bouwew May 15, 2025
873f4c2
Set retries to 6 for NodeAddRequest
bouwew May 16, 2025
a610c9f
Remove failing debug-logging, improve MessageError
bouwew May 16, 2025
a6e75c0
Bump to a129
bouwew May 16, 2025
05ce891
Pylint fix
bouwew May 16, 2025
91b0c9e
Revert timeout-changes
bouwew May 16, 2025
414da02
Simplify NodeAddRequest and adapt related
bouwew May 16, 2025
925152c
Remove unused imports
bouwew May 16, 2025
f422fd3
Bump to a130
bouwew May 16, 2025
687f758
Clean up all !r
bouwew May 17, 2025
0280d97
Revert blocking stick_response for NodeAddRequest
bouwew May 17, 2025
fd644b2
Bump to a132
bouwew May 17, 2025
8c82e9d
Revert NodeAddRequest related changes
bouwew May 17, 2025
283d7bf
Bump to a133
bouwew May 17, 2025
4e5c9e9
Improve debug message
bouwew May 18, 2025
823c6e4
Revert "Clean up all !r"
bouwew May 18, 2025
746526a
Revert 2 more !r removals
bouwew May 18, 2025
ec29b2e
Force response to prio-queue with nowait
bouwew May 18, 2025
ab18648
Bump to a134
bouwew May 18, 2025
0be676e
Improve debug-message
bouwew May 18, 2025
7ba67bb
Revert "Force response to prio-queue with nowait"
bouwew May 18, 2025
614bf4a
Fix logic for node_join_available_message() and node_rejoin_message()
bouwew May 18, 2025
f9ad56d
Add helper-comment
bouwew May 19, 2025
85cf9f2
Don't expect a node response for NodeAddRequest
bouwew May 19, 2025
e6c4837
Adapt related
bouwew May 19, 2025
155acec
Improve debug-message
bouwew May 19, 2025
7e09c7f
Adapt connection-sender for no response expected
bouwew May 19, 2025
208287a
Cleanup
bouwew May 19, 2025
9c234fc
Don't notify node_event_subscriber, will be done when the NodeRejoin …
bouwew May 19, 2025
e1d550e
Set NodeAddRequest _reply_identifier to None
bouwew May 19, 2025
81546b5
Bump to a135
bouwew May 19, 2025
7e61207
Revert use of None in subscribe to response
bouwew May 19, 2025
561737c
Bump to a136
bouwew May 19, 2025
d5bdd3d
Improve set_accept_join_request()
bouwew May 20, 2025
5ede18e
Bump to a137
bouwew May 20, 2025
9675d98
Fix
bouwew May 20, 2025
477b941
Revert NODE_TIMEOUT back to 15
bouwew May 20, 2025
3e76da2
Remove unused request-response pair
bouwew May 20, 2025
fe432e5
Make sure to set accept_join_request
bouwew May 20, 2025
0a9e058
Bump to a138
bouwew May 20, 2025
d06fc9d
Output bool from set_accept_join_request()
bouwew May 21, 2025
986c5a7
Bump to a139
bouwew May 21, 2025
160a61a
Update_node_registration() should not be async
bouwew May 21, 2025
6487b2a
Bump to a140
bouwew May 21, 2025
1c60120
NodeAddRequest: return to default retrying
bouwew May 22, 2025
32ee964
Add fault-handling in registry-register_node()
bouwew May 22, 2025
59b8742
Bump to a141
bouwew May 22, 2025
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
24 changes: 12 additions & 12 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name: Latest commit

env:
CACHE_VERSION: 22
CACHE_VERSION: 24
DEFAULT_PYTHON: "3.13"
PRE_COMMIT_HOME: ~/.cache/pre-commit

Expand All @@ -22,7 +22,7 @@ jobs:
name: Prepare
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
needs: prepare
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
- dependencies_check
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -175,7 +175,7 @@ jobs:
python-version: ["3.13"]
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -215,7 +215,7 @@ jobs:

steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -253,7 +253,7 @@ jobs:
needs: pytest
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
Expand Down Expand Up @@ -293,7 +293,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

Expand All @@ -303,7 +303,7 @@ jobs:
name: Dependency
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Run dependency checker
run: scripts/dependencies_check.sh debug

Expand All @@ -313,7 +313,7 @@ jobs:
needs: pytest
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -358,7 +358,7 @@ jobs:
needs: [coverage, mypy]
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
Expand Down Expand Up @@ -401,7 +401,7 @@ jobs:
needs: coverage
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@v4
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
Expand Down
4 changes: 1 addition & 3 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@

# Specific files
setup.cfg @plugwise/plugwise-usb
setup.py @plugwise/plugwise-usb
pyproject.toml @plugwise/plugwise-usb
requirements*.txt @plugwise/plugwise-usb

# Main code
/plugwise/ @plugwise/plugwise-usb
/userdata/ @plugwise/plugwise-usb
/plugwise_usb/ @plugwise/plugwise-usb

# Tests and development support
/tests/ @plugwise/plugwise-usb
Expand Down
26 changes: 20 additions & 6 deletions plugwise_usb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from .api import NodeEvent, PlugwiseNode, StickEvent
from .connection import StickController
from .exceptions import StickError, SubscriptionError
from .exceptions import MessageError, NodeError, StickError, SubscriptionError
from .network import StickNetwork

FuncT = TypeVar("FuncT", bound=Callable[..., Any])
Expand Down Expand Up @@ -190,20 +190,27 @@
return None
return self._network.accept_join_request

@accept_join_request.setter
def accept_join_request(self, state: bool) -> None:
async def set_accept_join_request(self, state: bool) -> bool:
"""Configure join request setting."""
if not self._controller.is_connected:
raise StickError(
"Cannot accept joining node"
+ " without an active USB-Stick connection."
)

if self._network is None or not self._network.is_running:
raise StickError(
"Cannot accept joining node"
+ "without node discovery be activated. Call discover() first."
)
self._network.accept_join_request = state

# Observation: joining is only temporarily possible after a HA (re)start or
# Integration reload, force the setting when used otherwise
try:
await self._network.allow_join_requests(state)
except (MessageError, NodeError) as exc:
raise NodeError(f"Failed setting accept joining: {exc}") from exc

Check warning on line 212 in plugwise_usb/__init__.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/__init__.py#L211-L212

Added lines #L211 - L212 were not covered by tests
return True

async def clear_cache(self) -> None:
"""Clear current cache."""
Expand Down Expand Up @@ -347,15 +354,22 @@
"""Add node to plugwise network."""
if self._network is None:
return False
return await self._network.register_node(mac)

try:
return await self._network.register_node(mac)
except NodeError as exc:
raise NodeError(f"Unable to add Node ({mac}): {exc}") from exc

Check warning on line 361 in plugwise_usb/__init__.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/__init__.py#L358-L361

Added lines #L358 - L361 were not covered by tests

@raise_not_connected
@raise_not_initialized
async def unregister_node(self, mac: str) -> None:
"""Remove node to plugwise network."""
if self._network is None:
return
await self._network.unregister_node(mac)
try:
await self._network.unregister_node(mac)
except MessageError as exc:
raise NodeError(f"Unable to remove Node ({mac}): {exc}") from exc

Check warning on line 372 in plugwise_usb/__init__.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/__init__.py#L369-L372

Added lines #L369 - L372 were not covered by tests

async def disconnect(self) -> None:
"""Disconnect from USB-Stick."""
Expand Down
6 changes: 4 additions & 2 deletions plugwise_usb/connection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ async def get_node_details(
self.send, bytes(mac, UTF8), retries=1
)
try:
ping_response = await ping_request.send(suppress_node_errors=True)
ping_response = await ping_request.send()
except StickError:
return (None, None)
if ping_response is None:
Expand All @@ -230,7 +230,9 @@ async def get_node_details(
return (info_response, ping_response)

async def send(
self, request: PlugwiseRequest, suppress_node_errors: bool = True
self,
request: PlugwiseRequest,
suppress_node_errors=True,
) -> PlugwiseResponse | None:
"""Submit request to queue and return response."""
if not suppress_node_errors:
Expand Down
31 changes: 19 additions & 12 deletions plugwise_usb/connection/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,46 +75,53 @@
_LOGGER.debug("queue stopped")

async def submit(self, request: PlugwiseRequest) -> PlugwiseResponse | None:
"""Add request to queue and return the response of node. Raises an error when something fails."""
"""Add request to queue and return the received node-response when applicable.

Raises an error when something fails.
"""
if request.waiting_for_response:
raise MessageError(
f"Cannot send message {request} which is currently waiting for response."
)

while request.resend and not request.waiting_for_response:
while request.resend:
_LOGGER.debug("submit | start (%s) %s", request.retries_left, request)
if not self._running or self._stick is None:
raise StickError(
f"Cannot send message {request.__class__.__name__} for"
+ f"{request.mac_decoded} because queue manager is stopped"
)

await self._add_request_to_queue(request)
if request.no_response:
return None

Check warning on line 97 in plugwise_usb/connection/queue.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/connection/queue.py#L97

Added line #L97 was not covered by tests

try:
response: PlugwiseResponse = await request.response_future()
return response
except (NodeTimeout, StickTimeout) as e:
except (NodeTimeout, StickTimeout) as exc:
if isinstance(request, NodePingRequest):
# For ping requests it is expected to receive timeouts, so lower log level
_LOGGER.debug(
"%s, cancel because timeout is expected for NodePingRequests", e
"%s, cancel because timeout is expected for NodePingRequests", exc
)
elif request.resend:
_LOGGER.debug("%s, retrying", e)
_LOGGER.debug("%s, retrying", exc)

Check warning on line 109 in plugwise_usb/connection/queue.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/connection/queue.py#L109

Added line #L109 was not covered by tests
else:
_LOGGER.warning("%s, cancel request", e) # type: ignore[unreachable]
except StickError as exception:
_LOGGER.error(exception)
_LOGGER.warning("%s, cancel request", exc) # type: ignore[unreachable]

Check warning on line 111 in plugwise_usb/connection/queue.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/connection/queue.py#L111

Added line #L111 was not covered by tests
except StickError as exc:
_LOGGER.error(exc)

Check warning on line 113 in plugwise_usb/connection/queue.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/connection/queue.py#L113

Added line #L113 was not covered by tests
self._stick.correct_received_messages(1)
raise StickError(
f"No response received for {request.__class__.__name__} "
+ f"to {request.mac_decoded}"
) from exception
except BaseException as exception:
) from exc
except BaseException as exc:
self._stick.correct_received_messages(1)
raise StickError(
f"No response received for {request.__class__.__name__} "
+ f"to {request.mac_decoded}"
) from exception
) from exc

return None

Expand All @@ -132,7 +139,7 @@
_LOGGER.debug("Send_queue_worker started")
while self._running and self._stick is not None:
request = await self._submit_queue.get()
_LOGGER.debug("Send from send queue %s", request)
_LOGGER.debug("Sending from send queue %s", request)
if request.priority == Priority.CANCEL:
self._submit_queue.task_done()
return
Expand Down
3 changes: 2 additions & 1 deletion plugwise_usb/connection/receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ async def _put_message_in_queue(
_LOGGER.debug("Add response to queue: %s", response)
await self._message_queue.put(response)
if self._message_worker_task is None or self._message_worker_task.done():
_LOGGER.debug("Queue: start new worker-task")
self._message_worker_task = self._loop.create_task(
self._message_queue_worker(),
name="Plugwise message receiver queue worker",
Expand All @@ -281,6 +282,7 @@ async def _message_queue_worker(self) -> None:
_LOGGER.debug("Message queue worker started")
while self.is_connected:
response: PlugwiseResponse = await self._message_queue.get()
_LOGGER.debug("Priority: %s", response.priority)
if response.priority == Priority.CANCEL:
self._message_queue.task_done()
return
Expand Down Expand Up @@ -511,5 +513,4 @@ async def _notify_node_response_subscribers(
name=f"Postpone subscription task for {node_response.seq_id!r} retry {node_response.retries}",
)


# endregion
8 changes: 5 additions & 3 deletions plugwise_usb/connection/sender.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ async def write_request_to_port(self, request: PlugwiseRequest) -> None:
self._stick_response = self._loop.create_future()

request.add_send_attempt()
_LOGGER.info("Send %s", request)
_LOGGER.info("Sending %s", request)

# Write message to serial port buffer
serialized_data = request.serialize()
_LOGGER.debug("write_request_to_port | Write %s to port as %s", request, serialized_data)
self._transport.write(serialized_data)
request.start_response_timeout()
# Don't timeout when no response expected
if not request.no_response:
request.start_response_timeout()

# Wait for USB stick to accept request
try:
Expand Down Expand Up @@ -118,7 +120,7 @@ async def write_request_to_port(self, request: PlugwiseRequest) -> None:
self._receiver.subscribe_to_stick_responses,
self._receiver.subscribe_to_node_responses,
)
_LOGGER.debug("write_request_to_port | request has subscribed : %s", request)
_LOGGER.debug("write_request_to_port | request has subscribed : %s", request)
elif response.response_type == StickResponseType.TIMEOUT:
_LOGGER.warning(
"USB-Stick directly responded with communication timeout for %s",
Expand Down
7 changes: 5 additions & 2 deletions plugwise_usb/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
MESSAGE_HEADER: Final = b"\x05\x05\x03\x03"

# Max timeout in seconds
STICK_TIME_OUT: Final = 11 # Stick responds with timeout messages within 10s.
NODE_TIME_OUT: Final = 15 # In bigger networks a response from a node could take up a while, so lets use 15 seconds.
# Stick responds with timeout messages within 10s.
STICK_TIME_OUT: Final = 11
# In bigger networks a response from a Node could take up a while, so lets use 15 seconds.
NODE_TIME_OUT: Final = 15

MAX_RETRIES: Final = 3
SUPPRESS_INITIALIZATION_WARNINGS: Final = 10 # Minutes to suppress (expected) communication warning messages after initialization

Expand Down
2 changes: 1 addition & 1 deletion plugwise_usb/messages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ..helpers.util import crc_fun


class Priority(int, Enum):
class Priority(Enum):
"""Message priority levels for USB-stick message requests."""

CANCEL = 0
Expand Down
Loading
Loading