Skip to content

Commit

Permalink
Merge pull request #88 from radical-squared/bug-fix-3-0-33
Browse files Browse the repository at this point in the history
fix invalid path
  • Loading branch information
elad-bar authored Jun 6, 2024
2 parents 93a3917 + e744e04 commit bfb0705
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.0.34

- Fix relative path of config files

## 3.0.33

- Fix "detected blocking call to open inside the event loop by custom integration" error
Expand Down
14 changes: 10 additions & 4 deletions custom_components/aqua_temp/managers/aqua_temp_config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import os
from pathlib import Path

import aiofiles

Expand Down Expand Up @@ -295,11 +296,11 @@ async def _load(self):
await self._save()

await self._load_entity_descriptions("default")
self._load_pc_mapping("default")
await self._load_pc_mapping("default")

for product_id in PRODUCT_IDS:
await self._load_entity_descriptions(product_id)
self._load_pc_mapping(product_id)
await self._load_pc_mapping(product_id)

log_messages = [
f"Entity Descriptions: {len(self._entity_descriptions)}",
Expand Down Expand Up @@ -378,6 +379,9 @@ async def _load_entity_descriptions(self, product_id: str):
ProductParameter.ENTITY_DESCRIPTION, product_id
)

if not os.path.exists(file_path):
return

file = await aiofiles.open(file_path)
json_str = await file.read()
await file.close()
Expand Down Expand Up @@ -524,7 +528,9 @@ def get_entity_descriptions(self, device_code):

@staticmethod
def _get_product_file(parameter: ProductParameter, product_id):
config_file = f"../parameters/{parameter}.{product_id}.json"
file_path = os.path.join(os.path.dirname(__file__), config_file)
config_file = f"{parameter}.{product_id}.json"
current_path = Path(__file__)
parent_directory = current_path.parents[1]
file_path = os.path.join(parent_directory, "parameters", config_file)

return file_path
2 changes: 1 addition & 1 deletion custom_components/aqua_temp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/radical-squared/aquatemp/issues",
"requirements": [],
"version": "3.0.33"
"version": "3.0.34"
}

0 comments on commit bfb0705

Please sign in to comment.