From a01ad9d11645529fc67b2271f4bd8069aee7efa0 Mon Sep 17 00:00:00 2001 From: Neuralyze <143380219+neuralyze@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:05:01 -0500 Subject: [PATCH] Added GPU sensors to output (#20) --- glances_api/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/glances_api/__init__.py b/glances_api/__init__.py index c70f0ea..28465e0 100644 --- a/glances_api/__init__.py +++ b/glances_api/__init__.py @@ -170,4 +170,14 @@ async def get_ha_sensor_data(self) -> dict[str, Any]: sensor_data["raid"] = data if data := self.data.get("uptime"): sensor_data["uptime"] = data + if data := self.data.get("gpu"): + sensor_data["gpu"] = {} + for sensor in data: + sensor_data["gpu"][f"GPU_{sensor['gpu_id']}__{sensor['name']}"] = { + "name": sensor["name"], + "temperature": sensor["temperature"], + "mem": sensor["mem"], + "proc": sensor["proc"], + "fan_speed": sensor["fan_speed"] if "fan_speed" in sensor else 0, + } return sensor_data