evaluate temperature

This commit is contained in:
2025-10-22 20:30:41 +02:00
parent b761663ab7
commit 8ea258b8c4
+18 -18
View File
@@ -128,7 +128,6 @@ def check_sel(root_path, sel: list):
return res return res
def process(end_points: list[Endpoint], base_path: str, user: str, vin: str, sel_years=None, sel_months=None, sel_days=None, sel_hours=None): def process(end_points: list[Endpoint], base_path: str, user: str, vin: str, sel_years=None, sel_months=None, sel_days=None, sel_hours=None):
_path = os.path.join(base_path, user) _path = os.path.join(base_path, user)
root_path = os.path.join(_path, vin) root_path = os.path.join(_path, vin)
@@ -148,16 +147,18 @@ def process(end_points: list[Endpoint], base_path: str, user: str, vin: str, sel
# Sort out files with unknown nickname # Sort out files with unknown nickname
file_list_sorted = sorted(os.listdir(day_path), key=lambda f: convert(f)) file_list_sorted = sorted(os.listdir(day_path), key=lambda f: convert(f))
vehicle_diff = {}
last = {}
for filename in file_list_sorted: for filename in file_list_sorted:
file_path = os.path.join(day_path, filename) file_path = os.path.join(day_path, filename)
with open(file_path, "r") as fp: with open(file_path, "r") as fp:
records = json.load(fp) records = json.load(fp)
print(f"In file \"{filename}\": found {len(records):4d} records") print(f"In file \"{filename}\": found {len(records):4d} records")
for record in records: combined_content = {}
try: for section in ["data", "other_data"]:
vehicle_diff = record['data'] vehicle_diff = {}
last = {}
content = {}
for record in records:
vehicle_diff = record[section]
is_header = True is_header = True
if 'is_delta' in record['info']: if 'is_delta' in record['info']:
if record['info']['is_delta']: if record['info']['is_delta']:
@@ -166,19 +167,16 @@ def process(end_points: list[Endpoint], base_path: str, user: str, vin: str, sel
if is_header: if is_header:
last = {} last = {}
except KeyError as e: if not has_diff_entries(vehicle_diff):
print(f"KeyError: {e}") vehicle_diff = {'update_add': vehicle_diff}
if not has_diff_entries(vehicle_diff): vehicle_data = jay_merge_full(last, vehicle_diff)
vehicle_diff = {'update_add': vehicle_diff} last = vehicle_data
vehicle_data = jay_merge_full(last, vehicle_diff)
last = vehicle_data
try:
for ep in end_points: for ep in end_points:
ep.assign({'info': record['info'], 'data': vehicle_data}) try:
except KeyError: ep.assign({'info': record['info'], section: vehicle_data})
pass except KeyError:
pass
for ep in end_points: for ep in end_points:
ep.remove_dups() ep.remove_dups()
@@ -254,6 +252,7 @@ def main() -> None:
ep_range = find_ep_by_name(end_points, name="range") ep_range = find_ep_by_name(end_points, name="range")
ep_chgpwr = find_ep_by_name(end_points, name="chgpwr") ep_chgpwr = find_ep_by_name(end_points, name="chgpwr")
ep_chg_state = find_ep_by_name(end_points, name="chg_state") ep_chg_state = find_ep_by_name(end_points, name="chg_state")
ep_temperature = find_ep_by_name(end_points, name="temperature")
time_h = make_time(dt_start, dt_stop, td_step) time_h = make_time(dt_start, dt_stop, td_step)
@@ -263,6 +262,7 @@ def main() -> None:
v_range = make_values(time_h, ep_range) v_range = make_values(time_h, ep_range)
v_chgpwr = make_values(time_h, ep_chgpwr) v_chgpwr = make_values(time_h, ep_chgpwr)
v_chg_state = make_values(time_h, ep_chg_state) v_chg_state = make_values(time_h, ep_chg_state)
v_temperature = make_values(time_h, ep_temperature)
# calc speed # calc speed
speed = [0] speed = [0]
@@ -310,7 +310,7 @@ def main() -> None:
plot.ylabel("Speed") plot.ylabel("Speed")
plot.grid() plot.grid()
plot.subplot(NUM_PLOTS, 1, 3) plot.subplot(NUM_PLOTS, 1, 3)
plot.plot(dt_h, v_soc, dt_h, v_chgpwr) plot.plot(dt_h, v_soc, dt_h, v_chgpwr, dt_h, v_temperature)
plot.ylabel("Akkustand") plot.ylabel("Akkustand")
plot.grid() plot.grid()
plot.subplot(NUM_PLOTS, 1, 4) plot.subplot(NUM_PLOTS, 1, 4)