@@ -27,7 +27,7 @@ class Event:
2727 def __init__ (self , ** event : dict [str , Any ]):
2828 """Initialize."""
2929 self ._convert_phases (cast (dict [str , Any ], event .get ("phases" )))
30- params : dict [str , Any ] = event .get ("parameters" , {})
30+ params : dict [str , Any ] = event .get ("parameters" ) or {}
3131 devices : list [dict [str , Any ]] = params .get ("devices" , [])
3232 consumption : dict [str , Any ] = event .get ("consumption" , {})
3333 allowed_wH : int = consumption .get ("baselineWh" , 0 ) or 0
@@ -71,6 +71,12 @@ def update_wh(self, used_wH: float) -> None:
7171 self .used_kWh = round (used_wH / 1000 , 2 )
7272 self .last_update = datetime .now (timezone .utc ).astimezone ()
7373
74+ def update_allowed_wh (self , allowed_wH : float ) -> None :
75+ """This function is used to update the allowed_kWh attribute during a Hilo Challenge Event"""
76+ LOG .debug ("Updating allowed Wh: %s" , allowed_wH )
77+ self .allowed_kWh = round (allowed_wH / 1000 , 2 )
78+ self .last_update = datetime .now (timezone .utc ).astimezone ()
79+
7480 def should_check_for_allowed_wh (self ) -> bool :
7581 """This function is used to authorize subscribing to a specific event in Hilo to receive the allowed_kWh
7682 that is made available in the pre_heat phase"""
0 commit comments