mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use climate entity built in attrs for nest climate (#99093)
* Use climate entity built in attrs for nest climate * Update homeassistant/components/nest/climate.py Co-authored-by: Shay Levy <levyshay1@gmail.com> --------- Co-authored-by: Shay Levy <levyshay1@gmail.com>
This commit is contained in:
parent
2dd6b26fbc
commit
7070302001
@ -32,7 +32,6 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .const import DATA_DEVICE_MANAGER, DOMAIN
|
||||
@ -106,17 +105,18 @@ class ThermostatEntity(ClimateEntity):
|
||||
"""Initialize ThermostatEntity."""
|
||||
self._device = device
|
||||
self._device_info = NestDeviceInfo(device)
|
||||
|
||||
@property
|
||||
def unique_id(self) -> str | None:
|
||||
"""Return a unique ID."""
|
||||
# The API "name" field is a unique device identifier.
|
||||
return self._device.name
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device specific attributes."""
|
||||
return self._device_info.device_info
|
||||
self._attr_unique_id = device.name
|
||||
self._attr_device_info = self._device_info.device_info
|
||||
self._attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
if mode_trait := device.traits.get(ThermostatModeTrait.NAME):
|
||||
self._attr_hvac_modes = [
|
||||
THERMOSTAT_MODE_MAP[mode]
|
||||
for mode in mode_trait.available_modes
|
||||
if mode in THERMOSTAT_MODE_MAP
|
||||
]
|
||||
else:
|
||||
self._attr_hvac_modes = []
|
||||
|
||||
@property
|
||||
def available(self) -> bool:
|
||||
@ -130,11 +130,6 @@ class ThermostatEntity(ClimateEntity):
|
||||
self._device.add_update_listener(self.async_write_ha_state)
|
||||
)
|
||||
|
||||
@property
|
||||
def temperature_unit(self) -> str:
|
||||
"""Return the unit of temperature measurement for the system."""
|
||||
return UnitOfTemperature.CELSIUS
|
||||
|
||||
@property
|
||||
def current_temperature(self) -> float | None:
|
||||
"""Return the current temperature."""
|
||||
@ -201,24 +196,6 @@ class ThermostatEntity(ClimateEntity):
|
||||
hvac_mode = THERMOSTAT_MODE_MAP[trait.mode]
|
||||
return hvac_mode
|
||||
|
||||
@property
|
||||
def hvac_modes(self) -> list[HVACMode]:
|
||||
"""List of available operation modes."""
|
||||
supported_modes = []
|
||||
for mode in self._get_device_hvac_modes:
|
||||
if mode in THERMOSTAT_MODE_MAP:
|
||||
supported_modes.append(THERMOSTAT_MODE_MAP[mode])
|
||||
return supported_modes
|
||||
|
||||
@property
|
||||
def _get_device_hvac_modes(self) -> set[str]:
|
||||
"""Return the set of SDM API hvac modes supported by the device."""
|
||||
modes = []
|
||||
if ThermostatModeTrait.NAME in self._device.traits:
|
||||
trait = self._device.traits[ThermostatModeTrait.NAME]
|
||||
modes.extend(trait.available_modes)
|
||||
return set(modes)
|
||||
|
||||
@property
|
||||
def hvac_action(self) -> HVACAction | None:
|
||||
"""Return the current HVAC action (heating, cooling)."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user