diff --git a/aiolyric/__init__.py b/aiolyric/__init__.py index 5980d80..907fc86 100644 --- a/aiolyric/__init__.py +++ b/aiolyric/__init__.py @@ -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, ) diff --git a/aiolyric/client.py b/aiolyric/client.py index f787ccd..dca9af0 100644 --- a/aiolyric/client.py +++ b/aiolyric/client.py @@ -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, diff --git a/tests/conftest.py b/tests/conftest.py index 9795498..7bbbe96 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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 diff --git a/tests/test_init.py b/tests/test_init.py index 025b1ff..bc7f2bf 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -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", + )