Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 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
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
4 changes: 2 additions & 2 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
if: github.event.pull_request.merged == true
steps:
- name: Check out committed code
uses: actions/checkout@v4
uses: actions/checkout@v4.2.2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Install pypa/build
Expand Down
68 changes: 34 additions & 34 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ jobs:
name: Prepare
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand All @@ -52,7 +52,7 @@ jobs:
pip install -r requirements_test.txt -r requirements_commit.txt
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: |
Expand All @@ -71,17 +71,17 @@ jobs:
needs: prepare
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
with:
persist-credentials: false
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand Down Expand Up @@ -124,15 +124,15 @@ jobs:
- dependencies_check
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand All @@ -147,7 +147,7 @@ jobs:
exit 1
- name: Restore pre-commit environment from cache
id: cache-precommit
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: ${{ env.PRE_COMMIT_HOME }}
key: |
Expand Down Expand Up @@ -175,15 +175,15 @@ jobs:
python-version: ["3.13"]
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ matrix.python-version }}
- name: Restore full Python ${{ matrix.python-version }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand Down Expand Up @@ -215,15 +215,15 @@ jobs:

steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
- name: Set up Python ${{ matrix.python-version }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ matrix.python-version }}
- name: Restore full Python ${{ matrix.python-version }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand All @@ -240,7 +240,7 @@ jobs:
. venv/bin/activate
pytest --log-level info tests/*.py --cov='.'
- name: Upload coverage artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v4.6.2
with:
name: coverage-${{ matrix.python-version }}
path: .coverage
Expand All @@ -253,17 +253,17 @@ jobs:
needs: pytest
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
with:
persist-credentials: false
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
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@4.2.2
- 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@4.2.2
- name: Run dependency checker
run: scripts/dependencies_check.sh debug

Expand All @@ -313,15 +313,15 @@ jobs:
needs: pytest
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand All @@ -335,7 +335,7 @@ jobs:
echo "Failed to restore Python virtual environment from cache"
exit 1
- name: Download all coverage artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v4.2.1
- name: Combine coverage results
run: |
. venv/bin/activate
Expand All @@ -348,7 +348,7 @@ jobs:
echo "***"
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
uses: codecov/codecov-action@v5.4.2
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand All @@ -358,15 +358,15 @@ jobs:
needs: [coverage, mypy]
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand Down Expand Up @@ -401,15 +401,15 @@ jobs:
needs: coverage
steps:
- name: Check out committed code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
uses: actions/checkout@4.2.2
- name: Set up Python ${{ env.DEFAULT_PYTHON }}
id: python
uses: actions/setup-python@v5
uses: actions/setup-python@v5.5.0
with:
python-version: ${{ env.DEFAULT_PYTHON }}
- name: Restore base Python ${{ env.DEFAULT_PYTHON }} virtual environment
id: cache-venv
uses: actions/cache@v4
uses: actions/cache@v4.2.3
with:
path: venv
key: >-
Expand Down
5 changes: 4 additions & 1 deletion plugwise_usb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from __future__ import annotations

from asyncio import get_running_loop
from asyncio import create_task, get_running_loop
from collections.abc import Callable, Coroutine
from functools import wraps
import logging
Expand Down Expand Up @@ -198,12 +198,15 @@ def accept_join_request(self, state: bool) -> None:
"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
_ = create_task(self._network.allow_join_requests(state))

async def clear_cache(self) -> None:
"""Clear current cache."""
Expand Down
10 changes: 5 additions & 5 deletions plugwise_usb/messages/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,13 @@
return MESSAGE_HEADER + msg + checksum + MESSAGE_FOOTER


class PlugwiseRequestWithNodeAckResponse(PlugwiseRequest):
class PlugwiseRequestWithStickResponse(PlugwiseRequest):
"""Base class of a plugwise request with a NodeAckResponse."""

async def send(self, suppress_node_errors: bool = False) -> NodeAckResponse | None:
async def send(self, suppress_node_errors: bool = False) -> StickResponse | None:
"""Send request."""
result = await self._send_request(suppress_node_errors)
if isinstance(result, NodeAckResponse):
if isinstance(result, StickResponse):

Check warning on line 418 in plugwise_usb/messages/requests.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/messages/requests.py#L418

Added line #L418 was not covered by tests
return result
if result is None:
return None
Expand All @@ -424,15 +424,15 @@
)


class NodeAddRequest(PlugwiseRequestWithNodeAckResponse):
class NodeAddRequest(PlugwiseRequestWithStickResponse):
"""Add node to the Plugwise Network and add it to memory of Circle+ node.

Supported protocols : 1.0, 2.0
Response message : TODO check if response is NodeAckResponse
"""

_identifier = b"0007"
_reply_identifier = b"0005"
_reply_identifier = b"0000" #"0005"

def __init__(
self,
Expand Down
15 changes: 12 additions & 3 deletions plugwise_usb/network/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,12 @@
f"Invalid response message type ({response.__class__.__name__}) received, expected NodeJoinAvailableResponse"
)
mac = response.mac_decoded
await self._notify_node_event_subscribers(NodeEvent.JOIN, mac)
return True
if await self.register_node(mac):
await self._notify_node_event_subscribers(NodeEvent.JOIN, mac)
return True

Check warning on line 252 in plugwise_usb/network/__init__.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/network/__init__.py#L250-L252

Added lines #L250 - L252 were not covered by tests

_LOGGER.debug("Joining of available Node %s failed", mac)
return False

Check warning on line 255 in plugwise_usb/network/__init__.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/network/__init__.py#L254-L255

Added lines #L254 - L255 were not covered by tests

async def node_rejoin_message(self, response: PlugwiseResponse) -> bool:
"""Handle NodeRejoinResponse messages."""
Expand Down Expand Up @@ -319,6 +323,7 @@
if load:
return await self._load_node(self._controller.mac_coordinator)
return True

return False

# endregion
Expand Down Expand Up @@ -485,9 +490,11 @@
await self.discover_network_coordinator(load=load)
if not self._is_running:
await self.start()

await self._discover_registered_nodes()
if load:
return await self._load_discovered_nodes()

return True

async def stop(self) -> None:
Expand All @@ -507,14 +514,16 @@
async def allow_join_requests(self, state: bool) -> None:
"""Enable or disable Plugwise network."""
request = CirclePlusAllowJoiningRequest(self._controller.send, state)
response = await request.send()
if (response := await request.send()) is None:
raise NodeError("No response to get notifications for join request.")

if response.response_type != NodeResponseType.JOIN_ACCEPTED:
raise MessageError(
f"Unknown NodeResponseType '{response.response_type.name}' received"
)

_LOGGER.debug("Send AllowJoiningRequest to Circle+ with state=%s", state)

Check warning on line 525 in plugwise_usb/network/__init__.py

View check run for this annotation

Codecov / codecov/patch

plugwise_usb/network/__init__.py#L525

Added line #L525 was not covered by tests

def subscribe_to_node_events(
self,
node_event_callback: Callable[[NodeEvent, str], Coroutine[Any, Any, None]],
Expand Down
1 change: 1 addition & 0 deletions plugwise_usb/nodes/helpers/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SupportedVersions(NamedTuple):
# Proto release
datetime(2015, 6, 16, 21, 9, 10, tzinfo=UTC): SupportedVersions(min=2.0, max=2.6),
datetime(2015, 6, 18, 14, 0, 54, tzinfo=UTC): SupportedVersions(min=2.0, max=2.6),
datetime(2015, 9, 18, 8, 53, 15, tzinfo=UTC): SupportedVersions(min=2.0, max=2.5),
# New Flash Update
datetime(2017, 7, 11, 16, 6, 59, tzinfo=UTC): SupportedVersions(min=2.0, max=2.6),
}
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "plugwise_usb"
version = "v0.40.0b1"
version = "v0.40.0a99"
keywords = ["home", "automation", "plugwise", "module", "usb"]
classifiers = [
"Development Status :: 5 - Production/Stable",
Expand Down Expand Up @@ -170,6 +170,7 @@ overgeneral-exceptions = [
]

[tool.pytest.ini_options]
asyncio_default_fixture_loop_scope = "session"
asyncio_mode = "strict"
markers = [
# mark a test as a asynchronous io test.
Expand Down
3 changes: 2 additions & 1 deletion scripts/tests_and_coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ set +u

if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "test_and_coverage" ] ; then
# Python tests (rerun with debug if failures)
PYTHONPATH=$(pwd) pytest -qx tests/ --cov='.' --no-cov-on-fail --cov-report term-missing || PYTHONPATH=$(pwd) pytest -xrpP --log-level debug tests/
#PYTHONPATH=$(pwd) pytest -qx tests/ --cov='.' --no-cov-on-fail --cov-report term-missing ||
PYTHONPATH=$(pwd) pytest -xrpP --log-level debug tests/
fi

if [ -z "${GITHUB_ACTIONS}" ] || [ "$1" == "linting" ] ; then
Expand Down
Loading
Loading