From 98c599932466f71122242e8cfcb7050fdbf82997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Matheson=20Wergeland?= Date: Tue, 2 Jul 2024 22:49:47 +0200 Subject: [PATCH] Support setting properties --- connectlife/api.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/connectlife/api.py b/connectlife/api.py index f021aa7..de02653 100644 --- a/connectlife/api.py +++ b/connectlife/api.py @@ -84,6 +84,23 @@ async def get_appliances_json(self) -> Any: return await response.json() + async def update_appliance(self, puid: str, properties: dict[str, int]): + data = { + "puid": puid, + "properties": properties + } + _LOGGER.debug("Updating appliance with puid %s", puid) + await self._fetch_access_token() + async with aiohttp.ClientSession() as session: + async with session.post(APPLIANCES_URL, json=data, headers={ + "User-Agent": "connectlife-api-connector 2.1.4", + "X-Token": self._access_token + }) as response: + result = await response.text() + _LOGGER.debug(result) + _LOGGER.debug("Updated appliance with puid %s", puid) + + async def _fetch_access_token(self): if self._expires is None: await self._initial_access_token()