From 50f4c5d347a8d6a95f4fa36d1c95228a56ceefe5 Mon Sep 17 00:00:00 2001 From: Shai Ungar Date: Sat, 7 May 2022 23:16:51 +0300 Subject: [PATCH] fix speed sensor wrong number (#71502) --- homeassistant/components/sabnzbd/sensor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sabnzbd/sensor.py b/homeassistant/components/sabnzbd/sensor.py index dee80945e9d..539eaa4f097 100644 --- a/homeassistant/components/sabnzbd/sensor.py +++ b/homeassistant/components/sabnzbd/sensor.py @@ -32,13 +32,15 @@ class SabnzbdSensorEntityDescription(SensorEntityDescription, SabnzbdRequiredKey """Describes Sabnzbd sensor entity.""" +SPEED_KEY = "kbpersec" + SENSOR_TYPES: tuple[SabnzbdSensorEntityDescription, ...] = ( SabnzbdSensorEntityDescription( key="status", name="Status", ), SabnzbdSensorEntityDescription( - key="kbpersec", + key=SPEED_KEY, name="Speed", native_unit_of_measurement=DATA_RATE_MEGABYTES_PER_SECOND, state_class=SensorStateClass.MEASUREMENT, @@ -154,7 +156,7 @@ class SabnzbdSensor(SensorEntity): self.entity_description.key ) - if self.entity_description.key == "speed": + if self.entity_description.key == SPEED_KEY: self._attr_native_value = round(float(self._attr_native_value) / 1024, 1) elif "size" in self.entity_description.key: self._attr_native_value = round(float(self._attr_native_value), 2)