@@ -159,20 +159,20 @@ class Totals:
159
159
160
160
current_day : datetime
161
161
odo : float
162
- charged_perc : int
163
- discharged_perc : int
162
+ charged_perc : float
163
+ discharged_perc : float
164
164
charges : int
165
165
trips : int
166
166
elapsed_minutes : int
167
- soc_cur : int
167
+ soc_cur : float
168
168
soc_avg : float
169
- soc_min : int
170
- soc_max : int
169
+ soc_min : float
170
+ soc_max : float
171
171
volt12_cur : int
172
172
volt12_avg : float
173
173
volt12_min : int
174
174
volt12_max : int
175
- soc_charged : int
175
+ soc_charged : float
176
176
177
177
178
178
@dataclass
@@ -276,7 +276,30 @@ def init(current_day: datetime, odo: float, soc: int, volt12: int) -> Totals:
276
276
return totals
277
277
278
278
279
- COLUMN_WIDTHS = [13 , 10 , 5 , 7 , 8 , 8 , 8 , 5 , 5 , 8 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 3 , 6 , 6 , 4 , 99 ]
279
+ COLUMN_WIDTHS = [
280
+ 13 , # Period
281
+ 10 , # Date
282
+ 5 , # Info
283
+ 7 , # Odometer
284
+ 8 , # Delta km
285
+ 8 , # +kWh
286
+ 8 , # -kWh
287
+ 5 , # km/kWh
288
+ 5 , # kWh/100km
289
+ 8 , # Cost
290
+ 4 , # SOC%
291
+ 4 , # SOC% Avg
292
+ 4 , # Soc% Min
293
+ 4 , # SOC% Max
294
+ 3 , # 12V%
295
+ 3 , # 12V% Avg
296
+ 3 , # 12V% Min
297
+ 3 , # 12V% Max
298
+ 6 , # #Charging
299
+ 6 , # #Trips
300
+ 4 , # Range
301
+ 99 , # Address
302
+ ]
280
303
281
304
282
305
def print_output_and_update_queue (output : str ) -> None :
@@ -634,7 +657,7 @@ def print_summary(
634
657
)
635
658
if charged_kwh > 3.0 :
636
659
write_charge_csv (
637
- f"{ date } , { odo :.1f} , { float_to_string_no_trailing_zero (charged_kwh )} , { t_soc_charged } " # noqa
660
+ f"{ date } , { odo :.1f} , { float_to_string_no_trailing_zero (charged_kwh )} , { float_to_string_no_trailing_zero ( t_soc_charged ) } " # noqa
638
661
)
639
662
640
663
if TRIP and prefix .startswith ("TRIP " ):
@@ -662,9 +685,9 @@ def print_summary(
662
685
last_upd_dt = last_updated_at [1 ]
663
686
location_last_upd_dt = location_last_updated_at [1 ]
664
687
SHEET_ROW_A = f"{ TR .last_run } ,{ TR .vehicle_upd } ,{ TR .gps_update } ,{ TR .last_entry } ,{ TR .last_address } ,{ TR .odometer } { ODO_METRIC } ,{ TR .driven } { ODO_METRIC } ,+kWh,-kWh,{ ODO_METRIC } /kWh,kWh/100{ ODO_METRIC } ,{ TR .cost } { COST_CURRENCY } ,{ TR .soc_perc } ,{ TR .avg } { TR .soc_perc } ,{ TR .min } { TR .soc_perc } ,{ TR .max } { TR .soc_perc } ,{ TR .volt12_perc } ,{ TR .avg } { TR .volt12_perc } ,{ TR .min } { TR .volt12_perc } ,{ TR .max } { TR .volt12_perc } ,{ TR .charges } ,{ TR .trips } ,{ TR .ev_range } " # noqa
665
- SHEET_ROW_B = f"{ last_run_dt } ,{ last_upd_dt } ,{ location_last_upd_dt } ,{ last_line } ,{ location_str } ,{ odo :.1f} ,{ float_to_string_no_trailing_zero (delta_odo )} ,{ float_to_string_no_trailing_zero (charged_kwh )} ,{ float_to_string_no_trailing_zero (discharged_kwh )} ,{ km_mi_per_kwh_str } ,{ kwh_per_km_mi_str } ,{ cost_str } ,{ t_soc_cur } ,{ t_soc_avg } ,{ t_soc_min } ,{ t_soc_max } ,{ t_volt12_cur } ,{ t_volt12_avg } ,{ t_volt12_min } ,{ t_volt12_max } ,{ t_charges } ,{ t_trips } ,{ ev_range } " # noqa
688
+ SHEET_ROW_B = f"{ last_run_dt } ,{ last_upd_dt } ,{ location_last_upd_dt } ,{ last_line } ,{ location_str } ,{ odo :.1f} ,{ float_to_string_no_trailing_zero (delta_odo )} ,{ float_to_string_no_trailing_zero (charged_kwh )} ,{ float_to_string_no_trailing_zero (discharged_kwh )} ,{ km_mi_per_kwh_str } ,{ kwh_per_km_mi_str } ,{ cost_str } ,{ float_to_string_no_trailing_zero ( t_soc_cur ) } ,{ float_to_string_no_trailing_zero ( t_soc_avg ) } ,{ float_to_string_no_trailing_zero ( t_soc_min ) } ,{ float_to_string_no_trailing_zero ( t_soc_max ) } ,{ t_volt12_cur } ,{ t_volt12_avg } ,{ t_volt12_min } ,{ t_volt12_max } ,{ t_charges } ,{ t_trips } ,{ ev_range } " # noqa
666
689
else :
667
- output = f"{ prefix } ,{ odo_str } ,{ delta_odo_str } ,{ charged_kwh_str } ,{ discharged_kwh_str } ,{ km_mi_per_kwh_str } ,{ kwh_per_km_mi_str } ,{ cost_str } ,{ t_soc_cur } ,{ t_soc_avg } ,{ t_soc_min } ,{ t_soc_max } ,{ t_volt12_cur } ,{ t_volt12_avg } ,{ t_volt12_min } ,{ t_volt12_max } ,{ t_charges_str } ,{ t_trips_str } ,{ ev_range } ,{ location_str } " # noqa
690
+ output = f"{ prefix } ,{ odo_str } ,{ delta_odo_str } ,{ charged_kwh_str } ,{ discharged_kwh_str } ,{ km_mi_per_kwh_str } ,{ kwh_per_km_mi_str } ,{ cost_str } ,{ float_to_string_no_trailing_zero ( t_soc_cur ) } ,{ float_to_string_no_trailing_zero ( t_soc_avg ) } ,{ float_to_string_no_trailing_zero ( t_soc_min ) } ,{ float_to_string_no_trailing_zero ( t_soc_max ) } ,{ t_volt12_cur } ,{ t_volt12_avg } ,{ t_volt12_min } ,{ t_volt12_max } ,{ t_charges_str } ,{ t_trips_str } ,{ ev_range } ,{ location_str } " # noqa
668
691
print_output_and_update_queue (output )
669
692
670
693
@@ -816,14 +839,14 @@ def keep_track_of_totals(
816
839
) != to_float (prev_split [LON ])
817
840
moved = coord_changed or delta_odo != 0.0
818
841
819
- soc = to_int (split [SOC ])
820
- prev_soc = to_int (prev_split [SOC ])
842
+ soc = to_float (split [SOC ])
843
+ prev_soc = to_float (prev_split [SOC ])
821
844
delta_soc = soc - prev_soc
822
- if (soc == 0 or prev_soc == 0 ) and abs (delta_soc ) > 5 :
845
+ if (soc == 0.0 or prev_soc == 0. 0 ) and abs (delta_soc ) > 5 :
823
846
# possibly wrong readout, take largest
824
847
soc = max (soc , prev_soc )
825
848
prev_soc = soc
826
- delta_soc = 0
849
+ delta_soc = 0.0
827
850
828
851
if delta_odo > 0.0 :
829
852
t_trips += 1
@@ -855,7 +878,7 @@ def keep_track_of_totals(
855
878
prev_charging = is_true (prev_split [CHARGING ])
856
879
no_charging = not charging and not prev_charging
857
880
858
- if delta_soc != 0 :
881
+ if delta_soc != 0.0 :
859
882
if D :
860
883
dbg (
861
884
f"Delta SOC: { delta_soc } , no_charging: { no_charging } , moved: { moved } , elapsed_minutes: { elapsed_minutes } " # noqa
@@ -888,7 +911,7 @@ def keep_track_of_totals(
888
911
if charging and not prev_charging :
889
912
t_charges += 1
890
913
_ = D and dbg ("CHARGES: " + str (t_charges ))
891
- elif delta_soc > 1 and no_charging :
914
+ elif delta_soc > 1.0 and no_charging :
892
915
t_charges += 1
893
916
_ = D and dbg ("charges: DELTA_SOC > 1: " + str (t_charges ))
894
917
0 commit comments