Skip to content

Commit 9535cb8

Browse files
authored
Add methods for Blu Trv boost mode (#839)
* Add methods for Blu Trv boost mode * Typo * Cleaning after rebase
1 parent 9dfdbba commit 9535cb8

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

aioshelly/rpc_device/device.py

+20
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,26 @@ async def blu_trv_set_valve_position(self, trv_id: int, position: float) -> None
302302
}
303303
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)
304304

305+
async def blu_trv_set_boost(self, trv_id: int, duration: int | None = None) -> None:
306+
"""Start boost mode for BLU TRV."""
307+
params = {
308+
"id": trv_id,
309+
"method": "Trv.SetBoost",
310+
}
311+
params["params"] = (
312+
{"id": 0} if duration is None else {"id": 0, "duration": duration}
313+
)
314+
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)
315+
316+
async def blu_trv_clear_boost(self, trv_id: int) -> None:
317+
"""Clear boost mode for BLU TRV."""
318+
params = {
319+
"id": trv_id,
320+
"method": "Trv.ClearBoost",
321+
"params": {"id": 0},
322+
}
323+
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)
324+
305325
async def number_set(self, id_: int, value: float) -> None:
306326
"""Set the value for the number component."""
307327
params = {

tests/rpc_device/test_device.py

+54
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,60 @@ async def test_blu_trv_set_valve_position(
892892
assert call_args_list[0][0][1] == 60
893893

894894

895+
@pytest.mark.asyncio
896+
async def test_blu_trv_set_boost(
897+
rpc_device: RpcDevice,
898+
) -> None:
899+
"""Test RpcDevice blu_trv_set_boost() method."""
900+
await rpc_device.blu_trv_set_boost(200)
901+
902+
assert rpc_device.call_rpc_multiple.call_count == 1
903+
call_args_list = rpc_device.call_rpc_multiple.call_args_list
904+
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
905+
assert call_args_list[0][0][0][0][1] == {
906+
"id": 200,
907+
"method": "Trv.SetBoost",
908+
"params": {"id": 0},
909+
}
910+
assert call_args_list[0][0][1] == 60
911+
912+
913+
@pytest.mark.asyncio
914+
async def test_blu_trv_set_boost_duration(
915+
rpc_device: RpcDevice,
916+
) -> None:
917+
"""Test RpcDevice blu_trv_set_boost() method with duration."""
918+
await rpc_device.blu_trv_set_boost(200, 33)
919+
920+
assert rpc_device.call_rpc_multiple.call_count == 1
921+
call_args_list = rpc_device.call_rpc_multiple.call_args_list
922+
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
923+
assert call_args_list[0][0][0][0][1] == {
924+
"id": 200,
925+
"method": "Trv.SetBoost",
926+
"params": {"id": 0, "duration": 33},
927+
}
928+
assert call_args_list[0][0][1] == 60
929+
930+
931+
@pytest.mark.asyncio
932+
async def test_blu_trv_clear_boost(
933+
rpc_device: RpcDevice,
934+
) -> None:
935+
"""Test RpcDevice blu_trv_clear_boost() method."""
936+
await rpc_device.blu_trv_clear_boost(200)
937+
938+
assert rpc_device.call_rpc_multiple.call_count == 1
939+
call_args_list = rpc_device.call_rpc_multiple.call_args_list
940+
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
941+
assert call_args_list[0][0][0][0][1] == {
942+
"id": 200,
943+
"method": "Trv.ClearBoost",
944+
"params": {"id": 0},
945+
}
946+
assert call_args_list[0][0][1] == 60
947+
948+
895949
@pytest.mark.asyncio
896950
async def test_number_set(
897951
rpc_device: RpcDevice,

0 commit comments

Comments
 (0)