|
13 | 13 | from ..api import NodeEvent, NodeType, PlugwiseNode, StickEvent |
14 | 14 | from ..connection import StickController |
15 | 15 | from ..constants import UTF8 |
| 16 | +from ..helpers.util import validate_mac |
16 | 17 | from ..exceptions import CacheError, MessageError, NodeError, StickError, StickTimeout |
17 | 18 | from ..messages.requests import ( |
18 | 19 | CircleClockSetRequest, |
@@ -546,6 +547,12 @@ async def allow_join_requests(self, state: bool) -> None: |
546 | 547 |
|
547 | 548 | async def energy_reset_request(self, mac: str) -> None: |
548 | 549 | """Send an energy-reset to a Node.""" |
| 550 | + if not validate_mac(mac): |
| 551 | + raise NodeError(f"MAC '{mac}' invalid") |
| 552 | + |
| 553 | + if mac not in self._nodes: |
| 554 | + raise NodeError(f"Node {mac} not present in network") |
| 555 | + |
549 | 556 | if self._nodes[mac].node_info.node_type.value not in ENERGY_NODE_TYPES: |
550 | 557 | raise NodeError( |
551 | 558 | f"Energy-resetting not supported for {self._nodes[mac].node_info.node_type.name}" |
@@ -575,6 +582,12 @@ async def set_energy_intervals( |
575 | 582 | Default: consumption = 60, production = 0. |
576 | 583 | For logging energy in both directions set both to 60. |
577 | 584 | """ |
| 585 | + if not validate_mac(mac): |
| 586 | + raise NodeError(f"MAC '{mac}' invalid") |
| 587 | + |
| 588 | + if mac not in self._nodes: |
| 589 | + raise NodeError(f"Node {mac} not present in network") |
| 590 | + |
578 | 591 | if self._nodes[mac].node_info.node_type.value not in ENERGY_NODE_TYPES: |
579 | 592 | raise NodeError( |
580 | 593 | f"Setting energy-intervals not supported for {self._nodes[mac].node_info.node_type.name}" |
|
0 commit comments