It might well have helped potential responders to understand the structure better(!), but I was able to get help on the python.org board to which D#256 gave a link.i would pretty print this dictionary to a file for clarity.
With very little toing and froing, we came up with the following code, which returns the total energy recorded by a specified 'meter' over a specified time period within that represented by the returned data. You pass the entire directory as the 'data' argument.
Code:
def summarize(data, meter_type, from_date, to_date):# from_date and to_date should be in the same text format as is used in the data - i.e. YYYY-MM-DD HH:MM:SS total = 0 for types in data["energyDetails"]["meters"]: if types["type"] == meter_type: for values in types["values"]: if 'value' in values: if (values["date"] >= from_date) and (values["date"] < to_date): total += values["value"] return totalStatistics: Posted by pfletch101 — Wed Jan 15, 2025 10:31 pm