mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Fix synology temperature rounding (#35556)
* Fix synology temperature rounding * Remove stale comment
This commit is contained in:
parent
785b8d2bd1
commit
36ad9a25e3
@ -121,8 +121,6 @@ class SynoApi:
|
|||||||
self._hass = hass
|
self._hass = hass
|
||||||
self._entry = entry
|
self._entry = entry
|
||||||
|
|
||||||
self.temp_unit = hass.config.units.temperature_unit
|
|
||||||
|
|
||||||
self.dsm: SynologyDSM = None
|
self.dsm: SynologyDSM = None
|
||||||
self.information: SynoDSMInformation = None
|
self.information: SynoDSMInformation = None
|
||||||
self.utilisation: SynoCoreUtilization = None
|
self.utilisation: SynoCoreUtilization = None
|
||||||
|
@ -8,12 +8,13 @@ from homeassistant.const import (
|
|||||||
DATA_MEGABYTES,
|
DATA_MEGABYTES,
|
||||||
DATA_RATE_KILOBYTES_PER_SECOND,
|
DATA_RATE_KILOBYTES_PER_SECOND,
|
||||||
DATA_TERABYTES,
|
DATA_TERABYTES,
|
||||||
|
PRECISION_TENTHS,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
|
from homeassistant.helpers.temperature import display_temp
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
from homeassistant.util.temperature import celsius_to_fahrenheit
|
|
||||||
|
|
||||||
from . import SynoApi
|
from . import SynoApi
|
||||||
from .const import (
|
from .const import (
|
||||||
@ -109,7 +110,7 @@ class SynoNasSensor(Entity):
|
|||||||
def unit_of_measurement(self) -> str:
|
def unit_of_measurement(self) -> str:
|
||||||
"""Return the unit the value is expressed in."""
|
"""Return the unit the value is expressed in."""
|
||||||
if self.sensor_type in TEMP_SENSORS_KEYS:
|
if self.sensor_type in TEMP_SENSORS_KEYS:
|
||||||
return self._api.temp_unit
|
return self.hass.config.units.temperature_unit
|
||||||
return self._unit
|
return self._unit
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -186,12 +187,8 @@ class SynoNasStorageSensor(SynoNasSensor):
|
|||||||
return round(attr / 1024.0 ** 4, 2)
|
return round(attr / 1024.0 ** 4, 2)
|
||||||
|
|
||||||
# Temperature
|
# Temperature
|
||||||
if self._api.temp_unit == TEMP_CELSIUS:
|
|
||||||
# Celsius
|
|
||||||
return attr
|
|
||||||
if self.sensor_type in TEMP_SENSORS_KEYS:
|
if self.sensor_type in TEMP_SENSORS_KEYS:
|
||||||
# Fahrenheit
|
return display_temp(self.hass, attr, TEMP_CELSIUS, PRECISION_TENTHS)
|
||||||
return celsius_to_fahrenheit(attr)
|
|
||||||
|
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user