From a18540298c9f226b8f66cebb3ebdd60a12c21e15 Mon Sep 17 00:00:00 2001 From: sisamiwe Date: Wed, 13 Nov 2024 17:22:00 +0100 Subject: [PATCH] DB_ADDON: - use item_attributes direct from item_attributes_master.py - add handling of pause_item - add deinit() if plugin start fails - rework parse_item sub methods - extend some functions to get result as sum or list - --- db_addon/__init__.py | 4 ++-- db_addon/webif/__init__.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/db_addon/__init__.py b/db_addon/__init__.py index c0542f608..45e802122 100644 --- a/db_addon/__init__.py +++ b/db_addon/__init__.py @@ -2713,7 +2713,7 @@ def _query_log_timestamp(self, func: str, item_id: int, ts_start: int, ts_end: i 'last': 'LIMIT 1 ', } - _where = "item_id = :item_id AND time <= :ts_start " if func == "next" else "item_id = :item_id AND time BETWEEN :ts_start AND :ts_end " + _where = "item_id = :item_id AND time <= :ts_end " if func == "next" else "item_id = :item_id AND time BETWEEN :ts_start AND :ts_end " _db_table = 'log ' @@ -2765,7 +2765,7 @@ def _query_log_timestamp(self, func: str, item_id: int, ts_start: int, ts_end: i # set params params = {'item_id': item_id, 'ts_start': ts_start, 'ts_end': ts_end} if func == "next": - params.pop('ts_end', None) + params.pop('ts_start', None) # assemble query query = f"SELECT {_select[func]}FROM {_db_table}WHERE {_where}{_group_by.get(group, '')}{_order.get(func, '')}{_limit.get(func, '')}{_table_alias.get(func, '')}{_group_by.get(group2, '')}".strip() diff --git a/db_addon/webif/__init__.py b/db_addon/webif/__init__.py index 268a54456..bff423039 100644 --- a/db_addon/webif/__init__.py +++ b/db_addon/webif/__init__.py @@ -116,7 +116,6 @@ def get_data_html(self, dataSet=None): data['items'][item.property.path]['last_update'] = item.property.last_update.strftime('%d.%m.%Y %H:%M:%S') data['items'][item.property.path]['last_change'] = item.property.last_change.strftime('%d.%m.%Y %H:%M:%S') - data['plugin_suspended'] = self.plugin.suspended data['maintenance'] = True if self.plugin.log_level == 10 else False data['queue_length'] = self.plugin.queue_backlog() data['active_queue_item'] = self.plugin.active_queue_item