Skip to content

Commit 33886f1

Browse files
committed
Moving to version 0.0.28
1 parent 168f48d commit 33886f1

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.0.28
2+
3+
* Added new function get_inverter_day_stats (by jgonzalezzitu)
4+
* Extended get_battery_day_stats function to retrieve more data (by jgonzalezzitu)
5+
16
# 0.0.27
27

38
* Added tests for README examples

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = fusion_solar_py
3-
version = 0.0.27
3+
version = 0.0.28
44
author = Johannes Griss
55
author_email = johannes.griss@meduniwien.ac.at
66
description = A simply API to the Huawei Fusion Solar web interface.

src/fusion_solar_py/client.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ def get_battery_basic_stats(self, battery_id: str) -> BatteryStatus:
736736
return battery_status
737737

738738
@logged_in
739-
def get_battery_day_stats(self, battery_id: str, signalIds: [str] = ["30005", "30007"],query_time: int = None) -> dict:
739+
def get_battery_day_stats(self, battery_id: str, signalIds: list[str] = ["30005", "30007"],query_time: int = None) -> dict:
740740
"""Retrieves the SOC (state of charge) in % and charge/discharge power in kW of
741741
the battery for the current day.
742742
:param battery_id: The battery's id
@@ -784,8 +784,8 @@ def get_battery_day_stats(self, battery_id: str, signalIds: [str] = ["30005", "3
784784

785785
return battery_data["data"]
786786

787-
@logged_in
788-
def get_inverter_day_stats(self, inverter_id: str, signalIds: [str] = ["30007"],query_time: int = None) -> dict:
787+
@logged_in
788+
def get_inverter_day_stats(self, inverter_id: str, signalIds: list[str] = ["30007"],query_time: int = None) -> dict:
789789
"""Retrieves data of
790790
the inverter for the current day (or another day).
791791
:param inverter_id: The inverter's id
@@ -809,9 +809,12 @@ def get_inverter_day_stats(self, inverter_id: str, signalIds: [str] = ["30007"],
809809
:type signalIds: [str]
810810
:return: The complete data structure as a dict
811811
"""
812-
current_time = round(time.time() * 1000)
812+
# either use the user supplied time or the current one
813813
if query_time is not None:
814814
current_time = query_time
815+
else:
816+
current_time = round(time.time() * 1000)
817+
815818
r = self._session.get(
816819
url=f"https://{self._huawei_subdomain}.fusionsolar.huawei.com/rest/pvms/web/device/v1/device-history-data",
817820
params={
@@ -821,16 +824,16 @@ def get_inverter_day_stats(self, inverter_id: str, signalIds: [str] = ["30007"],
821824
"_": current_time,
822825
},
823826
)
827+
824828
r.raise_for_status()
825-
battery_data = r.json()
829+
inverter_data = r.json()
826830

827-
if not battery_data["success"] or "data" not in battery_data:
831+
if not inverter_data["success"] or "data" not in inverter_data:
828832
raise FusionSolarException(
829833
f"Failed to retrieve battery day stats for {inverter_id}"
830834
)
831835

832-
833-
return battery_data["data"]
836+
return inverter_data["data"]
834837

835838

836839
@logged_in

0 commit comments

Comments
 (0)