Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions custom_components/hilo/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,11 +778,10 @@ async def _load_history(self) -> list:
async def _save_history(self):
async with aiofiles.open(self._history_state_yaml, mode="w") as yaml_file:
LOG.debug("Saving history state to yaml file")
# 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(self._history))
content = await asyncio.get_running_loop().run_in_executor(
None, yaml.dump, self._history
)
await yaml_file.write(content)


class HiloChallengeSensor(HiloEntity, SensorEntity):
Expand Down