Skip to content

Commit

Permalink
Interval 7 days
Browse files Browse the repository at this point in the history
  • Loading branch information
cyr-ius committed Oct 21, 2023
1 parent 2c1e8ce commit 22d9fe9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions custom_components/myelectricaldata/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Data Update Coordinator."""
from __future__ import annotations

from datetime import datetime as dt, timedelta
import logging
from datetime import datetime as dt
from datetime import timedelta
from typing import Any

from myelectricaldatapy import EnedisByPDL, EnedisException, LimitReached
Expand All @@ -12,13 +13,6 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
from .helpers import (
async_get_db_infos,
async_get_last_infos,
map_attributes,
next_date,
async_add_statistics,
)

from .const import (
CONF_AUTH,
Expand All @@ -32,7 +26,16 @@
CONF_RULE_START_TIME,
CONF_SERVICE,
CONF_TEMPO,
CONSUMPTION_DETAIL,
DOMAIN,
PRODUCTION_DETAIL,
)
from .helpers import (
async_add_statistics,
async_get_db_infos,
async_get_last_infos,
map_attributes,
next_date,
)

SCAN_INTERVAL = timedelta(hours=3)
Expand Down Expand Up @@ -96,9 +99,15 @@ async def _async_update_data(self) -> dict[str, Any]:
dt_start, cum_values, cum_prices = await async_get_last_infos(
self.hass, attrs
)

end = None
if service in [CONSUMPTION_DETAIL , PRODUCTION_DETAIL]:
end = next_date(dt_start, service) + timedelta(days=6)

self.api.set_collects(
service=service,
start=next_date(dt_start, service),
end=end,
intervals=intervals,
prices=opt.get(CONF_PRICINGS),
cum_value=cum_values,
Expand Down
2 changes: 1 addition & 1 deletion custom_components/myelectricaldata/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"issue_tracker": "https://github.com/cyr-ius/hass-myelectricaldata/issues",
"loggers": ["myelectricaldatapy"],
"requirements": ["myelectricaldatapy==2.1.2"],
"version": "1.2.1"
"version": "1.2.2"
}

0 comments on commit 22d9fe9

Please sign in to comment.