Skip to content

Commit fc94f15

Browse files
authored
Merge pull request #255 from plugwise/clear-cache
Improve enery-logs reset process, enable use of a button in plugwise_usb beta
2 parents 8a47da2 + a7753c1 commit fc94f15

File tree

12 files changed

+270
-120
lines changed

12 files changed

+270
-120
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __pycache__
99
.idea
1010
tests/__pycache__
1111
.coverage
12+
.python-version
1213
.vscode
1314
venv
1415
.venv

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22

3-
## Ongoing
3+
## v0.44.4
44

5+
- PR [#255](https://github.com/plugwise/python-plugwise-usb/pull/255): Improve enery-logs reset process, enable use of a button in Plugwise_usb beta
56
- PR [#261](https://github.com/plugwise/python-plugwise-usb/pull/261): Sense: bugfix parsing of humidity value as an unsigned int
67
- PR #263 Maintenance chores and re-instatement of ruff, deprecate pre-commit cloud runs (just leveraging renovate)
78
- PR #264 Maintenance chores Rework Github Actions workflow

plugwise_usb/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from .api import NodeEvent, PlugwiseNode, StickEvent
1616
from .connection import StickController
17-
from .constants import DEFAULT_CONS_INTERVAL, NO_PRODUCTION_INTERVAL
1817
from .exceptions import MessageError, NodeError, StickError, SubscriptionError
1918
from .network import StickNetwork
2019

@@ -177,22 +176,6 @@ def port(self, port: str) -> None:
177176

178177
self._port = port
179178

180-
async def energy_reset_request(self, mac: str) -> bool:
181-
"""Send an energy-reset request to a Node."""
182-
_LOGGER.debug("Resetting energy logs for %s", mac)
183-
try:
184-
await self._network.energy_reset_request(mac)
185-
except (MessageError, NodeError) as exc:
186-
raise NodeError(f"{exc}") from exc
187-
188-
# Follow up by an energy-intervals (re)set
189-
if result := await self.set_energy_intervals(
190-
mac, DEFAULT_CONS_INTERVAL, NO_PRODUCTION_INTERVAL
191-
):
192-
return result
193-
194-
return False
195-
196179
async def set_energy_intervals(
197180
self, mac: str, cons_interval: int, prod_interval: int
198181
) -> bool:

plugwise_usb/api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class NodeFeature(str, Enum):
4141

4242
AVAILABLE = "available"
4343
BATTERY = "battery"
44+
CIRCLE = "circle"
4445
CIRCLEPLUS = "circleplus"
4546
ENERGY = "energy"
4647
HUMIDITY = "humidity"
@@ -78,13 +79,14 @@ class NodeType(Enum):
7879
PUSHING_FEATURES = (
7980
NodeFeature.AVAILABLE,
8081
NodeFeature.BATTERY,
82+
NodeFeature.CIRCLE,
83+
NodeFeature.CIRCLEPLUS,
8184
NodeFeature.HUMIDITY,
8285
NodeFeature.MOTION,
8386
NodeFeature.MOTION_CONFIG,
8487
NodeFeature.TEMPERATURE,
8588
NodeFeature.SENSE,
8689
NodeFeature.SWITCH,
87-
NodeFeature.CIRCLEPLUS,
8890
)
8991

9092

plugwise_usb/network/__init__.py

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from asyncio import Task, create_task, gather, sleep
88
from collections.abc import Callable, Coroutine
9-
from datetime import UTC, datetime, timedelta
9+
from datetime import datetime, timedelta
1010
import logging
1111
from typing import Any
1212

@@ -15,11 +15,7 @@
1515
from ..constants import ENERGY_NODE_TYPES, UTF8
1616
from ..exceptions import CacheError, MessageError, NodeError, StickError, StickTimeout
1717
from ..helpers.util import validate_mac
18-
from ..messages.requests import (
19-
CircleClockSetRequest,
20-
CircleMeasureIntervalRequest,
21-
NodePingRequest,
22-
)
18+
from ..messages.requests import CircleMeasureIntervalRequest, NodePingRequest
2319
from ..messages.responses import (
2420
NODE_AWAKE_RESPONSE_ID,
2521
NODE_JOIN_ID,
@@ -524,25 +520,6 @@ async def stop(self) -> None:
524520

525521
# endregion
526522

527-
async def energy_reset_request(self, mac: str) -> None:
528-
"""Send an energy-reset to a Node."""
529-
self._validate_energy_node(mac)
530-
node_protocols = self._nodes[mac].node_protocols
531-
request = CircleClockSetRequest(
532-
self._controller.send,
533-
bytes(mac, UTF8),
534-
datetime.now(tz=UTC),
535-
node_protocols.max,
536-
True,
537-
)
538-
if (response := await request.send()) is None:
539-
raise NodeError(f"Energy-reset for {mac} failed")
540-
541-
if response.ack_id != NodeResponseType.CLOCK_ACCEPTED:
542-
raise MessageError(
543-
f"Unexpected NodeResponseType {response.ack_id!r} received as response to CircleClockSetRequest"
544-
)
545-
546523
async def set_energy_intervals(
547524
self, mac: str, consumption: int, production: int
548525
) -> None:

0 commit comments

Comments
 (0)