diff --git a/eval_records.py b/eval_records.py index dfd37d4..2e83063 100644 --- a/eval_records.py +++ b/eval_records.py @@ -2,13 +2,15 @@ import json import os from datetime import datetime from jay_diff import jay_merge_full +from matplotlib import pyplot as plot + BASE = "/media/jens/cifs/jens@moon/projects/we_collect/results" VIN = 'WVWZZZE1ZMP010760' USER = 'alex' YEAR = 2024 MONTH = 10 -DAY = ['20', '21', '22'] +DAY = ['15', '16', '17', '18', '19', '20', '21', '22', '23'] def has_diff_entries(diff): @@ -35,12 +37,17 @@ class Endpoint: self._ts_format = _ts_format self._ts_path_keys = self.to_keys(_ts_path) - def __str__(self): - return f"{self._ep_path}:{len(self._values)}: {self._values}" - def timestamps_str(self): return f"{self._ep_path}:{len(self._timestamps)}: {self._timestamps}" + @property + def timestamps(self): + return self._timestamps + + @property + def values(self): + return self._values + @property def path(self): return self._ep_path @@ -82,12 +89,11 @@ class Endpoint: return Endpoint.deref_multi(data[keys[0]], keys[1:]) if keys else data -end_points = [ - Endpoint('data/measurements/odometerStatus/value/odometer', 'info/timestamp'), - Endpoint('data/measurements/fuelLevelStatus/value/currentSOC_pct', 'info/timestamp'), - Endpoint('data/vehicleLights/lightsStatus/value/lights', 'info/timestamp'), - Endpoint('data/fuelStatus/rangeStatus/value/primaryEngine', 'info/timestamp') -] +end_points = { + 'odo': Endpoint('data/measurements/odometerStatus/value/odometer', 'info/timestamp'), + 'soc': Endpoint('data/measurements/fuelLevelStatus/value/currentSOC_pct', 'info/timestamp'), + 'engine': Endpoint('data/fuelStatus/rangeStatus/value/primaryEngine', 'info/timestamp') +} def convert(timestamp_str: str, pattern: str = "%Y-%m-%dT%H:%M:%S.%f%z"): @@ -158,14 +164,21 @@ for day in day_list: vehicle_data = jay_merge_full(last, vehicle_diff) last = vehicle_data try: - for end_point in end_points: - end_point.assign({'info': record['info'], 'data': vehicle_data}) + for k in end_points.keys(): + end_points[k].assign({'info': record['info'], 'data': vehicle_data}) except KeyError: pass -for end_point in end_points: - end_point.remove_dups() - print(end_point) - print(end_point.timestamps_str()) +for k in end_points.keys(): + end_points[k].remove_dups() -d = convert('2024-10-17T18:37:17.067Z') +plot.subplot(2, 1, 1) +plot.plot(end_points['odo'].timestamps, end_points['odo'].values) +plot.title("Kilometerstand") +plot.grid() +plot.subplot(2, 1, 2) +plot.plot(end_points['odo'].timestamps, end_points['soc'].values) +plot.title("Akku in %") +plot.grid() + +plot.show()