Skip to content

Commit 469c10c

Browse files
authored
Merge pull request #19 from hectorespert/revert_aiocsv_dependecy
Revert aiocsv changes
2 parents 126ba75 + 556750f commit 469c10c

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

.github/workflows/python.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ jobs:
2525
run: |
2626
python -m pip install --upgrade pip
2727
pip install -r requirements-test.txt
28+
2829
- name: Run pytest
2930
run: |
30-
pytest
31+
pytest --cov-branch --cov-report=xml
32+
33+
- name: Upload results to Codecov
34+
uses: codecov/codecov-action@v5
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }}

custom_components/som_energia/manifest.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
"integration_type": "hub",
88
"iot_class": "calculated",
99
"issue_tracker": "https://github.com/hectorespert/som-energia-hass/issuess",
10-
"requirements": ["aiocsv", "aiofiles"],
11-
"version": "2025.02.16"
10+
"version": "2025.03.01"
1211
}

custom_components/som_energia/price/prices.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1+
import csv
12
import datetime as datetime
23
import os
4+
from asyncio import get_running_loop
35
from zoneinfo import ZoneInfo
46

5-
from aiocsv import AsyncDictReader
6-
from aiofiles import open
77
from aiozoneinfo import async_get_time_zone
88

99
from custom_components.som_energia.price.holidays import holidays
1010

11-
async def _read_price_csv() -> dict:
11+
def _read_price_csv() -> dict:
1212
file_path = os.path.join(os.path.dirname(__file__), "prices.csv")
1313
prices_data = {}
14-
async with open(file_path, mode='r') as file:
15-
async for row in AsyncDictReader(file):
14+
with open(file_path) as file:
15+
reader = csv.DictReader(file)
16+
for row in reader:
1617
period = (row["Inicio Periodo"], row["Final Periodo"])
1718
prices_data[period] = {
1819
"punta": float(row["Punta"] if row["Punta"] != "" else 0.0),
@@ -28,7 +29,6 @@ async def _read_price_csv() -> dict:
2829
}
2930
return prices_data
3031

31-
3232
async def _prices_for_current_period(timezone_datetime: datetime, tz: ZoneInfo) -> dict:
3333
prices_of_the_period = {
3434
"punta": 0.0,
@@ -39,7 +39,7 @@ async def _prices_for_current_period(timezone_datetime: datetime, tz: ZoneInfo)
3939
"llano_generation_kwh": 0.0,
4040
"valle_generation_kwh": 0.0,
4141
}
42-
for period, prices_of_the_period in (await _read_price_csv()).items():
42+
for period, prices_of_the_period in (await get_running_loop().run_in_executor(None, _read_price_csv)).items():
4343
prices_period_start = datetime.datetime.strptime(period[0], "%Y-%m-%d").replace(tzinfo=tz)
4444
prices_period_end = datetime.datetime.strptime(period[1], "%Y-%m-%d").replace(
4545
hour=23, minute=59, second=59, microsecond=999999, tzinfo=tz

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
services:
22
homeassistant:
33
container_name: homeassistant
4-
image: "ghcr.io/home-assistant/home-assistant:stable"
4+
image: "ghcr.io/home-assistant/home-assistant:2025.2.5"
55
volumes:
66
- /etc/localtime:/etc/localtime:ro
77
- ./custom_components/som_energia:/config/custom_components/som_energia:ro

requirements-test.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
pytest
22
pytest-cov
33
pytest-homeassistant-custom-component
4-
aiocsv
5-
aiofiles

0 commit comments

Comments
 (0)