mirror of
https://github.com/home-assistant/core.git
synced 2025-07-11 07:17:12 +00:00
fix speed sensor wrong number (#71502)
This commit is contained in:
parent
21cee3b1c4
commit
50f4c5d347
@ -32,13 +32,15 @@ class SabnzbdSensorEntityDescription(SensorEntityDescription, SabnzbdRequiredKey
|
|||||||
"""Describes Sabnzbd sensor entity."""
|
"""Describes Sabnzbd sensor entity."""
|
||||||
|
|
||||||
|
|
||||||
|
SPEED_KEY = "kbpersec"
|
||||||
|
|
||||||
SENSOR_TYPES: tuple[SabnzbdSensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[SabnzbdSensorEntityDescription, ...] = (
|
||||||
SabnzbdSensorEntityDescription(
|
SabnzbdSensorEntityDescription(
|
||||||
key="status",
|
key="status",
|
||||||
name="Status",
|
name="Status",
|
||||||
),
|
),
|
||||||
SabnzbdSensorEntityDescription(
|
SabnzbdSensorEntityDescription(
|
||||||
key="kbpersec",
|
key=SPEED_KEY,
|
||||||
name="Speed",
|
name="Speed",
|
||||||
native_unit_of_measurement=DATA_RATE_MEGABYTES_PER_SECOND,
|
native_unit_of_measurement=DATA_RATE_MEGABYTES_PER_SECOND,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
@ -154,7 +156,7 @@ class SabnzbdSensor(SensorEntity):
|
|||||||
self.entity_description.key
|
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)
|
self._attr_native_value = round(float(self._attr_native_value) / 1024, 1)
|
||||||
elif "size" in self.entity_description.key:
|
elif "size" in self.entity_description.key:
|
||||||
self._attr_native_value = round(float(self._attr_native_value), 2)
|
self._attr_native_value = round(float(self._attr_native_value), 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user