From 80a6b16abe2a040f265b1677e1f4444dcce688e4 Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Tue, 12 Sep 2023 23:57:14 +0200 Subject: [PATCH 1/7] uzsu plugin: rename intervall to interval --- uzsu/__init__.py | 105 +++++++++++++++++++++++++---------------------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index 7c4ae7a00..30660807c 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -48,19 +48,19 @@ # time series is mandatory using dict key 'series' # # series: definition of the time series as dict using keys 'active', 'timeSeriesMin', -# 'timeSeriesMax', 'timeSeriesIntervall' +# 'timeSeriesMax', 'timeSeriesinterval' # example: # "series":{"active":true, # "timeSeriesMin":"06:15", # "timeSeriesMax":"15:30", -# "timeSeriesIntervall":"01:00"} +# "timeSeriesinterval":"01:00"} # alternative to 'timeSeriesMax', which indicated the end time of the time series, the key 'timeSeriesCount' # can be used to define the number of cycles to be run # example: # "series":{"active":true, # "timeSeriesMin":"06:15", # "timeSeriesCount":"4", -# "timeSeriesIntervall":"01:00"} +# "timeSeriesinterval":"01:00"} # # # rrule: You can use the recurrence rules documented in the iCalendar RFC for recurrence use of a switching entry. @@ -893,7 +893,8 @@ def _series_calculate(self, item, caller=None, source=None): """ self.logger.debug("Series Calculate method for item {} called by {}. Source: {}".format(item, caller, source)) if not self._items[item].get('list'): - return + issue = "No list entry in UZSU dict for item {}".format(item) + return issue try: mydays = ['MO', 'TU', 'WE', 'TH', 'FR', 'SA', 'SU'] for i, mydict in enumerate(self._items[item]['list']): @@ -906,32 +907,36 @@ def _series_calculate(self, item, caller=None, source=None): try: ##################### seriesbegin, seriesend, daycount, mydict = self._fix_empty_values(mydict) - intervall = mydict['series'].get('timeSeriesIntervall', None) + interval = mydict['series'].get('timeSeriesinterval', None) seriesstart = seriesbegin + endtime = None - if intervall is None or intervall == "": - self.logger.warning("Could not calculate serie for item {}" - " - because intervall is None - {}".format(item, mydict)) - return + if interval is None or interval == "": + issue = "Could not calculate serie for item {}"\ + " - because interval is None - {}".format(item, mydict) + self.logger.warning(issue) + return issue if (daycount == '' or daycount is None) and seriesend is None: - self.logger.warning("Could not calculate series" - " because timeSeriesCount is NONE and TimeSeriesMax is NONE") - return + issue = "Could not calculate series because "\ + "timeSeriesCount is NONE and TimeSeriesMax is NONE" + self.logger.warning(issue) + return issue - intervall = int(intervall.split(":")[0]) * 60 + int(mydict['series']['timeSeriesIntervall'].split(":")[1]) + interval = int(interval.split(":")[0]) * 60 + int(mydict['series']['timeSeriesinterval'].split(":")[1]) - if intervall == 0: - self.logger.warning("Could not calculate serie because intervall is ZERO - {}".format(mydict)) - return + if interval == 0: + issue = "Could not calculate serie because interval is ZERO - {}".format(mydict) + self.logger.warning(issue) + return issue if daycount is not None and daycount != '': - if int(daycount) * intervall >= 1440: + if int(daycount) * interval >= 1440: org_daycount = daycount - daycount = int(1439 / intervall) + daycount = int(1439 / interval) self.logger.warning("Cut your SerieCount to {} -" - " because intervall {} x SerieCount {}" - " is more than 24h".format(daycount, intervall, org_daycount)) + " because interval {} x SerieCount {}" + " is more than 24h".format(daycount, interval, org_daycount)) if 'sun' not in mydict['series']['timeSeriesMin']: starttime = datetime.strptime(mydict['series']['timeSeriesMin'], "%H:%M") @@ -944,7 +949,7 @@ def _series_calculate(self, item, caller=None, source=None): # calculate End of Serie by Count if seriesend is None: endtime = starttime - endtime += timedelta(minutes=intervall * int(daycount)) + endtime += timedelta(minutes=interval * int(daycount)) if seriesend is not None and 'sun' in seriesend: mytime = self._sun(datetime.now().replace(hour=0, minute=0, second=0).astimezone(self._timezone), @@ -964,13 +969,13 @@ def _series_calculate(self, item, caller=None, source=None): original_daycount = daycount if daycount is None: - daycount = int(timediff.total_seconds() / 60 / intervall) + daycount = int(timediff.total_seconds() / 60 / interval) else: - new_daycount = int(timediff.total_seconds() / 60 / intervall) + new_daycount = int(timediff.total_seconds() / 60 / interval) if int(daycount) > new_daycount: - self.logger.warning("Cut your SerieCount to {} - because intervall {}" + self.logger.warning("Cut your SerieCount to {} - because interval {}" " x SerieCount {} is not possible between {} and {}".format( - new_daycount, intervall, daycount, starttime, endtime)) + new_daycount, interval, daycount, starttime, endtime)) daycount = new_daycount ##################### @@ -981,13 +986,13 @@ def _series_calculate(self, item, caller=None, source=None): str(starttime.minute)).time())) mynewlist = [] - intervall = int(mydict['series']['timeSeriesIntervall'].split(":")[0])*60 + \ - int(mydict['series']['timeSeriesIntervall'].split(":")[1]) + interval = int(mydict['series']['timeSeriesinterval'].split(":")[0])*60 + \ + int(mydict['series']['timeSeriesinterval'].split(":")[1]) exceptions = 0 for day in list(rrule): if not mydays[day.weekday()] in mydict['rrule']: continue - myrulenext = "FREQ=MINUTELY;COUNT={};INTERVAL={}".format(daycount, intervall) + myrulenext = "FREQ=MINUTELY;COUNT={};INTERVAL={}".format(daycount, interval) if 'sun' not in mydict['series']['timeSeriesMin']: starttime = datetime.strptime(mydict['series']['timeSeriesMin'], "%H:%M") @@ -1014,7 +1019,7 @@ def _series_calculate(self, item, caller=None, source=None): item, datetime.strftime(starttime, "%H:%M"), datetime.strftime(endtime, "%H:%M"), max_interval.seconds // 3600, max_interval.seconds % 3600//60, - mydict['series']['timeSeriesIntervall'])) + mydict['series']['timeSeriesinterval'])) exceptions += 1 max_interval = int(max_interval.total_seconds() / 60) myrulenext = "FREQ=MINUTELY;COUNT=1;INTERVAL={}".format(max_interval) @@ -1029,13 +1034,14 @@ def _series_calculate(self, item, caller=None, source=None): mytpl = {'seriesMin': str(seriestarttime.time())[:5]} if original_daycount is not None: mytpl['seriesMax'] = str((seriestarttime + - timedelta(minutes=intervall * count)).time())[:5] + timedelta(minutes=interval * count)).time())[:5] else: mytpl['seriesMax'] = "{:02d}".format(endtime.hour) + ":" + \ "{:02d}".format(endtime.minute) mytpl['seriesDay'] = actday mytpl['maxCountCalculated'] = count if exceptions == 0 else 0 - self.logger.debug("Mytpl: {}, count {}, daycount {}, interval {}".format(mytpl, count, daycount, intervall)) + self.logger.debug("Mytpl: {}, count {}, " + "daycount {}, interval {}".format(mytpl, count, daycount, interval)) mynewlist.append(mytpl) count = 0 seriestarttime = None @@ -1051,14 +1057,14 @@ def _series_calculate(self, item, caller=None, source=None): if seriestarttime is not None: mytpl = {'seriesMin': str(seriestarttime.time())[:5]} if original_daycount is not None: - mytpl['seriesMax'] = str((seriestarttime + timedelta(minutes=intervall * count)).time())[:5] + mytpl['seriesMax'] = str((seriestarttime + timedelta(minutes=interval * count)).time())[:5] else: mytpl['seriesMax'] = "{:02d}".format(endtime.hour) + ":" + "{:02d}".format(endtime.minute) mytpl['maxCountCalculated'] = count if exceptions == 0 else 0 mytpl['seriesDay'] = actday self.logger.debug("Mytpl for last time of day: {}," " count {} daycount {}," - " interval {}".format(mytpl, count, original_daycount, intervall)) + " interval {}".format(mytpl, count, original_daycount, interval)) mynewlist.append(mytpl) if mynewlist: @@ -1125,15 +1131,15 @@ def _series_get_time(self, mydict, timescan=''): returnvalue = None seriesbegin, seriesend, daycount, mydict = self._fix_empty_values(mydict) - intervall = mydict['series'].get('timeSeriesIntervall', None) + interval = mydict['series'].get('timeSeriesinterval', None) seriesstart = seriesbegin - if intervall is not None and intervall != "": - intervall = int(intervall.split(":")[0])*60 + int(mydict['series']['timeSeriesIntervall'].split(":")[1]) + if interval is not None and interval != "": + interval = int(interval.split(":")[0])*60 + int(mydict['series']['timeSeriesinterval'].split(":")[1]) else: return returnvalue - if intervall == 0: - self.logger.warning("Could not calculate serie because intervall is ZERO - {}".format(mydict)) + if interval == 0: + self.logger.warning("Could not calculate serie because interval is ZERO - {}".format(mydict)) return returnvalue if 'sun' not in mydict['series']['timeSeriesMin']: @@ -1155,30 +1161,29 @@ def _series_get_time(self, mydict, timescan=''): if endtime < starttime: endtime += timedelta(days=1) timediff = endtime - starttime - daycount = int(timediff.total_seconds() / 60 / intervall) + daycount = int(timediff.total_seconds() / 60 / interval) else: if seriesend is None: endtime = starttime - endtime += timedelta(minutes=intervall * int(daycount)) + endtime += timedelta(minutes=interval * int(daycount)) timediff = endtime - starttime - daycount = int(timediff.total_seconds() / 60 / intervall) + daycount = int(timediff.total_seconds() / 60 / interval) else: endtime = datetime.strptime(seriesend, "%H:%M") timediff = endtime - starttime if daycount is not None and daycount != '': - if seriesend is None and (int(daycount) * intervall >= 1440): + if seriesend is None and (int(daycount) * interval >= 1440): org_count = daycount - count = int(1439 / intervall) - self.logger.warning("Cut your SerieCount to {} - because intervall {}" - " x SerieCount {} is more than 24h".format(count, intervall, org_count)) + count = int(1439 / interval) + self.logger.warning("Cut your SerieCount to {} - because interval {}" + " x SerieCount {} is more than 24h".format(count, interval, org_count)) else: - new_daycount = int(timediff.total_seconds() / 60 / intervall) - #self.logger.debug("new daycount: {}, seriesend {}".format(new_daycount, seriesend)) + new_daycount = int(timediff.total_seconds() / 60 / interval) if int(daycount) > new_daycount: - self.logger.warning("Cut your SerieCount to {} - because intervall {}" + self.logger.warning("Cut your SerieCount to {} - because interval {}" " x SerieCount {} is not possible between {} and {}".format( - new_daycount, intervall, daycount, datetime.strftime(starttime, "%H:%M"), + new_daycount, interval, daycount, datetime.strftime(starttime, "%H:%M"), datetime.strftime(endtime, "%H:%M"))) daycount = new_daycount mylist = OrderedDict() @@ -1191,7 +1196,7 @@ def _series_get_time(self, mydict, timescan=''): timestamp = day mylist[timestamp] = 'x' while mycount < daycount: - timestamp = timestamp + timedelta(minutes=intervall) + timestamp = timestamp + timedelta(minutes=interval) mylist[timestamp] = 'x' mycount += 1 From fc6b3be3f068c8901b9c6b81cb6913301b1b622e Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Tue, 12 Sep 2023 23:58:51 +0200 Subject: [PATCH 2/7] uzsu plugin: minor code changes and improvements regarding PEP8 and variables --- uzsu/__init__.py | 61 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index 30660807c..fca2bd988 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -180,6 +180,7 @@ def stop(self): Stop method for the plugin """ self.logger.debug("stop method called") + self.scheduler_remove('uzsu_sunupdate') for item in self._items: try: self.scheduler_remove('{}'.format(item.property.path)) @@ -195,7 +196,7 @@ def _update_all_suns(self, caller=None): :type caller: str """ for item in self._items: - success = self._update_sun(item) + success = self._update_sun(item, caller="update_all_suns") if success: self.logger.debug('Updating sun info for item {}. Caller: {}'.format(item, caller)) self._update_item(item, 'UZSU Plugin', 'update_all_suns') @@ -223,8 +224,8 @@ def _update_sun(self, item, caller=None): item, caller, self._items[item]['sunrise'], self._items[item]['sunset'])) success = True except Exception as e: - success = False - self.logger.debug("Not updated sun entries for item {}. Error {}".format(item, e)) + success = "Not updated sun entries for item {}. Error {}".format(item, e) + self.logger.debug(success) return success def _update_suncalc(self, item, entry, entryindex, entryvalue): @@ -355,7 +356,8 @@ def _logics_planned(self, item=None): if self._planned.get(item) not in [None, {}, 'notinit'] and self._items[item].get('active') is True: self.logger.info("Item '{}' is going to be set to {} at {}".format( item, self._planned[item]['value'], self._planned[item]['next'])) - self._webdata['items'][item.id()].update({'planned': {'value': self._planned[item]['value'], 'time': self._planned[item]['next']}}) + self._webdata['items'][item.id()].update({'planned': {'value': self._planned[item]['value'], + 'time': self._planned[item]['next']}}) return self._planned[item] elif self._planned.get(item) == 'notinit' and self._items[item].get('active') is True: self.logger.info("Item '{}' is active but not fully initialized yet.".format(item)) @@ -524,26 +526,24 @@ def _update_item(self, item, caller="", comment=""): success = self._get_sun4week(item, caller="_update_item") if success: self.logger.debug('Updated weekly sun info for item {}' - ' caller : {} comment : {}'.format(item, caller, comment)) + ' caller: {} comment: {}'.format(item, caller, comment)) else: self.logger.debug('Issues with updating weekly sun info' - ' for item {} caller : {} comment : {}'.format(item, caller, comment)) - success = False + ' for item {} caller: {} comment: {}'.format(item, caller, comment)) success = self._series_calculate(item, caller, comment) - if success: + if success is True: self.logger.debug('Updated seriesCalculated for item {}' - ' caller : {} comment : {}'.format(item, caller, comment)) + ' caller: {} comment: {}'.format(item, caller, comment)) else: self.logger.debug('Issues with updating seriesCalculated' - ' for item {} caller : {} comment : {}'.format(item, caller, comment)) - success = False + ' for item {} caller: {} comment: {}, issue: {}'.format(item, caller, comment, success)) success = self._update_sun(item, caller="_update_item") - if success: + if success is True: self.logger.debug('Updated sunset/rise calculations for item {}' - ' caller : {} comment : {}'.format(item, caller, comment)) + ' caller: {} comment: {}'.format(item, caller, comment)) else: self.logger.debug('Issues with updating sunset/rise calculations' - ' for item {} caller : {} comment : {}'.format(item, caller, comment)) + ' for item {} caller: {} comment: {}, issue: {}'.format(item, caller, comment, success)) item(self._items[item], caller, comment) self._webdata['items'][item.id()].update({'interpolation': self._items[item].get('interpolation')}) self._webdata['items'][item.id()].update({'active': str(self._items[item].get('active'))}) @@ -562,9 +562,9 @@ def _schedule(self, item, caller=None): This function schedules an item: First the item is removed from the scheduler. If the item is active then the list is searched for the nearest next execution time. No matter if active or not the calculation for the execution time is triggered. - :param item: item to be updated towards the plugin + :param item: item to be updated towards the plugin. :param caller: if given it represents the callers name. If the caller is set - to "dry_run" the evaluation of sun entries takes place but no scheduler will be set + to "dry_run" the evaluation of sun entries takes place but no scheduler will be set. """ if caller != "dry_run": self.scheduler_remove('{}'.format(item.property.path)) @@ -767,6 +767,7 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): if 'time' not in entry: return None, None value = entry['value'] + next = None active = True if caller == "dry_run" else entry['active'] today = datetime.today() tomorrow = today + timedelta(days=1) @@ -791,9 +792,9 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): entry['rrule'], time)) if 'sun' in time: rrule = rrulestr(entry['rrule'], dtstart=datetime.combine( - weekbefore, self._sun(datetime.combine(weekbefore.date(), - datetime.min.time()).replace(tzinfo=self._timezone), - time, timescan).time())) + weekbefore, self._sun(datetime.combine(weekbefore.date(), + datetime.min.time()).replace(tzinfo=self._timezone), + time, timescan).time())) self.logger.debug("Looking for {} sun-related time. Found rrule: {}".format( timescan, str(rrule).replace('\n', ';'))) else: @@ -807,9 +808,9 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): return None, None if 'sun' in time: sleep(0.01) - next = self._sun(datetime.combine(dt.date(), - datetime.min.time()).replace(tzinfo=self._timezone), - time, timescan) + next = self._sun(datetime.combine(dt.date(), + datetime.min.time()).replace(tzinfo=self._timezone), + time, timescan) self.logger.debug("Result parsing time (rrule) {}: {}".format(time, next)) if entryindex is not None and timescan == 'next': self._update_suncalc(item, entry, entryindex, next.strftime("%H:%M")) @@ -854,13 +855,13 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): self._itpl[item][next.timestamp() * 1000.0] = value self.logger.debug("Looking for {} series-related time. Found rrule: {} with start-time . {}".format( timescan, entry['rrule'].replace('\n', ';'), entry['series']['timeSeriesMin'])) - - cond_today = next.date() == today.date() - cond_yesterday = next.date() - timedelta(days=1) == yesterday.date() - cond_tomorrow = next.date() == tomorrow.date() - cond_next = next > datetime.now(self._timezone) - cond_previous_today = next - timedelta(seconds=1) < datetime.now(self._timezone) - cond_previous_yesterday = next - timedelta(days=1) < datetime.now(self._timezone) + + cond_today = False if next is None else next.date() == today.date() + cond_yesterday = False if next is None else next.date() - timedelta(days=1) == yesterday.date() + cond_tomorrow = False if next is None else next.date() == tomorrow.date() + cond_next = False if next is None else next > datetime.now(self._timezone) + cond_previous_today = False if next is None else next - timedelta(seconds=1) < datetime.now(self._timezone) + cond_previous_yesterday = False if next is None else next - timedelta(days=1) < datetime.now(self._timezone) if next and cond_today and cond_next: self._itpl[item][next.timestamp() * 1000.0] = value self.logger.debug("Return next today: {}, value {}".format(next, value)) @@ -959,7 +960,7 @@ def _series_calculate(self, item, caller=None, source=None): elif seriesend is not None and 'sun' not in seriesend: endtime = datetime.strptime(seriesend, "%H:%M") - if seriesend is None: + if seriesend is None and endtime: seriesend = str(endtime.time())[:5] if endtime <= starttime: From cb06e20532e22a8cf5b2b691818ddb0acd1d7fd4 Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Tue, 12 Sep 2023 23:59:28 +0200 Subject: [PATCH 3/7] uzsu plugin: important update for scheduler handling to work with newest changes in core regarding caller --- uzsu/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index fca2bd988..304a82991 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -137,7 +137,7 @@ def run(self): self.logger.debug("run method called") self.alive = True self.scheduler_add('uzsu_sunupdate', self._update_all_suns, - value={'caller': 'scheduler'}, cron=self._suncalculation_cron) + value={'caller': 'Scheduler:UZSU'}, cron=self._suncalculation_cron) self.logger.info("Adding sun update schedule for midnight") for item in self._items: @@ -568,7 +568,7 @@ def _schedule(self, item, caller=None): """ if caller != "dry_run": self.scheduler_remove('{}'.format(item.property.path)) - _caller = "scheduler" + _caller = "Scheduler:UZSU" self.logger.debug('Schedule Item {}, Trigger: {}, Changed by: {}'.format( item, caller, item.changed_by())) else: @@ -717,7 +717,7 @@ def _schedule(self, item, caller=None): self._webdata['items'][item.id()].update({'planned': {'value': _value, 'time': _next.strftime('%d.%m.%Y %H:%M')}}) self._update_count['done'] = self._update_count.get('done') + 1 self.scheduler_add('{}'.format(item.property.path), self._set, - value={'item': item, 'value': _value}, next=_next) + value={'item': item, 'value': _value, 'caller': 'Scheduler'}, next=_next) if self._update_count.get('done') == self._update_count.get('todo'): self.scheduler_trigger('uzsu_sunupdate', by='UZSU Plugin') self._update_count = {'done': 0, 'todo': 0} @@ -736,7 +736,7 @@ def _set(self, item=None, value=None, caller=None): _uzsuitem, _itemvalue = self._get_dependant(item) _uzsuitem(value, 'UZSU Plugin', 'set') self._webdata['items'][item.id()].update({'depend': {'item': _uzsuitem.id(), 'value': str(_itemvalue)}}) - if not caller: + if not caller or caller == "Scheduler": self._schedule(item, caller='set') def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): From 7f9e5d11cacb3f647f0c39af9c33c21bd12ca486 Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Wed, 13 Sep 2023 00:00:53 +0200 Subject: [PATCH 4/7] uzsu plugin: bump version to 1.6.6 --- uzsu/__init__.py | 14 +++++++------- uzsu/plugin.yaml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index 304a82991..5134b0ba4 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -104,7 +104,7 @@ class UZSU(SmartPlugin): ALLOW_MULTIINSTANCE = False - PLUGIN_VERSION = "1.6.5" # item buffer for all uzsu enabled items + PLUGIN_VERSION = "1.6.6" # item buffer for all uzsu enabled items def __init__(self, smarthome): """ @@ -356,7 +356,7 @@ def _logics_planned(self, item=None): if self._planned.get(item) not in [None, {}, 'notinit'] and self._items[item].get('active') is True: self.logger.info("Item '{}' is going to be set to {} at {}".format( item, self._planned[item]['value'], self._planned[item]['next'])) - self._webdata['items'][item.id()].update({'planned': {'value': self._planned[item]['value'], + self._webdata['items'][item.id()].update({'planned': {'value': self._planned[item]['value'], 'time': self._planned[item]['next']}}) return self._planned[item] elif self._planned.get(item) == 'notinit' and self._items[item].get('active') is True: @@ -792,8 +792,8 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): entry['rrule'], time)) if 'sun' in time: rrule = rrulestr(entry['rrule'], dtstart=datetime.combine( - weekbefore, self._sun(datetime.combine(weekbefore.date(), - datetime.min.time()).replace(tzinfo=self._timezone), + weekbefore, self._sun(datetime.combine(weekbefore.date(), + datetime.min.time()).replace(tzinfo=self._timezone), time, timescan).time())) self.logger.debug("Looking for {} sun-related time. Found rrule: {}".format( timescan, str(rrule).replace('\n', ';'))) @@ -808,8 +808,8 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): return None, None if 'sun' in time: sleep(0.01) - next = self._sun(datetime.combine(dt.date(), - datetime.min.time()).replace(tzinfo=self._timezone), + next = self._sun(datetime.combine(dt.date(), + datetime.min.time()).replace(tzinfo=self._timezone), time, timescan) self.logger.debug("Result parsing time (rrule) {}: {}".format(time, next)) if entryindex is not None and timescan == 'next': @@ -855,7 +855,7 @@ def _get_time(self, entry, timescan, item=None, entryindex=None, caller=None): self._itpl[item][next.timestamp() * 1000.0] = value self.logger.debug("Looking for {} series-related time. Found rrule: {} with start-time . {}".format( timescan, entry['rrule'].replace('\n', ';'), entry['series']['timeSeriesMin'])) - + cond_today = False if next is None else next.date() == today.date() cond_yesterday = False if next is None else next.date() - timedelta(days=1) == yesterday.date() cond_tomorrow = False if next is None else next.date() == tomorrow.date() diff --git a/uzsu/plugin.yaml b/uzsu/plugin.yaml index 29bc5e70e..5a0096583 100755 --- a/uzsu/plugin.yaml +++ b/uzsu/plugin.yaml @@ -46,7 +46,7 @@ plugin: keywords: scheduler uzsu trigger series support: https://knx-user-forum.de/forum/supportforen/smarthome-py/1364692-supportthread-für-uzsu-plugin - version: 1.6.5 # Plugin version + version: 1.6.6 # Plugin version sh_minversion: 1.6 # minimum shNG version to use this plugin # sh_maxversion: # maximum shNG version to use this plugin (leave empty if latest) multi_instance: False # plugin supports multi instance From 35b1ffd795cbd8c0dfc4554d2888b4284968ec5b Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Wed, 13 Sep 2023 10:34:55 +0200 Subject: [PATCH 5/7] uzsu plugin: revert timeSeriesInterval to timeSeriesIntervall to stay compatible with all SV versions --- uzsu/__init__.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index 5134b0ba4..ae8f9d1a6 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -48,19 +48,19 @@ # time series is mandatory using dict key 'series' # # series: definition of the time series as dict using keys 'active', 'timeSeriesMin', -# 'timeSeriesMax', 'timeSeriesinterval' +# 'timeSeriesMax', 'timeSeriesintervall' # example: # "series":{"active":true, # "timeSeriesMin":"06:15", # "timeSeriesMax":"15:30", -# "timeSeriesinterval":"01:00"} +# "timeSeriesintervall":"01:00"} # alternative to 'timeSeriesMax', which indicated the end time of the time series, the key 'timeSeriesCount' # can be used to define the number of cycles to be run # example: # "series":{"active":true, # "timeSeriesMin":"06:15", # "timeSeriesCount":"4", -# "timeSeriesinterval":"01:00"} +# "timeSeriesintervall":"01:00"} # # # rrule: You can use the recurrence rules documented in the iCalendar RFC for recurrence use of a switching entry. @@ -908,7 +908,7 @@ def _series_calculate(self, item, caller=None, source=None): try: ##################### seriesbegin, seriesend, daycount, mydict = self._fix_empty_values(mydict) - interval = mydict['series'].get('timeSeriesinterval', None) + interval = mydict['series'].get('timeSeriesintervall', None) seriesstart = seriesbegin endtime = None @@ -924,7 +924,7 @@ def _series_calculate(self, item, caller=None, source=None): self.logger.warning(issue) return issue - interval = int(interval.split(":")[0]) * 60 + int(mydict['series']['timeSeriesinterval'].split(":")[1]) + interval = int(interval.split(":")[0]) * 60 + int(mydict['series']['timeSeriesintervall'].split(":")[1]) if interval == 0: issue = "Could not calculate serie because interval is ZERO - {}".format(mydict) @@ -987,8 +987,8 @@ def _series_calculate(self, item, caller=None, source=None): str(starttime.minute)).time())) mynewlist = [] - interval = int(mydict['series']['timeSeriesinterval'].split(":")[0])*60 + \ - int(mydict['series']['timeSeriesinterval'].split(":")[1]) + interval = int(mydict['series']['timeSeriesintervall'].split(":")[0])*60 + \ + int(mydict['series']['timeSeriesintervall'].split(":")[1]) exceptions = 0 for day in list(rrule): if not mydays[day.weekday()] in mydict['rrule']: @@ -1020,7 +1020,7 @@ def _series_calculate(self, item, caller=None, source=None): item, datetime.strftime(starttime, "%H:%M"), datetime.strftime(endtime, "%H:%M"), max_interval.seconds // 3600, max_interval.seconds % 3600//60, - mydict['series']['timeSeriesinterval'])) + mydict['series']['timeSeriesintervall'])) exceptions += 1 max_interval = int(max_interval.total_seconds() / 60) myrulenext = "FREQ=MINUTELY;COUNT=1;INTERVAL={}".format(max_interval) @@ -1132,11 +1132,11 @@ def _series_get_time(self, mydict, timescan=''): returnvalue = None seriesbegin, seriesend, daycount, mydict = self._fix_empty_values(mydict) - interval = mydict['series'].get('timeSeriesinterval', None) + interval = mydict['series'].get('timeSeriesintervall', None) seriesstart = seriesbegin if interval is not None and interval != "": - interval = int(interval.split(":")[0])*60 + int(mydict['series']['timeSeriesinterval'].split(":")[1]) + interval = int(interval.split(":")[0])*60 + int(mydict['series']['timeSeriesintervall'].split(":")[1]) else: return returnvalue if interval == 0: From c26724b4ecd086add2c626d998024be0b5ac607b Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Thu, 14 Sep 2023 11:19:52 +0200 Subject: [PATCH 6/7] uzsu plugin: replace caller UZSU Plugin by longname of plugin --- uzsu/__init__.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index ae8f9d1a6..85922c033 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -126,6 +126,7 @@ def __init__(self, smarthome): self._webdata = {'sunCalculated': {}, 'items': {}} self._update_count = {'todo': 0, 'done': 0} self._itpl = {} + self._pluginname = self.get_fullname() self.init_webinterface(WebInterface) self.logger.info("Init with timezone {}".format(self._timezone)) @@ -145,7 +146,7 @@ def run(self): self._items[item]['interpolation']['itemtype'] = self._add_type(item) self._lastvalues[item] = None self._webdata['items'][item.id()].update({'lastvalue': '-'}) - self._update_item(item, 'UZSU Plugin', 'run') + self._update_item(item, self._pluginname, 'run') cond1 = self._items[item].get('active') and self._items[item]['active'] is True cond2 = self._items[item].get('list') if cond1 and cond2: @@ -158,7 +159,7 @@ def run(self): # remove lastvalue dict entry, it is not used anymore try: self._items[item].pop('lastvalue') - self._update_item(item, 'UZSU Plugin', 'lastvalue removed') + self._update_item(item, self._pluginname, 'lastvalue removed') self.logger.debug("Item '{}': removed lastvalue dict entry as it is deprecated.".format(item)) except Exception: pass @@ -199,7 +200,7 @@ def _update_all_suns(self, caller=None): success = self._update_sun(item, caller="update_all_suns") if success: self.logger.debug('Updating sun info for item {}. Caller: {}'.format(item, caller)) - self._update_item(item, 'UZSU Plugin', 'update_all_suns') + self._update_item(item, self._pluginname, 'update_all_suns') def _update_sun(self, item, caller=None): """ @@ -239,12 +240,12 @@ def _update_suncalc(self, item, entry, entryindex, entryvalue): if entry.get('calculated') and entryvalue is None: self.logger.debug("No sunset/rise in time for current entry {}. Removing calculated value.".format(entry)) self._items[item]['list'][entryindex].pop('calculated') - self._update_item(item, 'UZSU Plugin', 'update_sun') + self._update_item(item, self._pluginname, 'update_sun') elif update is True and not entry.get('calculated') == entryvalue: self.logger.debug("Updated calculated time for item {} entry {} with value {}.".format( item, self._items[item]['list'][entryindex], entryvalue)) self._items[item]['list'][entryindex]['calculated'] = entryvalue - self._update_item(item, 'UZSU Plugin', 'update_sun') + self._update_item(item, self._pluginname, 'update_sun') elif entry.get('calculated'): self.logger.debug("Sun calculation {} entry not updated for item {} with value {}".format( entryvalue, item, entry.get('calculated'))) @@ -305,7 +306,7 @@ def _logics_activate(self, activevalue=None, item=None): self._items[item] = item() self._items[item]['active'] = activevalue self.logger.info("Item {} is set via logic to: {}".format(item, activevalue)) - self._update_item(item, 'UZSU Plugin', 'logic') + self._update_item(item, self._pluginname, 'logic') return activevalue if activevalue is None: return self._items[item].get('active') @@ -322,7 +323,7 @@ def _logics_interpolation(self, intpl_type=None, interval=None, backintime=None, self._items[item]['interpolation']['initage'] = int(backintime) self.logger.info("Item {} interpolation is set via logic to: type={}, interval={}, backintime={}".format( item, intpl_type, abs(interval), backintime)) - self._update_item(item, 'UZSU Plugin', 'logic') + self._update_item(item, self._pluginname, 'logic') return self._items[item].get('interpolation') def _logics_clear(self, clear=False, item=None): @@ -335,7 +336,7 @@ def _logics_clear(self, clear=False, item=None): self._items[item].clear() self._items[item] = {'interpolation': {}, 'active': False} self.logger.info("UZSU settings for item '{}' are cleared".format(item)) - self._update_item(item, 'UZSU Plugin', 'clear') + self._update_item(item, self._pluginname, 'clear') return True else: return False @@ -429,7 +430,7 @@ def parse_item(self, item): self._items[item]['list'][entry].pop('delayedExec', None) self._webdata['items'].update({item.id(): {}}) - self._update_item(item, 'UZSU Plugin', 'init') + self._update_item(item, self._pluginname, 'init') self._planned.update({item: 'notinit'}) self._webdata['items'][item.id()].update({'planned': {'value': '-', 'time': '-'}}) @@ -478,7 +479,7 @@ def _check_rruleandplanned(self, item): self.logger.warning("Error creating rrule: {}".format(err)) if count > 0: self.logger.debug("Updated {} rrule entries for item: {}".format(count, item)) - self._update_item(item, 'UZSU Plugin', 'create_rrule') + self._update_item(item, self._pluginname, 'create_rrule') if _inactive >= len(self._items[item]['list']): self._planned.update({item: None}) self._webdata['items'][item.id()].update({'planned': {'value': '-', 'time': '-'}}) @@ -492,7 +493,7 @@ def update_item(self, item, caller=None, source=None, dest=None): :param source: if given it represents the source :param dest: if given it represents the dest """ - cond = (not caller == 'UZSU Plugin') or source == 'logic' + cond = (not caller == self._pluginname) or source == 'logic' self.logger.debug('Update Item {}, Caller {}, Source {}, Dest {}. Will update: {}'.format( item, caller, source, dest, cond)) if not source == 'create_rrule': @@ -520,7 +521,7 @@ def update_item(self, item, caller=None, source=None, dest=None): self._schedule(item, caller='dry_run') if self._items[item] != self.itemsApi.return_item(str(item)) and cond: - self._update_item(item, 'UZSU Plugin', 'update') + self._update_item(item, self._pluginname, 'update') def _update_item(self, item, caller="", comment=""): success = self._get_sun4week(item, caller="_update_item") @@ -628,7 +629,7 @@ def _schedule(self, item, caller=None): if _interval < 0: _interval = abs(int(_interval)) self._items[item]['interpolation']['interval'] = _interval - self._update_item(item, 'UZSU Plugin', 'intervalchange') + self._update_item(item, self._pluginname, 'intervalchange') _interpolation = self._items[item]['interpolation'].get('type') _interpolation = self._interpolation_type if not _interpolation else _interpolation _initage = self._items[item]['interpolation'].get('initage') @@ -663,7 +664,7 @@ def _schedule(self, item, caller=None): self.logger.info("Looking if there was a value set after {} for item {}".format( _timediff, item)) self._items[item]['interpolation']['initialized'] = True - self._update_item(item, 'UZSU Plugin', 'init') + self._update_item(item, self._pluginname, 'init') if cond1 and not cond2 and cond3 and cond6: self._set(item=item, value=_initvalue, caller=_caller) self.logger.info("Updated item {} on startup with value {} from time {}".format( @@ -709,7 +710,7 @@ def _schedule(self, item, caller=None): " to not enough values set in the UZSU.".format(_value, item)) if _reset_interpolation is True: self._items[item]['interpolation']['type'] = 'none' - self._update_item(item, 'UZSU Plugin', 'reset_interpolation') + self._update_item(item, self._pluginname, 'reset_interpolation') if _caller != "dry_run": self.logger.debug("will add scheduler named uzsu_{} with datetime {} and tzinfo {}" " and value {}".format(item.property.path, _next, _next.tzinfo, _value)) @@ -719,7 +720,7 @@ def _schedule(self, item, caller=None): self.scheduler_add('{}'.format(item.property.path), self._set, value={'item': item, 'value': _value, 'caller': 'Scheduler'}, next=_next) if self._update_count.get('done') == self._update_count.get('todo'): - self.scheduler_trigger('uzsu_sunupdate', by='UZSU Plugin') + self.scheduler_trigger('uzsu_sunupdate', by=self._pluginname) self._update_count = {'done': 0, 'todo': 0} elif self._items[item].get('active') is True and self._items[item].get('list'): self.logger.warning("item '{}' is active but has no active entries.".format(item)) @@ -734,7 +735,7 @@ def _set(self, item=None, value=None, caller=None): :param caller: if given it represents the callers name """ _uzsuitem, _itemvalue = self._get_dependant(item) - _uzsuitem(value, 'UZSU Plugin', 'set') + _uzsuitem(value, self._pluginname, 'set') self._webdata['items'][item.id()].update({'depend': {'item': _uzsuitem.id(), 'value': str(_itemvalue)}}) if not caller or caller == "Scheduler": self._schedule(item, caller='set') From 825828c0daaba106610166c6dcfea1ad6da41592 Mon Sep 17 00:00:00 2001 From: Onkel Andy Date: Sat, 16 Sep 2023 16:25:08 +0200 Subject: [PATCH 7/7] uzsu plugin: re-fix timeseriesintervall --- uzsu/__init__.py | 55 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/uzsu/__init__.py b/uzsu/__init__.py index 85922c033..f752f29d8 100755 --- a/uzsu/__init__.py +++ b/uzsu/__init__.py @@ -48,19 +48,19 @@ # time series is mandatory using dict key 'series' # # series: definition of the time series as dict using keys 'active', 'timeSeriesMin', -# 'timeSeriesMax', 'timeSeriesintervall' +# 'timeSeriesMax', 'timeSeriesIntervall' # example: # "series":{"active":true, # "timeSeriesMin":"06:15", # "timeSeriesMax":"15:30", -# "timeSeriesintervall":"01:00"} +# "timeSeriesIntervall":"01:00"} # alternative to 'timeSeriesMax', which indicated the end time of the time series, the key 'timeSeriesCount' # can be used to define the number of cycles to be run # example: # "series":{"active":true, # "timeSeriesMin":"06:15", # "timeSeriesCount":"4", -# "timeSeriesintervall":"01:00"} +# "timeSeriesIntervall":"01:00"} # # # rrule: You can use the recurrence rules documented in the iCalendar RFC for recurrence use of a switching entry. @@ -126,7 +126,6 @@ def __init__(self, smarthome): self._webdata = {'sunCalculated': {}, 'items': {}} self._update_count = {'todo': 0, 'done': 0} self._itpl = {} - self._pluginname = self.get_fullname() self.init_webinterface(WebInterface) self.logger.info("Init with timezone {}".format(self._timezone)) @@ -146,7 +145,7 @@ def run(self): self._items[item]['interpolation']['itemtype'] = self._add_type(item) self._lastvalues[item] = None self._webdata['items'][item.id()].update({'lastvalue': '-'}) - self._update_item(item, self._pluginname, 'run') + self._update_item(item, 'UZSU Plugin', 'run') cond1 = self._items[item].get('active') and self._items[item]['active'] is True cond2 = self._items[item].get('list') if cond1 and cond2: @@ -159,7 +158,7 @@ def run(self): # remove lastvalue dict entry, it is not used anymore try: self._items[item].pop('lastvalue') - self._update_item(item, self._pluginname, 'lastvalue removed') + self._update_item(item, 'UZSU Plugin', 'lastvalue removed') self.logger.debug("Item '{}': removed lastvalue dict entry as it is deprecated.".format(item)) except Exception: pass @@ -200,7 +199,7 @@ def _update_all_suns(self, caller=None): success = self._update_sun(item, caller="update_all_suns") if success: self.logger.debug('Updating sun info for item {}. Caller: {}'.format(item, caller)) - self._update_item(item, self._pluginname, 'update_all_suns') + self._update_item(item, 'UZSU Plugin', 'update_all_suns') def _update_sun(self, item, caller=None): """ @@ -240,12 +239,12 @@ def _update_suncalc(self, item, entry, entryindex, entryvalue): if entry.get('calculated') and entryvalue is None: self.logger.debug("No sunset/rise in time for current entry {}. Removing calculated value.".format(entry)) self._items[item]['list'][entryindex].pop('calculated') - self._update_item(item, self._pluginname, 'update_sun') + self._update_item(item, 'UZSU Plugin', 'update_sun') elif update is True and not entry.get('calculated') == entryvalue: self.logger.debug("Updated calculated time for item {} entry {} with value {}.".format( item, self._items[item]['list'][entryindex], entryvalue)) self._items[item]['list'][entryindex]['calculated'] = entryvalue - self._update_item(item, self._pluginname, 'update_sun') + self._update_item(item, 'UZSU Plugin', 'update_sun') elif entry.get('calculated'): self.logger.debug("Sun calculation {} entry not updated for item {} with value {}".format( entryvalue, item, entry.get('calculated'))) @@ -306,7 +305,7 @@ def _logics_activate(self, activevalue=None, item=None): self._items[item] = item() self._items[item]['active'] = activevalue self.logger.info("Item {} is set via logic to: {}".format(item, activevalue)) - self._update_item(item, self._pluginname, 'logic') + self._update_item(item, 'UZSU Plugin', 'logic') return activevalue if activevalue is None: return self._items[item].get('active') @@ -323,7 +322,7 @@ def _logics_interpolation(self, intpl_type=None, interval=None, backintime=None, self._items[item]['interpolation']['initage'] = int(backintime) self.logger.info("Item {} interpolation is set via logic to: type={}, interval={}, backintime={}".format( item, intpl_type, abs(interval), backintime)) - self._update_item(item, self._pluginname, 'logic') + self._update_item(item, 'UZSU Plugin', 'logic') return self._items[item].get('interpolation') def _logics_clear(self, clear=False, item=None): @@ -336,7 +335,7 @@ def _logics_clear(self, clear=False, item=None): self._items[item].clear() self._items[item] = {'interpolation': {}, 'active': False} self.logger.info("UZSU settings for item '{}' are cleared".format(item)) - self._update_item(item, self._pluginname, 'clear') + self._update_item(item, 'UZSU Plugin', 'clear') return True else: return False @@ -430,7 +429,7 @@ def parse_item(self, item): self._items[item]['list'][entry].pop('delayedExec', None) self._webdata['items'].update({item.id(): {}}) - self._update_item(item, self._pluginname, 'init') + self._update_item(item, 'UZSU Plugin', 'init') self._planned.update({item: 'notinit'}) self._webdata['items'][item.id()].update({'planned': {'value': '-', 'time': '-'}}) @@ -479,7 +478,7 @@ def _check_rruleandplanned(self, item): self.logger.warning("Error creating rrule: {}".format(err)) if count > 0: self.logger.debug("Updated {} rrule entries for item: {}".format(count, item)) - self._update_item(item, self._pluginname, 'create_rrule') + self._update_item(item, 'UZSU Plugin', 'create_rrule') if _inactive >= len(self._items[item]['list']): self._planned.update({item: None}) self._webdata['items'][item.id()].update({'planned': {'value': '-', 'time': '-'}}) @@ -493,7 +492,7 @@ def update_item(self, item, caller=None, source=None, dest=None): :param source: if given it represents the source :param dest: if given it represents the dest """ - cond = (not caller == self._pluginname) or source == 'logic' + cond = (not caller == 'UZSU Plugin') or source == 'logic' self.logger.debug('Update Item {}, Caller {}, Source {}, Dest {}. Will update: {}'.format( item, caller, source, dest, cond)) if not source == 'create_rrule': @@ -521,7 +520,7 @@ def update_item(self, item, caller=None, source=None, dest=None): self._schedule(item, caller='dry_run') if self._items[item] != self.itemsApi.return_item(str(item)) and cond: - self._update_item(item, self._pluginname, 'update') + self._update_item(item, 'UZSU Plugin', 'update') def _update_item(self, item, caller="", comment=""): success = self._get_sun4week(item, caller="_update_item") @@ -629,7 +628,7 @@ def _schedule(self, item, caller=None): if _interval < 0: _interval = abs(int(_interval)) self._items[item]['interpolation']['interval'] = _interval - self._update_item(item, self._pluginname, 'intervalchange') + self._update_item(item, 'UZSU Plugin', 'intervalchange') _interpolation = self._items[item]['interpolation'].get('type') _interpolation = self._interpolation_type if not _interpolation else _interpolation _initage = self._items[item]['interpolation'].get('initage') @@ -664,7 +663,7 @@ def _schedule(self, item, caller=None): self.logger.info("Looking if there was a value set after {} for item {}".format( _timediff, item)) self._items[item]['interpolation']['initialized'] = True - self._update_item(item, self._pluginname, 'init') + self._update_item(item, 'UZSU Plugin', 'init') if cond1 and not cond2 and cond3 and cond6: self._set(item=item, value=_initvalue, caller=_caller) self.logger.info("Updated item {} on startup with value {} from time {}".format( @@ -710,7 +709,7 @@ def _schedule(self, item, caller=None): " to not enough values set in the UZSU.".format(_value, item)) if _reset_interpolation is True: self._items[item]['interpolation']['type'] = 'none' - self._update_item(item, self._pluginname, 'reset_interpolation') + self._update_item(item, 'UZSU Plugin', 'reset_interpolation') if _caller != "dry_run": self.logger.debug("will add scheduler named uzsu_{} with datetime {} and tzinfo {}" " and value {}".format(item.property.path, _next, _next.tzinfo, _value)) @@ -720,7 +719,7 @@ def _schedule(self, item, caller=None): self.scheduler_add('{}'.format(item.property.path), self._set, value={'item': item, 'value': _value, 'caller': 'Scheduler'}, next=_next) if self._update_count.get('done') == self._update_count.get('todo'): - self.scheduler_trigger('uzsu_sunupdate', by=self._pluginname) + self.scheduler_trigger('uzsu_sunupdate', by='UZSU Plugin') self._update_count = {'done': 0, 'todo': 0} elif self._items[item].get('active') is True and self._items[item].get('list'): self.logger.warning("item '{}' is active but has no active entries.".format(item)) @@ -735,7 +734,7 @@ def _set(self, item=None, value=None, caller=None): :param caller: if given it represents the callers name """ _uzsuitem, _itemvalue = self._get_dependant(item) - _uzsuitem(value, self._pluginname, 'set') + _uzsuitem(value, 'UZSU Plugin', 'set') self._webdata['items'][item.id()].update({'depend': {'item': _uzsuitem.id(), 'value': str(_itemvalue)}}) if not caller or caller == "Scheduler": self._schedule(item, caller='set') @@ -909,7 +908,7 @@ def _series_calculate(self, item, caller=None, source=None): try: ##################### seriesbegin, seriesend, daycount, mydict = self._fix_empty_values(mydict) - interval = mydict['series'].get('timeSeriesintervall', None) + interval = mydict['series'].get('timeSeriesIntervall', None) seriesstart = seriesbegin endtime = None @@ -925,7 +924,7 @@ def _series_calculate(self, item, caller=None, source=None): self.logger.warning(issue) return issue - interval = int(interval.split(":")[0]) * 60 + int(mydict['series']['timeSeriesintervall'].split(":")[1]) + interval = int(interval.split(":")[0]) * 60 + int(mydict['series']['timeSeriesIntervall'].split(":")[1]) if interval == 0: issue = "Could not calculate serie because interval is ZERO - {}".format(mydict) @@ -988,8 +987,8 @@ def _series_calculate(self, item, caller=None, source=None): str(starttime.minute)).time())) mynewlist = [] - interval = int(mydict['series']['timeSeriesintervall'].split(":")[0])*60 + \ - int(mydict['series']['timeSeriesintervall'].split(":")[1]) + interval = int(mydict['series']['timeSeriesIntervall'].split(":")[0])*60 + \ + int(mydict['series']['timeSeriesIntervall'].split(":")[1]) exceptions = 0 for day in list(rrule): if not mydays[day.weekday()] in mydict['rrule']: @@ -1021,7 +1020,7 @@ def _series_calculate(self, item, caller=None, source=None): item, datetime.strftime(starttime, "%H:%M"), datetime.strftime(endtime, "%H:%M"), max_interval.seconds // 3600, max_interval.seconds % 3600//60, - mydict['series']['timeSeriesintervall'])) + mydict['series']['timeSeriesIntervall'])) exceptions += 1 max_interval = int(max_interval.total_seconds() / 60) myrulenext = "FREQ=MINUTELY;COUNT=1;INTERVAL={}".format(max_interval) @@ -1133,11 +1132,11 @@ def _series_get_time(self, mydict, timescan=''): returnvalue = None seriesbegin, seriesend, daycount, mydict = self._fix_empty_values(mydict) - interval = mydict['series'].get('timeSeriesintervall', None) + interval = mydict['series'].get('timeSeriesIntervall', None) seriesstart = seriesbegin if interval is not None and interval != "": - interval = int(interval.split(":")[0])*60 + int(mydict['series']['timeSeriesintervall'].split(":")[1]) + interval = int(interval.split(":")[0])*60 + int(mydict['series']['timeSeriesIntervall'].split(":")[1]) else: return returnvalue if interval == 0: