Skip to content
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.2 (Unreleased)
## 1.1.0 (Unreleased)

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

### Feature Changes
- 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]

## 1.0.1 (03/23/2026)
Setup and submitted to HACs!

Expand Down
19 changes: 17 additions & 2 deletions custom_components/pvoutput_publisher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.const import Platform
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.event import async_track_time_change
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.helpers.dispatcher import async_dispatcher_send
import homeassistant.util.dt as dt_util
Expand Down Expand Up @@ -147,7 +147,22 @@ async def push_data(now: datetime, sys_id=system_id, gen_id=generation_ent_id, c
except Exception as e:
_LOGGER.error("Unexpected error connecting to PVOutput for %s: %s", name, e)

listener = async_track_time_interval(hass, push_data, timedelta(minutes=frequency))
# Smart clock-aligned scheduling (Cron style)
if frequency < 60:
# Creates a list of exact minutes: [0, 5, 10, 15...]
minutes = list(range(0, 60, frequency))
listener = async_track_time_change(hass, push_data, minute=minutes, second=0)
elif frequency == 60:
# Every hour on the dot (xx:00:00)
listener = async_track_time_change(hass, push_data, minute=0, second=0)
elif frequency == 180:
# Every 3 hours on the dot (00:00, 03:00, 06:00...)
hours = list(range(0, 24, 3))
listener = async_track_time_change(hass, push_data, hour=hours, minute=0, second=0)
else:
# Safe fallback just in case
listener = async_track_time_change(hass, push_data, minute=list(range(0, 60, 5)), second=0)

remove_listeners.append(listener)

hass.data[DOMAIN][entry.entry_id] = remove_listeners
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pvoutput_publisher/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"iot_class": "cloud_push",
"issue_tracker": "https://github.com/SourceLabOrg/HomeAssistant-PVOutputPublisher/issues",
"requirements": [],
"version": "1.0.2"
"version": "1.1.0"
}
Loading