Skip to content

Commit b7c8ea0

Browse files
committed
align submissions to PVOutput api
1 parent faf759a commit b7c8ea0

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
The format is based on [Keep a Changelog](http://keepachangelog.com/)
33
and this project adheres to [Semantic Versioning](http://semver.org/).
44

5-
## 1.0.2 (Unreleased)
5+
## 1.1.0 (Unreleased)
66

77
### Bugfixes
88
- Removes `device_class=temperature` restriction when picking your temperature sensor. (Issue#1)[https://github.com/SourceLabOrg/HomeAssistant-PVOutputPublisher/issues/1]
99

10+
### Feature Changes
11+
- Switched to strict, clock-aligned scheduling to prevent time drift and perfectly sync with PVOutput intervals. (Issue#1)[https://github.com/SourceLabOrg/HomeAssistant-PVOutputPublisher/issues/1]
12+
1013
## 1.0.1 (03/23/2026)
1114
Setup and submitted to HACs!
1215

custom_components/pvoutput_publisher/__init__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from homeassistant.config_entries import ConfigEntry
66
from homeassistant.core import HomeAssistant
77
from homeassistant.const import Platform
8-
from homeassistant.helpers.event import async_track_time_interval
8+
from homeassistant.helpers.event import async_track_time_change
99
from homeassistant.helpers.aiohttp_client import async_get_clientsession
1010
from homeassistant.helpers.dispatcher import async_dispatcher_send
1111
import homeassistant.util.dt as dt_util
@@ -147,7 +147,22 @@ async def push_data(now: datetime, sys_id=system_id, gen_id=generation_ent_id, c
147147
except Exception as e:
148148
_LOGGER.error("Unexpected error connecting to PVOutput for %s: %s", name, e)
149149

150-
listener = async_track_time_interval(hass, push_data, timedelta(minutes=frequency))
150+
# Smart clock-aligned scheduling (Cron style)
151+
if frequency < 60:
152+
# Creates a list of exact minutes: [0, 5, 10, 15...]
153+
minutes = list(range(0, 60, frequency))
154+
listener = async_track_time_change(hass, push_data, minute=minutes, second=0)
155+
elif frequency == 60:
156+
# Every hour on the dot (xx:00:00)
157+
listener = async_track_time_change(hass, push_data, minute=0, second=0)
158+
elif frequency == 180:
159+
# Every 3 hours on the dot (00:00, 03:00, 06:00...)
160+
hours = list(range(0, 24, 3))
161+
listener = async_track_time_change(hass, push_data, hour=hours, minute=0, second=0)
162+
else:
163+
# Safe fallback just in case
164+
listener = async_track_time_change(hass, push_data, minute=list(range(0, 60, 5)), second=0)
165+
151166
remove_listeners.append(listener)
152167

153168
hass.data[DOMAIN][entry.entry_id] = remove_listeners

custom_components/pvoutput_publisher/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
"iot_class": "cloud_push",
1010
"issue_tracker": "https://github.com/SourceLabOrg/HomeAssistant-PVOutputPublisher/issues",
1111
"requirements": [],
12-
"version": "1.0.2"
12+
"version": "1.1.0"
1313
}

0 commit comments

Comments
 (0)