Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 6 additions & 4 deletions aiolyric/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,23 @@ async def update_priority(
location: LyricLocation,
device: LyricDevice,
priority_type: str,
rooms: list[int],
rooms: list[int] | None = None,
) -> ClientResponse:
"""Update Priority."""
self.logger.debug("Update Priority")

priority = {
priority: dict = {
"priorityType": priority_type,
"selectedRooms": rooms,
}

if rooms is not None:
priority["selectedRooms"] = rooms

data = {"currentPriority": priority}

self.logger.debug(data)

return await self._client.post(
return await self._client.put(
f"{BASE_URL}/devices/thermostats/{device.device_id}/priority?apikey={self._client_id}&locationId={location.location_id}",
json=data,
)
12 changes: 12 additions & 0 deletions aiolyric/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ async def post(
**kwargs,
)

async def put(
self,
url: str,
**kwargs,
) -> ClientResponse:
"""Make a PUT request."""
return await self.request(
"PUT",
url,
**kwargs,
)

async def request(
self,
method: str,
Expand Down
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def mock_aioresponse():
repeat=True,
)

mocker.put(
f"{BASE_URL}/devices/thermostats/LCC-00A01AB1ABCD/priority?apikey=test&locationId=123456",
payload=RESPONSE_JSON_BASIC,
status=200,
repeat=True,
)

yield mocker


Expand Down
19 changes: 19 additions & 0 deletions tests/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,22 @@ async def test_lyric(
lyric.devices[0],
"auto",
)

await lyric.update_priority(
lyric.locations[0],
lyric.devices[0],
"PickARoom",
[0, 1],
)

await lyric.update_priority(
lyric.locations[0],
lyric.devices[0],
"FollowMe",
)

await lyric.update_priority(
lyric.locations[0],
lyric.devices[0],
"WholeHouse",
)