From 21c72fa55935e6971c032ec15b712a1fd10c4cd6 Mon Sep 17 00:00:00 2001 From: Zixuan Wang Date: Thu, 25 Mar 2021 01:19:11 -0700 Subject: [PATCH] Fix missing glances temperature sensors (#46086) * Fix missing glances temperature sensors (#44899) * Revert matching rules for Glances * Shorter if statement Co-authored-by: J. Nick Koston * Revert long-line if statement * Update if statement Co-authored-by: J. Nick Koston --- homeassistant/components/glances/const.py | 7 ++++--- homeassistant/components/glances/sensor.py | 7 +++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/glances/const.py b/homeassistant/components/glances/const.py index 69e4ce0c016..18865a232d7 100644 --- a/homeassistant/components/glances/const.py +++ b/homeassistant/components/glances/const.py @@ -36,9 +36,10 @@ SENSOR_TYPES = { "process_thread": ["processcount", "Thread", "Count", CPU_ICON], "process_sleeping": ["processcount", "Sleeping", "Count", CPU_ICON], "cpu_use_percent": ["cpu", "CPU used", PERCENTAGE, CPU_ICON], - "temperature_core": ["sensors", "temperature", TEMP_CELSIUS, "mdi:thermometer"], - "fan_speed": ["sensors", "fan speed", "RPM", "mdi:fan"], - "battery": ["sensors", "charge", PERCENTAGE, "mdi:battery"], + "temperature_core": ["sensors", "Temperature", TEMP_CELSIUS, "mdi:thermometer"], + "temperature_hdd": ["sensors", "Temperature", TEMP_CELSIUS, "mdi:thermometer"], + "fan_speed": ["sensors", "Fan speed", "RPM", "mdi:fan"], + "battery": ["sensors", "Charge", PERCENTAGE, "mdi:battery"], "docker_active": ["docker", "Containers active", "", "mdi:docker"], "docker_cpu_use": ["docker", "Containers CPU used", PERCENTAGE, "mdi:docker"], "docker_memory_use": [ diff --git a/homeassistant/components/glances/sensor.py b/homeassistant/components/glances/sensor.py index 3e663621625..52649518b68 100644 --- a/homeassistant/components/glances/sensor.py +++ b/homeassistant/components/glances/sensor.py @@ -172,6 +172,13 @@ class GlancesSensor(SensorEntity): if sensor["type"] == "temperature_core": if sensor["label"] == self._sensor_name_prefix: self._state = sensor["value"] + elif self.type == "temperature_hdd": + for sensor in value["sensors"]: + if ( + sensor["type"] == "temperature_hdd" + and sensor["label"] == self._sensor_name_prefix + ): + self._state = sensor["value"] elif self.type == "memory_use_percent": self._state = value["mem"]["percent"] elif self.type == "memory_use":