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

Get Away Mode method added to API #4

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This library is initially focused on supporting a Phyn integration for Home Assi
- Device state
- Water consumption
- Shutoff valve control
- Get and set away mode

## Acknowledgements

Expand Down
10 changes: 10 additions & 0 deletions aiophyn/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ async def close_valve(self, device_id: str) -> None:
"post",
f"{API_BASE}/devices/{device_id}/sov/Close",
)

async def get_away_mode(self, device_id: str) -> dict:
"""Return away mode status of a device.

:param device_id: Unique identifier for the device
:type device_id: ``str``
:rtype: ``dict``
"""
return await self._request("get", f"{API_BASE}/preferences/device/{device_id}/leak_sensitivity_away_mode")


async def enable_away_mode(self, device_id: str) -> None:
"""Enable the device's away mode.
Expand Down
7 changes: 7 additions & 0 deletions aiophyn/utils/device_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

async def device_dump(username: str, password: str) -> None:
device_states = []
away_mode_states = []
async with ClientSession() as session:
try:
api = await async_get_api(username, password, session=session)
Expand All @@ -20,9 +21,15 @@ async def device_dump(username: str, password: str) -> None:
for device_id in home.get("device_ids", []):
device_state = await api.device.get_state(device_id)
device_states.append(device_state)

away_mode = await api.device.get_away_mode(device_id)
away_mode_states.append(away_mode)
print("\n" * 3)
pprint(device_states)
print("\n" * 3)
pprint(away_mode_states)
print("\n" * 3)

except PhynError as err:
_LOGGER.error("There was an error: %s", err)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aiophyn"
version = "2023.01.0"
version = "2023.08.0"
description = "An asynchronous library for Phyn Smart Water devices"
authors = ["MizterB <5458030+MizterB@users.noreply.github.com>"]
license = "MIT"
Expand Down