Skip to content

Commit f556da3

Browse files
committed
Network: add set_measure_interval()
Allows to enable/disable production measurements
1 parent 497ee31 commit f556da3

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

plugwise_usb/network/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
from ..connection import StickController
1515
from ..constants import UTF8
1616
from ..exceptions import CacheError, MessageError, NodeError, StickError, StickTimeout
17-
from ..messages.requests import CirclePlusAllowJoiningRequest, NodePingRequest
17+
from ..messages.requests import (
18+
CirclePlusAllowJoiningRequest,
19+
CircleMeasureIntervalRequest,
20+
NodePingRequest,
21+
)
1822
from ..messages.responses import (
1923
NODE_AWAKE_RESPONSE_ID,
2024
NODE_JOIN_ID,
@@ -537,6 +541,17 @@ async def allow_join_requests(self, state: bool) -> None:
537541
_LOGGER.debug("Sent AllowJoiningRequest to Circle+ with state=%s", state)
538542
self.accept_join_request = state
539543

544+
async def set_measure_interval(self, consumption: int, production: int) -> None:
545+
"""Set the measure intervals for both consumption and production.
546+
547+
Default: consumption = 60, production = 0.
548+
For measuring in both directions set both to 60.
549+
"""
550+
_LOGGER.debug("set_measure_interval | cons=%s, prod=%s", consumption, production)
551+
request = CircleMeasureIntervalRequest(self, consumption, production)
552+
if (response := await request.send()) is None:
553+
raise NodeError("No response for CircleMeasureIntervalRequest.")
554+
540555
def subscribe_to_node_events(
541556
self,
542557
node_event_callback: Callable[[NodeEvent, str], Coroutine[Any, Any, None]],

0 commit comments

Comments
 (0)