Skip to content

Commit 6ad61d4

Browse files
authored
Merge pull request #333 from plugwise/mdi_nodeinfologic
Improve node_info_update and update_node_details logic
2 parents 0698cce + 1d23f0b commit 6ad61d4

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## ongoing
4+
5+
- PR [333](https://github.com/plugwise/python-plugwise-usb/pull/333): Improve node_info_update and update_node_details logic
6+
37
## 0.45.0 - 2025-09-03
48

59
- PR [330](https://github.com/plugwise/python-plugwise-usb/pull/330): Add sense hysteresis based switch action

plugwise_usb/nodes/circle.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,39 +1033,39 @@ async def node_info_update(
10331033
return None
10341034

10351035
await super().node_info_update(node_info)
1036-
await self._relay_update_state(
1037-
node_info.relay_state, timestamp=node_info.timestamp
1038-
)
1039-
if self._current_log_address is not None and (
1040-
self._current_log_address > node_info.current_logaddress_pointer
1041-
or self._current_log_address == 1
1042-
):
1043-
# Rollover of log address
1044-
_LOGGER.debug(
1045-
"Rollover log address from %s into %s for node %s",
1046-
self._current_log_address,
1047-
node_info.current_logaddress_pointer,
1048-
self._mac_in_str,
1049-
)
1050-
1051-
if self._current_log_address != node_info.current_logaddress_pointer:
1052-
self._current_log_address = node_info.current_logaddress_pointer
10531036

10541037
return self._node_info
10551038

10561039
# pylint: disable=too-many-arguments
10571040
async def update_node_details(
1058-
self, node_info: NodeInfoResponse | None = None
1041+
self, node_info: NodeInfoResponse | NodeInfoMessage | None = None
10591042
) -> bool:
10601043
"""Process new node info and return true if all fields are updated."""
1044+
if node_info is None:
1045+
return False
1046+
10611047
if node_info.relay_state is not None:
1062-
self._relay_state = replace(
1063-
self._relay_state,
1064-
state=node_info.relay_state,
1065-
timestamp=node_info.timestamp,
1048+
await self._relay_update_state(
1049+
node_info.relay_state, timestamp=node_info.timestamp
1050+
)
1051+
1052+
if (
1053+
node_info.current_logaddress_pointer is not None
1054+
and self._current_log_address is not None
1055+
and self._current_log_address > node_info.current_logaddress_pointer
1056+
):
1057+
# Rollover of log address
1058+
_LOGGER.debug(
1059+
"Rollover log address from %s to %s for node %s",
1060+
self._current_log_address,
1061+
node_info.current_logaddress_pointer,
1062+
self._mac_in_str,
10661063
)
10671064

1068-
if node_info.current_logaddress_pointer is not None:
1065+
if (
1066+
node_info.current_logaddress_pointer is not None
1067+
and node_info.current_logaddress_pointer != self._current_log_address
1068+
):
10691069
self._current_log_address = node_info.current_logaddress_pointer
10701070

10711071
return await super().update_node_details(node_info)

0 commit comments

Comments
 (0)