@@ -62,7 +62,7 @@ def __init__(
6262 update_interval = timedelta (minutes = 60 ),
6363 )
6464
65- # calculate the price using the given template
65+ # calculate the price using the given template
6666 def calc_price (self , value , fake_dt = None , no_template = False ) -> float :
6767 """Calculate price based on the users settings."""
6868 # Used to inject the current hour.
@@ -188,14 +188,21 @@ def today_data_available(self):
188188 # we could still optimize as not every calculator mode needs hourly updates
189189 def sync_calculator (self ):
190190 now = dt .now ()
191- if self .calculator_last_sync is None or self .calculator_last_sync .hour != now .hour :
192- self .logger .debug (f"The calculator needs to be synced with the current time" )
191+ if (
192+ self .calculator_last_sync is None
193+ or self .calculator_last_sync .hour != now .hour
194+ ):
195+ self .logger .debug (
196+ f"The calculator needs to be synced with the current time"
197+ )
193198 if self .today .date () != now .date ():
194- self .logger .debug (f"new day detected: update today and filtered hourprices" )
199+ self .logger .debug (
200+ f"new day detected: update today and filtered hourprices"
201+ )
195202 self .today = now .replace (hour = 0 , minute = 0 , second = 0 , microsecond = 0 )
196203 self .filtered_hourprices = self ._filter_calculated_hourprices (self .data )
197204
198- self .calculator_last_sync = now
205+ self .calculator_last_sync = now
199206
200207 def _filter_calculated_hourprices (self , data ):
201208 # rotation = calculations made upon 24hrs today
@@ -212,7 +219,7 @@ def _filter_calculated_hourprices(self, data):
212219 # publish >48 hrs of data = calculations made on all data of today and tomorrow (48 hrs)
213220 elif self .calculation_mode == CALCULATION_MODE ["publish" ] and len (data ) > 48 :
214221 return {hour : price for hour , price in data .items () if hour >= self .today }
215- # publish <=48 hrs of data = calculations made on all data of yesterday and today (48 hrs)
222+ # publish <=48 hrs of data = calculations made on all data of yesterday and today (48 hrs)
216223 elif self .calculation_mode == CALCULATION_MODE ["publish" ]:
217224 return {
218225 hour : price
0 commit comments