summaryrefslogtreecommitdiff
path: root/src/home
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-11-06 20:09:49 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-11-06 20:09:49 +0300
commit2b70f151eed4853c62019efd8119c0d917abf8d2 (patch)
tree1c095aecbc258348ba6f084ed130cfb5c7e4661b /src/home
parentae2bfdcd68f312c47f9699917ccb13302f401ba7 (diff)
api: inverter methods
Diffstat (limited to 'src/home')
-rw-r--r--src/home/api/web_api_client.py15
-rw-r--r--src/home/database/inverter.py2
-rw-r--r--src/home/database/inverter_time_formats.py2
3 files changed, 17 insertions, 2 deletions
diff --git a/src/home/api/web_api_client.py b/src/home/api/web_api_client.py
index 4a9f4bc..2884ddb 100644
--- a/src/home/api/web_api_client.py
+++ b/src/home/api/web_api_client.py
@@ -106,7 +106,20 @@ class WebAPIClient:
return MediaNodeClient.record_list_from_serialized(files)
return files
- def _process_sound_sensor_hits_data(self, data: List[dict]) -> List[dict]:
+ def inverter_get_consumed_energy(self, s_from: str, s_to: str):
+ return self._post('inverter/get_consumed_energy/', {
+ 'from': s_from,
+ 'to': s_to
+ })
+
+ def inverter_get_grid_consumed_energy(self, s_from: str, s_to: str):
+ return self._post('inverter/get_grid_consumed_energy/', {
+ 'from': s_from,
+ 'to': s_to
+ })
+
+ @staticmethod
+ def _process_sound_sensor_hits_data(data: List[dict]) -> List[dict]:
for item in data:
item['time'] = datetime.fromtimestamp(item['time'])
return data
diff --git a/src/home/database/inverter.py b/src/home/database/inverter.py
index 1e967c4..fc3f74f 100644
--- a/src/home/database/inverter.py
+++ b/src/home/database/inverter.py
@@ -1,5 +1,5 @@
from time import time
-from datetime import datetime
+from datetime import datetime, timedelta
from typing import Optional
from collections import namedtuple
diff --git a/src/home/database/inverter_time_formats.py b/src/home/database/inverter_time_formats.py
new file mode 100644
index 0000000..7c37d30
--- /dev/null
+++ b/src/home/database/inverter_time_formats.py
@@ -0,0 +1,2 @@
+FormatTime = '%Y-%m-%d %H:%M:%S'
+FormatDate = '%Y-%m-%d'