@@ -433,7 +433,7 @@ async def _async_update_data(
433
433
434
434
else :
435
435
devices_by_id : Devices = await self ._get_devices_by_device_id (device .device_number )
436
- last_meter_read = devices_by_id .counter_devices [0 ].last_mr
436
+ last_meter_read = int ( devices_by_id .counter_devices [0 ].last_mr )
437
437
last_meter_read_date = devices_by_id .counter_devices [0 ].last_mr_date
438
438
phase_count = devices_by_id .counter_devices [0 ].connection_size .phase
439
439
connection_size = (devices_by_id .counter_devices [0 ].
@@ -657,7 +657,7 @@ def _calculate_estimated_bill(meter_id, future_consumptions: dict[str, FutureCon
657
657
distribution_price = 0
658
658
delivery_price = 0
659
659
660
- consumption_price = future_consumption * kwh_tariff
660
+ consumption_price = round ( future_consumption * kwh_tariff , 2 )
661
661
total_days = 0
662
662
663
663
today = TIMEZONE .localize (datetime .today ())
@@ -684,16 +684,16 @@ def _calculate_estimated_bill(meter_id, future_consumptions: dict[str, FutureCon
684
684
total_days = today .day
685
685
days_in_current_month = calendar .monthrange (today .year , today .month )[1 ]
686
686
687
- consumption_price = future_consumption * kwh_tariff
688
- total_kva_price = kva_price * total_days
689
- distribution_price = (distribution_tariff / days_in_current_month ) * total_days
687
+ consumption_price = future_consumption * kwh_tariff , 2
688
+ total_kva_price = kva_price * total_days , 2
689
+ distribution_price = (distribution_tariff / days_in_current_month ) * total_days , 2
690
690
delivery_price = (delivery_tariff / days_in_current_month ) * total_days
691
691
692
692
_LOGGER .debug (f'Calculated estimated bill: No. of days: { total_days } , total KVA price: { total_kva_price } , '
693
693
f'total distribution price: { distribution_price } , total delivery price: { delivery_price } , '
694
694
f'consumption price: { consumption_price } ' )
695
695
696
- fixed_price = total_kva_price + distribution_price + delivery_price
697
- total_estimated_bill = consumption_price + fixed_price
698
- return total_estimated_bill , fixed_price , consumption_price , total_days , \
699
- delivery_price , distribution_price , total_kva_price , future_consumption
696
+ fixed_price = round ( total_kva_price + distribution_price + delivery_price , 2 )
697
+ total_estimated_bill = round ( consumption_price + fixed_price , 2 )
698
+ return total_estimated_bill , fixed_price , round ( consumption_price , 2 ) , total_days , \
699
+ round ( delivery_price , 2 ), round ( distribution_price , 2 ), round ( total_kva_price , 2 ) , future_consumption
0 commit comments