Skip to content
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

Support setting properties #1

Merged
merged 3 commits into from
Jul 4, 2024
Merged
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
17 changes: 17 additions & 0 deletions connectlife/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, str]):
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()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "connectlife"
version = "0.1.0"
version = "0.2.0"
authors = [
{ name="Øyvind Matheson Wergeland", email="[email protected]" },
]
Expand Down