mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Fix inconsistent lyric temperature unit (#98457)
This commit is contained in:
parent
d5338e88f2
commit
9be532cea9
@ -21,7 +21,12 @@ from homeassistant.components.climate import (
|
|||||||
HVACMode,
|
HVACMode,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE
|
from homeassistant.const import (
|
||||||
|
ATTR_TEMPERATURE,
|
||||||
|
PRECISION_HALVES,
|
||||||
|
PRECISION_WHOLE,
|
||||||
|
UnitOfTemperature,
|
||||||
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers import entity_platform
|
from homeassistant.helpers import entity_platform
|
||||||
@ -113,7 +118,6 @@ async def async_setup_entry(
|
|||||||
),
|
),
|
||||||
location,
|
location,
|
||||||
device,
|
device,
|
||||||
hass.config.units.temperature_unit,
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -140,10 +144,15 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
|
|||||||
description: ClimateEntityDescription,
|
description: ClimateEntityDescription,
|
||||||
location: LyricLocation,
|
location: LyricLocation,
|
||||||
device: LyricDevice,
|
device: LyricDevice,
|
||||||
temperature_unit: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Initialize Honeywell Lyric climate entity."""
|
"""Initialize Honeywell Lyric climate entity."""
|
||||||
self._temperature_unit = temperature_unit
|
# Use the native temperature unit from the device settings
|
||||||
|
if device.units == "Fahrenheit":
|
||||||
|
self._attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||||
|
self._attr_precision = PRECISION_WHOLE
|
||||||
|
else:
|
||||||
|
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
self._attr_precision = PRECISION_HALVES
|
||||||
|
|
||||||
# Setup supported hvac modes
|
# Setup supported hvac modes
|
||||||
self._attr_hvac_modes = [HVACMode.OFF]
|
self._attr_hvac_modes = [HVACMode.OFF]
|
||||||
@ -176,11 +185,6 @@ class LyricClimate(LyricDeviceEntity, ClimateEntity):
|
|||||||
return SUPPORT_FLAGS_LCC
|
return SUPPORT_FLAGS_LCC
|
||||||
return SUPPORT_FLAGS_TCC
|
return SUPPORT_FLAGS_TCC
|
||||||
|
|
||||||
@property
|
|
||||||
def temperature_unit(self) -> str:
|
|
||||||
"""Return the unit of measurement."""
|
|
||||||
return self._temperature_unit
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self) -> float | None:
|
def current_temperature(self) -> float | None:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
|
@ -17,7 +17,7 @@ from homeassistant.components.sensor import (
|
|||||||
SensorStateClass,
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import PERCENTAGE
|
from homeassistant.const import PERCENTAGE, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
@ -76,6 +76,11 @@ async def async_setup_entry(
|
|||||||
for location in coordinator.data.locations:
|
for location in coordinator.data.locations:
|
||||||
for device in location.devices:
|
for device in location.devices:
|
||||||
if device.indoorTemperature:
|
if device.indoorTemperature:
|
||||||
|
if device.units == "Fahrenheit":
|
||||||
|
native_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||||
|
else:
|
||||||
|
native_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
entities.append(
|
entities.append(
|
||||||
LyricSensor(
|
LyricSensor(
|
||||||
coordinator,
|
coordinator,
|
||||||
@ -84,7 +89,7 @@ async def async_setup_entry(
|
|||||||
name="Indoor Temperature",
|
name="Indoor Temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=hass.config.units.temperature_unit,
|
native_unit_of_measurement=native_temperature_unit,
|
||||||
value=lambda device: device.indoorTemperature,
|
value=lambda device: device.indoorTemperature,
|
||||||
),
|
),
|
||||||
location,
|
location,
|
||||||
@ -108,6 +113,11 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if device.outdoorTemperature:
|
if device.outdoorTemperature:
|
||||||
|
if device.units == "Fahrenheit":
|
||||||
|
native_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||||
|
else:
|
||||||
|
native_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
entities.append(
|
entities.append(
|
||||||
LyricSensor(
|
LyricSensor(
|
||||||
coordinator,
|
coordinator,
|
||||||
@ -116,7 +126,7 @@ async def async_setup_entry(
|
|||||||
name="Outdoor Temperature",
|
name="Outdoor Temperature",
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=hass.config.units.temperature_unit,
|
native_unit_of_measurement=native_temperature_unit,
|
||||||
value=lambda device: device.outdoorTemperature,
|
value=lambda device: device.outdoorTemperature,
|
||||||
),
|
),
|
||||||
location,
|
location,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user