Skip to content

Commit

Permalink
Add telegram method (homewizard#430)
Browse files Browse the repository at this point in the history
Return type is `Any` because we don't process the response from the API.
  • Loading branch information
Mausy5043 committed Feb 1, 2025
1 parent 6a770f5 commit d830fe7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions homewizard_energy/homewizard_energy.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ async def measurement(self) -> Measurement:
"""Get the current measurement."""
raise NotImplementedError

async def telegram(self) -> Any:
"""Get the latest telegram."""
raise NotImplementedError

async def system(
self,
cloud_enabled: bool | None = None,
Expand Down
9 changes: 9 additions & 0 deletions homewizard_energy/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ async def measurement(self) -> Measurement:
_, response = await self._request("api/v1/data")
return Measurement.from_json(response)

async def telegram(self) -> Any:
"""Return the most recent, valid telegram that was given by the device.
The telegram is not processed in any other form.
If you need parsed data, use the measurement method.
"""
_, response = await self._request("api/v1/telegram")
telegram = response
return telegram

@optional_method
async def system(
self,
Expand Down
10 changes: 10 additions & 0 deletions homewizard_energy/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ async def measurement(self) -> Measurement:

return measurement

@authorized_method
async def telegram(self) -> Any:
"""Return the most recent, valid telegram that was given by the device.
The telegram is not processed in any other form.
If you need parsed data, use the measurement method.
"""
_, response = await self._request("/api/telegram")
telegram = response
return telegram

@authorized_method
async def system(
self,
Expand Down

0 comments on commit d830fe7

Please sign in to comment.