Skip to content

Add methods for Blu Trv boost mode #839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions aioshelly/rpc_device/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,26 @@ async def blu_trv_set_valve_position(self, trv_id: int, position: float) -> None
}
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)

async def blu_trv_set_boost(self, trv_id: int, duration: int | None = None) -> None:
"""Start boost mode for BLU TRV."""
params = {
"id": trv_id,
"method": "Trv.SetBoost",
}
params["params"] = (
{"id": 0} if duration is None else {"id": 0, "duration": duration}
)
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)

async def blu_trv_clear_boost(self, trv_id: int) -> None:
"""Clear boost mode for BLU TRV."""
params = {
"id": trv_id,
"method": "Trv.ClearBoost",
"params": {"id": 0},
}
await self.call_rpc("BluTRV.Call", params=params, timeout=BLU_TRV_TIMEOUT)

async def number_set(self, id_: int, value: float) -> None:
"""Set the value for the number component."""
params = {
Expand Down
73 changes: 73 additions & 0 deletions tests/rpc_device/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,25 @@ async def test_blu_trv_set_external_temperature(
assert call_args_list[0][0][1] == 60


async def test_blu_trv_set_boost(
rpc_device: RpcDevice,
) -> None:
"""Test RpcDevice blu_trv_set_boost() method."""
await rpc_device.blu_trv_set_boost(200)

assert rpc_device.call_rpc_multiple.call_count == 1
call_args_list = rpc_device.call_rpc_multiple.call_args_list
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
assert call_args_list[0][0][0][0][1] == {
"id": 200,
"method": "Trv.SetExternalTemperature",
"params": {"id": 0, "t_C": 22.6},
"method": "Trv.SetBoost",
"params": {"id": 0},
}
assert call_args_list[0][0][1] == 60


@pytest.mark.asyncio
async def test_blu_trv_set_valve_position(
rpc_device: RpcDevice,
Expand All @@ -892,6 +911,60 @@ async def test_blu_trv_set_valve_position(
assert call_args_list[0][0][1] == 60


@pytest.mark.asyncio
async def test_blu_trv_set_boost(
rpc_device: RpcDevice,
) -> None:
"""Test RpcDevice blu_trv_set_boost() method."""
await rpc_device.blu_trv_set_boost(200)

assert rpc_device.call_rpc_multiple.call_count == 1
call_args_list = rpc_device.call_rpc_multiple.call_args_list
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
assert call_args_list[0][0][0][0][1] == {
"id": 200,
"method": "Trv.SetBoost",
"params": {"id": 0},
}
assert call_args_list[0][0][1] == 60


@pytest.mark.asyncio
async def test_blu_trv_set_boost_duration(
rpc_device: RpcDevice,
) -> None:
"""Test RpcDevice blu_trv_set_boost() method with duration."""
await rpc_device.blu_trv_set_boost(200, 33)

assert rpc_device.call_rpc_multiple.call_count == 1
call_args_list = rpc_device.call_rpc_multiple.call_args_list
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
assert call_args_list[0][0][0][0][1] == {
"id": 200,
"method": "Trv.SetBoost",
"params": {"id": 0, "duration": 33},
}
assert call_args_list[0][0][1] == 60


@pytest.mark.asyncio
async def test_blu_trv_clear_boost(
rpc_device: RpcDevice,
) -> None:
"""Test RpcDevice blu_trv_clear_boost() method."""
await rpc_device.blu_trv_clear_boost(200)

assert rpc_device.call_rpc_multiple.call_count == 1
call_args_list = rpc_device.call_rpc_multiple.call_args_list
assert call_args_list[0][0][0][0][0] == "BluTRV.Call"
assert call_args_list[0][0][0][0][1] == {
"id": 200,
"method": "Trv.ClearBoost",
"params": {"id": 0},
}
assert call_args_list[0][0][1] == 60


@pytest.mark.asyncio
async def test_number_set(
rpc_device: RpcDevice,
Expand Down
Loading