@@ -317,7 +317,7 @@ async def _verify_daily_readings_exist(
317317 )
318318 if not daily_reading :
319319 _LOGGER .debug (
320- f' Daily reading for date: { desired_date .strftime (" %Y-%m-%d" )} is missing, calculating manually'
320+ f" Daily reading for date: { desired_date .strftime (' %Y-%m-%d' )} is missing, calculating manually"
321321 )
322322 readings = prefetched_reading
323323 if not readings :
@@ -330,7 +330,7 @@ async def _verify_daily_readings_exist(
330330 )
331331 else :
332332 _LOGGER .debug (
333- f' Daily reading for date: { desired_date .strftime (" %Y-%m-%d" )} - using existing prefetched readings'
333+ f" Daily reading for date: { desired_date .strftime (' %Y-%m-%d' )} - using existing prefetched readings"
334334 )
335335
336336 if readings and readings .data :
@@ -353,16 +353,16 @@ async def _verify_daily_readings_exist(
353353 )
354354 if desired_date_reading is None or desired_date_reading .value <= 0 :
355355 _LOGGER .debug (
356- f' Couldn\ ' t find daily reading for: { desired_date .strftime (" %Y-%m-%d" ) } '
356+ f" Couldn't find daily reading for: { desired_date .strftime (' %Y-%m-%d' ) } "
357357 )
358358 else :
359359 daily_readings [device .device_number ].append (
360360 RemoteReading (0 , desired_date , desired_date_reading .value )
361361 )
362362 else :
363363 _LOGGER .debug (
364- f' Daily reading for date: { daily_reading .date .strftime (" %Y-%m-%d" ) } '
365- f' is present: { daily_reading .value } '
364+ f" Daily reading for date: { daily_reading .date .strftime (' %Y-%m-%d' ) } "
365+ f" is present: { daily_reading .value } "
366366 )
367367
368368 async def _update_data (
@@ -454,7 +454,9 @@ async def _update_data(
454454
455455 devices = await self ._get_devices_by_contract_id (contract_id )
456456 if not devices :
457- _LOGGER .debug (f"No devices for contract { contract_id } . Skipping creating devices." )
457+ _LOGGER .debug (
458+ f"No devices for contract { contract_id } . Skipping creating devices."
459+ )
458460 continue
459461
460462 for device in devices or []:
@@ -589,7 +591,7 @@ async def _update_data(
589591 last_invoice ,
590592 )
591593 except Exception as e :
592- _LOGGER .warn ("Failed to calculate estimated next bill" , e )
594+ _LOGGER .warning ("Failed to calculate estimated next bill" , e )
593595 estimated_bill = 0
594596 consumption_price = 0
595597 total_days = 0
@@ -705,7 +707,14 @@ async def _insert_statistics(self, contract_id: int, is_smart_meter: bool) -> No
705707
706708 if readings and readings .meter_start_date :
707709 # Fetching the last reading from either the installation date or a month ago
708- month_ago_time = max (month_ago_time , TIMEZONE .localize (datetime .combine (readings .meter_start_date , datetime .min .time ())))
710+ month_ago_time = max (
711+ month_ago_time ,
712+ TIMEZONE .localize (
713+ datetime .combine (
714+ readings .meter_start_date , datetime .min .time ()
715+ )
716+ ),
717+ )
709718 else :
710719 _LOGGER .debug (
711720 "[IEC Statistics] Failed to extract field `meterStartDate`, falling back to a month ago"
@@ -1016,8 +1025,10 @@ def _calculate_estimated_bill(
10161025 future_consumption_info .total_import - last_meter_read
10171026 )
10181027 else :
1019- _LOGGER .warn (f"Failed to calculate Future Consumption, Assuming last meter read \
1020- ({ last_meter_read } ) as full consumption" )
1028+ _LOGGER .warning (
1029+ f"Failed to calculate Future Consumption, Assuming last meter read \
1030+ ({ last_meter_read } ) as full consumption"
1031+ )
10211032 future_consumption = last_meter_read
10221033
10231034 kva_price = power_size * kva_tariff / 365
0 commit comments