Skip to content

Commit

Permalink
Add a get_water_statistics function meant for the PW1 sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanruthe committed Jan 21, 2024
1 parent 762d420 commit 9f0fa20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions aiophyn/device.py
Expand Up @@ -65,6 +65,27 @@ async def get_consumption(
"get", f"{API_BASE}/devices/{device_id}/consumption/details", params=params
)

async def get_water_statistics(self, device_id: str, from_ts, to_ts):
"""Get statistics about a PW1 sensor
:param device_id: Unique identifier for the device
:type device_id: str
:param from_ts: Lower bound timestamp. This is a timestamp with thousands as integer
:type from_ts: int
:param to_ts: Upper bound timestamp. This is a timestamp with thousands as integer
:type to_ts: int
:return: List of dictionaries of results.
:rtype: List[dict[str, Any]]
"""
params = {
"from_ts": from_ts,
"to_ts": to_ts
}

return await self._request(
"get", f"{API_BASE}/devices/{device_id}/water_statistics/history/", params=params
)

async def open_valve(self, device_id: str) -> None:
"""Open a device shutoff valve.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aiophyn"
version = "2024.1.2"
version = "2024.1.3"
description = "An asynchronous library for Phyn Smart Water devices"
authors = ["MizterB <5458030+MizterB@users.noreply.github.com>","jordanruthe <31575189+jordanruthe@users.noreply.github.com>"]
license = "MIT"
Expand Down

0 comments on commit 9f0fa20

Please sign in to comment.