-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added GPU sensors to output #20
Added GPU sensors to output #20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey I noticed your PR just as I happened to start working on this myself.
Thanks for putting in the work! Please feel free to ignore my suggestion if you already have working code for the Home Assistant component ready.
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, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of using more descriptive names here in the glances-api package already instead of doing the translation in Home Assistant?
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, | |
} | |
unique_name = f"GPU_{sensor['gpu_id']}__{sensor['name']}" | |
sensor_data["gpu"][unique_name] = { | |
"name": sensor["name"], | |
"memory_use_percent": round(sensor["mem"], 1), | |
"processor_use_percent": sensor["proc"], | |
"temperature_celsius": sensor["temperature"], | |
"fan_speed_percent": sensor.get("fan_speed", 0), | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that adding the unit of measurement to a sensor name could be problematic as I'm frankly not sure if the return value could depend on the system's settings (Celsius vs. Fahrenheit, etc.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Home Assistant interface will need to display a unit anyways so I figured the closer to the source we resolve the ambiguity, the better.
I based myself on the comments in this part of the glances codebase to be sure about the units:
https://github.com/nicolargo/glances/blob/develop/glances/plugins/gpu/model.py#L278
A bit further up in that same file, I see a mention of Fahrenheit conversion but that seems to be only for the GUI, not the API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API HOST 61208/api/3/gpu
[{"key":"gpu_id","gpu_id":0,"name":"Tesla P4","mem":26.248677571614582,"proc":0,"temperature":42,"fan_speed":null}]
@fabaff Any update on this? Would love to have GPU support integrated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
add the necessary GPU sensor parsing for the Glances component in Home Assistant.