@@ -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