From ac0eacb15e0a870389b71e9fd95a1ae2289e2cc4 Mon Sep 17 00:00:00 2001 From: Normann Date: Tue, 8 Oct 2024 10:38:08 +0200 Subject: [PATCH] convert np arrys to lists before changing --- src/akkudoktoreos/class_ems.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/akkudoktoreos/class_ems.py b/src/akkudoktoreos/class_ems.py index 404766b..f20443a 100644 --- a/src/akkudoktoreos/class_ems.py +++ b/src/akkudoktoreos/class_ems.py @@ -138,8 +138,22 @@ def simuliere(self, start_stunde: int) -> dict: "Haushaltsgeraet_wh_pro_stunde": haushaltsgeraet_wh_pro_stunde, } - # set the first value to None so no action will be done in the current hour - out["Last_Wh_pro_Stunde"][0] = None - out["Netzeinspeisung_Wh_pro_Stunde"][0] = None - out["Netzbezug_Wh_pro_Stunde"][0] = None + # List output keys where the first element needs to be changed to None + keys_to_modify = [ + "Last_Wh_pro_Stunde", + "Netzeinspeisung_Wh_pro_Stunde", + "Netzbezug_Wh_pro_Stunde", + ] + + # Loop through each key in the list + for key in keys_to_modify: + # Convert the NumPy array to a list + element_list = out[key].tolist() + + # Change the first value to None + element_list[0] = None + + # Assign the modified list back to the dictionary + out[key] = element_list + return out