Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions homeassistant/components/synology_dsm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ def __init__(self, hass: HomeAssistantType, entry: ConfigEntry):
self._hass = hass
self._entry = entry

self.temp_unit = hass.config.units.temperature_unit

self.dsm: SynologyDSM = None
self.information: SynoDSMInformation = None
self.utilisation: SynoCoreUtilization = None
Expand Down
10 changes: 4 additions & 6 deletions homeassistant/components/synology_dsm/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
DATA_MEGABYTES,
DATA_RATE_KILOBYTES_PER_SECOND,
DATA_TERABYTES,
PRECISION_TENTHS,
TEMP_CELSIUS,
)
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.temperature import display_temp
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util.temperature import celsius_to_fahrenheit

from . import SynoApi
from .const import (
Expand Down Expand Up @@ -109,7 +110,7 @@ def icon(self) -> str:
def unit_of_measurement(self) -> str:
"""Return the unit the value is expressed in."""
if self.sensor_type in TEMP_SENSORS_KEYS:
return self._api.temp_unit
return self.hass.config.units.temperature_unit
return self._unit

@property
Expand Down Expand Up @@ -186,12 +187,9 @@ def state(self):
return round(attr / 1024.0 ** 4, 2)

# Temperature
if self._api.temp_unit == TEMP_CELSIUS:
# Celsius
return attr
if self.sensor_type in TEMP_SENSORS_KEYS:
# Fahrenheit
Comment thread
shenxn marked this conversation as resolved.
Outdated
return celsius_to_fahrenheit(attr)
return display_temp(self.hass, attr, TEMP_CELSIUS, PRECISION_TENTHS)

return attr

Expand Down