Add GPU sensor to Glances (#106322)

* feat: add GPU sensor to Glances

* Add translations to Glances GPU sensor

* Fix translations of GPU processor and memory usage

* PR feedback: move icons to icons.json

thanks to @wittypluck

* Update glances snapshot with added GPU

* Remove JSON trailing comma

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Limit precision of Glance GPU mem usage sensor

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Clean up outdated snapshots

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
This commit is contained in:
fhoekstra 2024-04-07 15:05:22 +02:00 committed by GitHub
parent 1b07d3ecfa
commit e4fbe539aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 255 additions and 1 deletions

View file

@ -235,6 +235,36 @@ SENSOR_TYPES = {
translation_key="uptime",
device_class=SensorDeviceClass.TIMESTAMP,
),
("gpu", "mem"): GlancesSensorEntityDescription(
key="mem",
type="gpu",
translation_key="gpu_memory_usage",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
("gpu", "proc"): GlancesSensorEntityDescription(
key="proc",
type="gpu",
translation_key="gpu_processor_usage",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
suggested_display_precision=1,
),
("gpu", "temperature"): GlancesSensorEntityDescription(
key="temperature",
type="gpu",
translation_key="temperature",
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
),
("gpu", "fan_speed"): GlancesSensorEntityDescription(
key="fan_speed",
type="gpu",
translation_key="fan_speed",
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
}
@ -249,7 +279,7 @@ async def async_setup_entry(
entities: list[GlancesSensor] = []
for sensor_type, sensors in coordinator.data.items():
if sensor_type in ["fs", "diskio", "sensors", "raid"]:
if sensor_type in ["fs", "diskio", "sensors", "raid", "gpu"]:
entities.extend(
GlancesSensor(
coordinator,