Skip to content
Merged
2 changes: 2 additions & 0 deletions plugwise_usb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class NodeFeature(str, Enum):

AVAILABLE = "available"
BATTERY = "battery"
CIRCLEPLUS = "circleplus"
ENERGY = "energy"
HUMIDITY = "humidity"
INFO = "info"
Expand Down Expand Up @@ -83,6 +84,7 @@ class NodeType(Enum):
NodeFeature.TEMPERATURE,
NodeFeature.SENSE,
NodeFeature.SWITCH,
NodeFeature.CIRCLEPLUS,
)


Expand Down
20 changes: 19 additions & 1 deletion plugwise_usb/nodes/circle_plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
from ..messages.requests import (
CirclePlusRealTimeClockGetRequest,
CirclePlusRealTimeClockSetRequest,
CirclePlusAllowJoiningRequest,
)
from ..messages.responses import NodeResponseType
from .circle import PlugwiseCircle
from .helpers.firmware import CIRCLE_PLUS_FIRMWARE_SUPPORT

from .helpers import raise_not_loaded
_LOGGER = logging.getLogger(__name__)


Expand All @@ -37,6 +38,7 @@ async def load(self) -> bool:
NodeFeature.RELAY_LOCK,
NodeFeature.ENERGY,
NodeFeature.POWER,
NodeFeature.CIRCLEPLUS,
),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
)
if await self.initialize():
Expand Down Expand Up @@ -73,6 +75,7 @@ async def load(self) -> bool:
NodeFeature.RELAY_LOCK,
NodeFeature.ENERGY,
NodeFeature.POWER,
NodeFeature.CIRCLEPLUS,
),
)
if not await self.initialize():
Expand Down Expand Up @@ -121,3 +124,18 @@ async def clock_synchronize(self) -> bool:
self.name,
)
return False

@raise_not_loaded
async def enable_auto_join(self) -> bool:
"""Enable auto-join on the Circle+.

Returns:
bool: True if the request was acknowledged, False otherwise.
"""
_LOGGER.info("Enabling auto-join for CirclePlus")
request = CirclePlusAllowJoiningRequest(self._send, True)
if (response := await request.send()) is None:
return False

# JOIN_ACCEPTED is the ACK for enable=True
return NodeResponseType(response.ack_id) == NodeResponseType.JOIN_ACCEPTED
1 change: 1 addition & 0 deletions plugwise_usb/nodes/helpers/firmware.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ class SupportedVersions(NamedTuple):
NodeFeature.MOTION: 2.0,
NodeFeature.MOTION_CONFIG: 2.0,
NodeFeature.SWITCH: 2.0,
NodeFeature.CIRCLEPLUS: 2.0,
}

# endregion
1 change: 1 addition & 0 deletions tests/test_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2498,6 +2498,7 @@ async def test_node_discovery_and_load(
pw_api.NodeFeature.RELAY,
pw_api.NodeFeature.RELAY_LOCK,
pw_api.NodeFeature.ENERGY,
pw_api.NodeFeature.CIRCLEPLUS,
pw_api.NodeFeature.POWER,
)
)
Expand Down
Loading