From f2c5ee517b3ecf4f8c4f5bac30786e525a4d90b6 Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Sat, 21 Dec 2024 21:42:18 +0100 Subject: [PATCH] uzsu: fix and improve perday interpolation --- uzsu/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index c57de04c9..f92be3b57 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -1049,14 +1049,15 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): if 'sun' in time and 'series' not in time: next = self._sun(datetime.combine(today, datetime.min.time()).replace(tzinfo=self._timezone), time, timescan) cond_future = next > datetime.now(self._timezone) + cond_istoday = next.date() == datetime.now().date() if cond_future: self.logger.debug(f'{item}: Result parsing time today (sun) {time}: {next}') if entryindex is not None: self._update_suncalc(item, entry, entryindex, next.strftime("%H:%M")) else: - if caller != "dry_run" and not self._items[item]['interpolation'].get('perday'): + if caller != "dry_run" and (not self._items[item]['interpolation'].get('perday') or cond_istoday): self._itpl[item][next.timestamp() * 1000.0] = value - self.logger.debug(f'{item}: Include previous today (sun): {next}, value {value} for interpolation.') + self.logger.debug(f'{item}: Include previous today (sun): {next}, value {value} for interpolation.') if entryindex is not None: self._update_suncalc(item, entry, entryindex, next.strftime("%H:%M")) next = self._sun(datetime.combine(tomorrow, datetime.min.time()).replace( @@ -1074,8 +1075,10 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): next = self._series_get_time(entry, timescan) if next is None: return None, None, False - if caller != "dry_run": + cond_istoday = next.date() == datetime.now().date() + if caller != "dry_run" and (not self._items[item]['interpolation'].get('perday') or cond_istoday): self._itpl[item][next.timestamp() * 1000.0] = value + self.logger.debug(f'{item}: Include {timescan} of series: {next} for interpolation.') rstr = str(entry['rrule']).replace('\n', ';') self.logger.debug(f'{item}: Looking for {timescan} series-related time. Found rrule: {rstr} ' f'with start-time {entry["series"]["timeSeriesMin"]}. Next: {next}')