Use _attr_precision in entities (#77477)

pull/77518/head
epenet 2022-08-29 22:02:29 +02:00 committed by GitHub
parent d4c020b675
commit e19e65908a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 14 additions and 73 deletions

View File

@ -74,6 +74,7 @@ async def async_setup_entry(
class ElkThermostat(ElkEntity, ClimateEntity):
"""Representation of an Elk-M1 Thermostat."""
_attr_precision = PRECISION_WHOLE
_attr_supported_features = (
ClimateEntityFeature.FAN_MODE
| ClimateEntityFeature.AUX_HEAT
@ -138,11 +139,6 @@ class ElkThermostat(ElkEntity, ClimateEntity):
"""Return the list of available operation modes."""
return SUPPORT_HVAC
@property
def precision(self) -> int:
"""Return the precision of the system."""
return PRECISION_WHOLE
@property
def is_aux_heat(self) -> bool:
"""Return if aux heater is on."""

View File

@ -64,16 +64,12 @@ async def async_setup_entry(
class FritzboxThermostat(FritzBoxEntity, ClimateEntity):
"""The thermostat class for FRITZ!SmartHome thermostats."""
_attr_precision = PRECISION_HALVES
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
_attr_temperature_unit = TEMP_CELSIUS
@property
def precision(self) -> float:
"""Return precision 0.5."""
return PRECISION_HALVES
@property
def current_temperature(self) -> float:
"""Return the current temperature."""

View File

@ -113,6 +113,7 @@ async def async_setup_entry(
class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
"""Representation of a Gree HVAC device."""
_attr_precision = PRECISION_WHOLE
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.FAN_MODE
@ -152,11 +153,6 @@ class GreeClimateEntity(CoordinatorEntity, ClimateEntity):
units = self.coordinator.device.temperature_units
return TEMP_CELSIUS if units == TemperatureUnits.C else TEMP_FAHRENHEIT
@property
def precision(self) -> float:
"""Return the precision of temperature for the device."""
return PRECISION_WHOLE
@property
def current_temperature(self) -> float:
"""Return the reported current temperature for the device."""

View File

@ -142,6 +142,7 @@ class ClimateAehW4a1(ClimateEntity):
"""Representation of a Hisense AEH-W4A1 module for climate device."""
_attr_hvac_modes = HVAC_MODES
_attr_precision = PRECISION_WHOLE
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE
| ClimateEntityFeature.FAN_MODE
@ -294,11 +295,6 @@ class ClimateAehW4a1(ClimateEntity):
return MAX_TEMP_C
return MAX_TEMP_F
@property
def precision(self):
"""Return the precision of the system."""
return PRECISION_WHOLE
@property
def target_temperature_step(self):
"""Return the supported step of target temperature."""

View File

@ -76,6 +76,7 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
"""Representation of an ISY994 thermostat entity."""
_attr_hvac_modes = ISY_HVAC_MODES
_attr_precision = PRECISION_TENTHS
_attr_supported_features = (
ClimateEntityFeature.FAN_MODE
| ClimateEntityFeature.TARGET_TEMPERATURE
@ -96,11 +97,6 @@ class ISYThermostatEntity(ISYNodeEntity, ClimateEntity):
self._target_temp_low = 0
self._target_temp_high = 0
@property
def precision(self) -> float:
"""Return the precision of the system."""
return PRECISION_TENTHS
@property
def temperature_unit(self) -> str:
"""Return the unit of measurement."""

View File

@ -126,6 +126,7 @@ def _return_on_connection_error(ret=None):
class ControllerDevice(ClimateEntity):
"""Representation of iZone Controller."""
_attr_precision = PRECISION_TENTHS
_attr_should_poll = False
_attr_temperature_unit = TEMP_CELSIUS
@ -253,11 +254,6 @@ class ControllerDevice(ClimateEntity):
"""Return the name of the entity."""
return f"iZone Controller {self._controller.device_uid}"
@property
def precision(self) -> float:
"""Return the precision of the system."""
return PRECISION_TENTHS
@property
def extra_state_attributes(self):
"""Return the optional state attributes."""
@ -438,6 +434,7 @@ class ControllerDevice(ClimateEntity):
class ZoneDevice(ClimateEntity):
"""Representation of iZone Zone."""
_attr_precision = PRECISION_TENTHS
_attr_should_poll = False
_attr_temperature_unit = TEMP_CELSIUS
@ -526,11 +523,6 @@ class ZoneDevice(ClimateEntity):
return self._attr_supported_features
return self._attr_supported_features & ~ClimateEntityFeature.TARGET_TEMPERATURE
@property
def precision(self):
"""Return the precision of the system."""
return PRECISION_TENTHS
@property
def hvac_mode(self) -> HVACMode | None:
"""Return current operation ie. heat, cool, idle."""

View File

@ -54,6 +54,7 @@ def setup_platform(
class ProliphixThermostat(ClimateEntity):
"""Representation a Proliphix thermostat."""
_attr_precision = PRECISION_TENTHS
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
_attr_temperature_unit = TEMP_FAHRENHEIT
@ -72,15 +73,6 @@ class ProliphixThermostat(ClimateEntity):
"""Return the name of the thermostat."""
return self._name
@property
def precision(self):
"""Return the precision of the system.
Proliphix temperature values are passed back and forth in the
API as tenths of degrees F (i.e. 690 for 69 degrees).
"""
return PRECISION_TENTHS
@property
def extra_state_attributes(self):
"""Return the device specific state attributes."""

View File

@ -106,6 +106,7 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
_attr_fan_modes = [FAN_ON, FAN_AUTO]
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.COOL, HVACMode.OFF, HVACMode.AUTO]
_attr_precision = PRECISION_HALVES
def __init__(
self,
@ -139,15 +140,6 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
return features
@property
def precision(self):
"""Return the precision of the system.
Venstar temperature values are passed back and forth in the
API in C or F, with half-degree accuracy.
"""
return PRECISION_HALVES
@property
def temperature_unit(self):
"""Return the unit of measurement, as defined by the API."""

View File

@ -142,6 +142,7 @@ async def async_setup_entry(
class ViCareClimate(ClimateEntity):
"""Representation of the ViCare heating climate device."""
_attr_precision = PRECISION_TENTHS
_attr_supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
@ -320,11 +321,6 @@ class ViCareClimate(ClimateEntity):
"""Return the maximum temperature."""
return VICARE_TEMP_HEATING_MAX
@property
def precision(self):
"""Return the precision of the system."""
return PRECISION_TENTHS
@property
def target_temperature_step(self) -> float:
"""Set target temperature step to wholes."""

View File

@ -100,6 +100,7 @@ async def async_setup_entry(
class ViCareWater(WaterHeaterEntity):
"""Representation of the ViCare domestic hot water device."""
_attr_precision = PRECISION_TENTHS
_attr_supported_features = WaterHeaterEntityFeature.TARGET_TEMPERATURE
def __init__(self, name, api, circuit, device_config, heating_type):
@ -197,11 +198,6 @@ class ViCareWater(WaterHeaterEntity):
"""Set target temperature step to wholes."""
return PRECISION_WHOLE
@property
def precision(self):
"""Return the precision of the system."""
return PRECISION_TENTHS
@property
def current_operation(self):
"""Return current operation ie. heat, cool, idle."""

View File

@ -137,6 +137,7 @@ class Thermostat(ZhaEntity, ClimateEntity):
DEFAULT_MAX_TEMP = 35
DEFAULT_MIN_TEMP = 7
_attr_precision = PRECISION_TENTHS
_attr_temperature_unit = TEMP_CELSIUS
def __init__(self, unique_id, zha_device, channels, **kwargs):
@ -264,11 +265,6 @@ class Thermostat(ZhaEntity, ClimateEntity):
"""Return the list of available HVAC operation modes."""
return SEQ_OF_OPERATION.get(self._thrm.ctrl_sequence_of_oper, [HVACMode.OFF])
@property
def precision(self):
"""Return the precision of the system."""
return PRECISION_TENTHS
@property
def preset_mode(self) -> str:
"""Return current preset mode."""

View File

@ -126,6 +126,8 @@ async def async_setup_entry(
class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
"""Representation of a Z-Wave climate."""
_attr_precision = PRECISION_TENTHS
def __init__(
self, config_entry: ConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
) -> None:
@ -251,11 +253,6 @@ class ZWaveClimate(ZWaveBaseEntity, ClimateEntity):
return TEMP_FAHRENHEIT
return TEMP_CELSIUS
@property
def precision(self) -> float:
"""Return the precision of 0.1."""
return PRECISION_TENTHS
@property
def hvac_mode(self) -> HVACMode:
"""Return hvac operation ie. heat, cool mode."""