Skip to content

Commit 4ebdcfd

Browse files
committed
add sense hysteresis request
1 parent b7176ce commit 4ebdcfd

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

plugwise_usb/messages/requests.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,6 +1404,55 @@ async def send(self) -> NodeAckResponse | None:
14041404
)
14051405

14061406

1407+
class SenseConfigureHysteresisRequest(PlugwiseRequest):
1408+
"""Configure a Sense Hysteresis Switching Setting.
1409+
1410+
temp_hum : configure temperature True or humidity False
1411+
lower_bound : lower bound of the hysteresis
1412+
upper_bound : upper bound of the hysteresis
1413+
direction : Switch active high or active low
1414+
1415+
Response message: NodeAckResponse
1416+
"""
1417+
1418+
_identifier = b"0104"
1419+
_reply_identifier = b"0100"
1420+
1421+
# pylint: disable=too-many-arguments
1422+
def __init__( # noqa: PLR0913
1423+
self,
1424+
send_fn: Callable[[PlugwiseRequest, bool], Awaitable[PlugwiseResponse | None]],
1425+
mac: bytes,
1426+
temp_hum: bool,
1427+
lower_bound: int,
1428+
upper_bound: int,
1429+
direction: bool,
1430+
):
1431+
"""Initialize ScanConfigureRequest message object."""
1432+
super().__init__(send_fn, mac)
1433+
temp_hum_value = 1 if temp_hum else 0
1434+
lower_bound_value = Int(lower_bound, length=4)
1435+
upper_bound_value = Int(upper_bound, length=4)
1436+
direction_value = 1 if direction else 0
1437+
self._args += [
1438+
temp_hum_value,
1439+
lower_bound_value,
1440+
upper_bound_value,
1441+
direction_value,
1442+
]
1443+
1444+
async def send(self) -> NodeAckResponse | None:
1445+
"""Send request."""
1446+
result = await self._send_request()
1447+
if isinstance(result, NodeAckResponse):
1448+
return result
1449+
if result is None:
1450+
return None
1451+
raise MessageError(
1452+
f"Invalid response message. Received {result.__class__.__name__}, expected NodeAckResponse"
1453+
)
1454+
1455+
14071456
class ScanLightCalibrateRequest(PlugwiseRequest):
14081457
"""Calibrate light sensitivity.
14091458

0 commit comments

Comments
 (0)