diff --git a/custom_components/hilo/sensor.py b/custom_components/hilo/sensor.py index f8e378a3..410632db 100755 --- a/custom_components/hilo/sensor.py +++ b/custom_components/hilo/sensor.py @@ -40,8 +40,8 @@ from pyhilo.device import HiloDevice from pyhilo.event import Event from pyhilo.util import from_utc_timestamp -import ruyaml as yaml -from ruyaml.scanner import ScannerError +import yaml +from yaml.scanner import ScannerError from . import Hilo from .const import ( @@ -761,7 +761,11 @@ async def _load_history(self) -> list: async def _save_history(self, history: list): async with aiofiles.open(self._history_state_yaml, mode="w") as yaml_file: LOG.debug("Saving history state to yaml file") - await yaml_file.write(yaml.dump(history, Dumper=yaml.RoundTripDumper)) + # TODO: Use asyncio.get_running_loop() and run_in_executor to write + # to the file in a non blocking manner. Currently, the file writes + # are properly async but the yaml dump is done synchroniously on the + # main event loop + await yaml_file.write(yaml.dump(history)) class HiloChallengeSensor(HiloEntity, SensorEntity): diff --git a/requirements.txt b/requirements.txt index dd14d3a8..503130ef 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ colorlog==6.9.0 homeassistant~=2025.3.4 pip>=21.3.1 ruff==0.11.3 +pyyaml>=6.0.2