Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix invalid path #88

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
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
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"
}
Loading