Skip to content

Commit c7945ef

Browse files
authored
Merge pull request #265 from AbigailAsselin-Hilo/add_graphql_subscription
Add graphql subscription
2 parents a34db82 + 69a9f97 commit c7945ef

7 files changed

Lines changed: 542 additions & 147 deletions

File tree

pyhilo/api.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
import random
77
import string
88
import sys
9-
from typing import Any, Callable, Dict, Union, cast
9+
from typing import Any, Callable, Union, cast
1010
from urllib import parse
1111

1212
from aiohttp import ClientSession
1313
from aiohttp.client_exceptions import ClientResponseError
1414
import backoff
15-
from gql import Client, gql
16-
from gql.transport.aiohttp import AIOHTTPTransport
1715

1816
from pyhilo.const import (
1917
ANDROID_CLIENT_ENDPOINT,
@@ -45,7 +43,6 @@
4543
)
4644
from pyhilo.device import DeviceAttribute, HiloDevice, get_device_attributes
4745
from pyhilo.exceptions import InvalidCredentialsError, RequestError
48-
from pyhilo.graphql import GraphQlHelper
4946
from pyhilo.util.state import (
5047
StateDict,
5148
WebsocketDict,
@@ -513,22 +510,6 @@ async def get_devices(self, location_id: int) -> list[dict[str, Any]]:
513510
devices.append(callback())
514511
return devices
515512

516-
async def call_get_location_query(self, location_hilo_id: string) -> Dict[str, Any]:
517-
access_token = await self.async_get_access_token()
518-
transport = AIOHTTPTransport(
519-
url="https://platform.hiloenergie.com/api/digital-twin/v3/graphql",
520-
headers={"Authorization": f"Bearer {access_token}"},
521-
)
522-
client = Client(transport=transport, fetch_schema_from_transport=True)
523-
query = gql(GraphQlHelper.query_get_location())
524-
525-
async with client as session:
526-
result = await session.execute(
527-
query, variable_values={"locationHiloId": location_hilo_id}
528-
)
529-
LOG.info(result)
530-
return result
531-
532513
async def _set_device_attribute(
533514
self,
534515
device: HiloDevice,

pyhilo/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
LOG: Final = logging.getLogger(__package__)
88
DEFAULT_STATE_FILE: Final = "hilo_state.yaml"
99
REQUEST_RETRY: Final = 9
10-
PYHILO_VERSION: Final = "2025.2.02"
10+
PYHILO_VERSION: Final = "2025.4.01"
1111
# TODO: Find a way to keep previous line in sync with pyproject.toml automatically
1212

1313
CONTENT_TYPE_FORM: Final = "application/x-www-form-urlencoded"

pyhilo/device/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,7 @@ def update(self, **kwargs: Dict[str, Union[str, int, Dict]]) -> None:
8787
new_val.append(DeviceAttribute("Disconnected", "null"))
8888
elif att == "provider":
8989
att = "manufacturer"
90-
new_val = HILO_PROVIDERS.get(
91-
int(val), f"Unknown ({val})"
92-
) # type: ignore
90+
new_val = HILO_PROVIDERS.get(int(val), f"Unknown ({val})") # type: ignore
9391
else:
9492
if att == "serial":
9593
att = "identifier"
@@ -234,9 +232,7 @@ def __init__(self, **kwargs: Dict[str, Any]):
234232
# attr='intensity',
235233
# value_type='%')
236234
# }
237-
kwargs["timeStamp"] = from_utc_timestamp(
238-
kwargs.pop("timeStampUTC", "")
239-
) # type: ignore
235+
kwargs["timeStamp"] = from_utc_timestamp(kwargs.pop("timeStampUTC", "")) # type: ignore
240236
self.id = 0
241237
self.value: Union[int, bool, str] = 0
242238
self.device_id = 0

0 commit comments

Comments
 (0)