From 84fa10eba87b7d44f622d89ce8a3fb1538a18647 Mon Sep 17 00:00:00 2001 From: Liam Reynolds Date: Tue, 27 Jan 2026 16:12:49 -0800 Subject: [PATCH] temp_graph.py: added a --filter option Use the --filter option to filter for a device name. Any device name containing the filtered string will remain. All other devices will be hidden. If this would hide an entire chart, that chart is removed entirely. Considerations: if more filters are desired, it may be easiest to instead rework the html report to include some scripted filter options. Signed-off-by: Liam Reynolds --- py-scripts/temp_graph.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) mode change 100644 => 100755 py-scripts/temp_graph.py diff --git a/py-scripts/temp_graph.py b/py-scripts/temp_graph.py old mode 100644 new mode 100755 index 224befe9f..ea28978de --- a/py-scripts/temp_graph.py +++ b/py-scripts/temp_graph.py @@ -96,6 +96,8 @@ def main(): default=False, action="store_true") parser.add_argument("-c", "--cutoff", default=20, help="max time in minutes between two table entries") + parser.add_argument("-f", "--filter", default=None, + help="only graph from sensors with names containing the filtered string") parser.add_argument("--help_summary", default=False, action="store_true") args = parser.parse_args() @@ -173,12 +175,20 @@ def main(): date_format = mdates.DateFormatter('%H:%M') + skip_tables = [] + for file_num in range(len(out_tables)): file = out_tables[file_num] df = pd.read_csv(file.name) + if args.filter: + df = df[df['device'].str.contains(args.filter, case=False)] + if (df.empty): + print("A chart was hidden because it did not contain the filtered string") + skip_tables.append(file_num) + continue df['datetime'] = pd.to_datetime(df['datetime'], format="%Y-%m-%d %H:%M:%S") - _, ax = plt.subplots() + _, ax = plt.subplots(layout='constrained') min_temps = df.groupby('datetime')['temperature'].min() max_temps = df.groupby('datetime')['temperature'].max() mean_temps = df.groupby('datetime')['temperature'].mean() @@ -216,6 +226,8 @@ def main(): with open(_out_dir + _tstamp + '/report' + '.html', 'w') as f: f.write(" \n \n ") for file_num in range(len(out_tables)): + if file_num in skip_tables: + continue f.write('\"graph')