|
5 | 5 | """ |
6 | 6 |
|
7 | 7 | from __future__ import annotations |
8 | | -from collections.abc import Callable |
9 | 8 |
|
10 | 9 | import asyncio |
| 10 | +from collections.abc import Callable |
11 | 11 | from dataclasses import dataclass |
12 | 12 | from enum import Enum |
13 | 13 | import hashlib |
|
19 | 19 | import httpx |
20 | 20 |
|
21 | 21 | from .api import DEFAULT_URL_BASE |
| 22 | +from .timed_cache import time_cached |
22 | 23 |
|
23 | 24 |
|
24 | 25 | class AccessoryType(Enum): |
@@ -599,19 +600,22 @@ def set_value(keys, value): |
599 | 600 | return json.loads(data) |
600 | 601 |
|
601 | 602 | # Sends a 203 which is a high level status |
| 603 | + @time_cached() |
602 | 604 | async def _status(self): |
603 | 605 | payload = self._build_payload(203, {"opt": 1, "refreshData": 1}) |
604 | 606 | data = (await self._mqtt_send(payload))["result"]["dataArea"] |
605 | 607 | return json.loads(data) |
606 | 608 |
|
607 | 609 | # Sends a 311 which appears to be a more specific switch command |
| 610 | + @time_cached() |
608 | 611 | async def _switch_status(self): |
609 | 612 | payload = self._build_payload(311, {"opt": 0, "order": self.gateway}) |
610 | 613 | data = (await self._mqtt_send(payload))["result"]["dataArea"] |
611 | 614 | return json.loads(data) |
612 | 615 |
|
613 | 616 | # Sends a 353 which grabs real-time smart-circuit load information |
614 | 617 | # https://github.com/richo/homeassistant-franklinwh/issues/27#issuecomment-2714422732 |
| 618 | + @time_cached() |
615 | 619 | async def _switch_usage(self): |
616 | 620 | payload = self._build_payload(353, {"opt": 0, "order": self.gateway}) |
617 | 621 | data = (await self._mqtt_send(payload))["result"]["dataArea"] |
@@ -739,6 +743,7 @@ async def set_grid_status(self, status: GridStatus, soc: int = 5): |
739 | 743 | } |
740 | 744 | await self._post(url, json.dumps(payload)) |
741 | 745 |
|
| 746 | + @time_cached() |
742 | 747 | async def get_composite_info(self): |
743 | 748 | """Get composite information about the FranklinWH gateway.""" |
744 | 749 | url = self.url_base + "hes-gateway/terminal/getDeviceCompositeInfo" |
|
0 commit comments