From 21c6056baf015a55372504c25b59437fc98d9cbf Mon Sep 17 00:00:00 2001 From: Matt Clayton Date: Mon, 29 Nov 2021 21:52:58 +0000 Subject: [PATCH] Add temperature of coral tpu to telemetry mqtt message --- frigate/stats.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/frigate/stats.py b/frigate/stats.py index bc92907cd..52ec04428 100644 --- a/frigate/stats.py +++ b/frigate/stats.py @@ -31,6 +31,24 @@ def get_fs_type(path): bestMatch = part.mountpoint return fsType +def read_temperature(path): + if os.path.isfile(path): + with open(path) as f: + line=f.readline().strip() + return int(line)/1000 + return None + +def get_temperatures(): + temps={} + + # Get temperatures for all attached Corals + base="/sys/class/apex/" + for apex in os.listdir(base): + temp=read_temperature(os.path.join(base,apex,"temp")) + if temp is not None: + temps[apex]=temp + + return temps def read_temperature(path): if os.path.isfile(path):