Skip to content

Commit 2d0565e

Browse files
authored
Merge pull request #288 from dvd-dev/dev
Fix typo, fix missing await
2 parents 11eab96 + 6a4d079 commit 2d0565e

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

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.4.02"
10+
PYHILO_VERSION: Final = "2025.5.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/graphql.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from gql.transport.websockets import WebsocketsTransport
77

88
from pyhilo import API
9+
from pyhilo.const import LOG
910
from pyhilo.device.graphql_value_mapper import GraphqlValueMapper
1011
from pyhilo.devices import Devices
1112

@@ -557,14 +558,14 @@ async def subscribe_to_device_updated(
557558
async for result in session.subscribe(
558559
query, variable_values={"locationHiloId": location_hilo_id}
559560
):
560-
print(f"Received subscription result {result}")
561+
LOG.debug(f"Received subscription result {result}")
561562
device_hilo_id = self._handle_device_subscription_result(result)
562563
if callback:
563564
callback(device_hilo_id)
564565
except Exception as e:
565-
print(f"Connection lost: {e}. Reconnecting in 5 seconds...")
566+
LOG.debug(f"Connection lost: {e}. Reconnecting in 5 seconds...")
566567
await asyncio.sleep(5)
567-
self.call_get_location_query(location_hilo_id)
568+
await self.call_get_location_query(location_hilo_id)
568569

569570
async def subscribe_to_location_updated(
570571
self, location_hilo_id: str, callback: callable = None
@@ -580,11 +581,11 @@ async def subscribe_to_location_updated(
580581
async for result in session.subscribe(
581582
query, variable_values={"locationHiloId": location_hilo_id}
582583
):
583-
print(f"Received subscription result {result}")
584+
LOG.debug(f"Received subscription result {result}")
584585
device_hilo_id = self._handle_location_subscription_result(result)
585586
callback(device_hilo_id)
586587
except asyncio.CancelledError:
587-
print("Subscription cancelled.")
588+
LOG.debug("Subscription cancelled.")
588589
asyncio.sleep(1)
589590
await self.subscribe_to_location_updated(location_hilo_id)
590591

@@ -602,13 +603,13 @@ def _handle_device_subscription_result(self, result: Dict[str, Any]) -> str:
602603
attributes = self.mapper.map_device_subscription_values(devices_values)
603604
updated_device = self._devices.parse_values_received(attributes)
604605
# callback to update the device in the UI
605-
print(f"Device updated: {updated_device}")
606+
LOG.debug(f"Device updated: {updated_device}")
606607
return devices_values.get("hiloId")
607608

608609
def _handle_location_subscription_result(self, result: Dict[str, Any]) -> str:
609610
devices_values: list[any] = result["onAnyLocationUpdated"]["location"]
610611
attributes = self.mapper.map_location_subscription_values(devices_values)
611612
updated_device = self._devices.parse_values_received(attributes)
612613
# callback to update the device in the UI
613-
print(f"Device updated: {updated_device}")
614+
LOG.debug(f"Device updated: {updated_device}")
614615
return devices_values.get("hiloId")

pyhilo/util/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ async def set_state(
161161
LOG.debug("Saving state to yaml file")
162162
# TODO: Use asyncio.get_running_loop() and run_in_executor to write
163163
# to the file in a non blocking manner. Currently, the file writes
164-
# are properly async but the yaml dump is done synchroniously on the
164+
# are properly async but the yaml dump is done synchronously on the
165165
# main event loop.
166166
content = yaml.dump(new_state)
167167
await yaml_file.write(content)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ exclude = ".venv/.*"
4040

4141
[tool.poetry]
4242
name = "python-hilo"
43-
version = "2025.4.2"
43+
version = "2025.5.1"
4444
description = "A Python3, async interface to the Hilo API"
4545
readme = "README.md"
4646
authors = ["David Vallee Delisle <[email protected]>"]

0 commit comments

Comments
 (0)