Skip to content

Commit 3a7119c

Browse files
authored
Add method to set target temperature for BLU TRV (#848)
1 parent 9535cb8 commit 3a7119c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

aioshelly/rpc_device/device.py

+11
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,17 @@ async def trigger_blu_trv_calibration(self, trv_id: int) -> None:
282282
}
283283
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)
284284

285+
async def blu_trv_set_target_temperature(
286+
self, trv_id: int, temperature: float
287+
) -> None:
288+
"""Set the target temperatire for BLU TRV."""
289+
params = {
290+
"id": trv_id,
291+
"method": "Trv.SetTarget",
292+
"params": {"id": 0, "target_C": temperature},
293+
}
294+
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)
295+
285296
async def blu_trv_set_external_temperature(
286297
self, trv_id: int, temperature: float
287298
) -> None:

tests/rpc_device/test_device.py

+18
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,24 @@ async def test_trigger_blu_trv_calibration(
854854
assert call_args_list[0][0][1] == 60
855855

856856

857+
@pytest.mark.asyncio
858+
async def test_blu_trv_set_target_temperature(
859+
rpc_device: RpcDevice,
860+
) -> None:
861+
"""Test RpcDevice blu_trv_set_target_temperature() method."""
862+
await rpc_device.blu_trv_set_target_temperature(200, 21.5)
863+
864+
assert rpc_device.call_rpc_multiple.call_count == 1
865+
call_args_list = rpc_device.call_rpc_multiple.call_args_list
866+
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
867+
assert call_args_list[0][0][0][0][1] == {
868+
"id": 200,
869+
"method": "Trv.SetTarget",
870+
"params": {"id": 0, "target_C": 21.5},
871+
}
872+
assert call_args_list[0][0][1] == 60
873+
874+
857875
@pytest.mark.asyncio
858876
async def test_blu_trv_set_external_temperature(
859877
rpc_device: RpcDevice,

0 commit comments

Comments
 (0)