mirror of
https://github.com/home-assistant/core
synced 2024-10-05 15:22:20 +00:00
Add entity translations to ecobee (#95281)
This commit is contained in:
parent
320003bf15
commit
cb9cbdfb28
|
@ -35,19 +35,16 @@ async def async_setup_entry(
|
|||
class EcobeeBinarySensor(BinarySensorEntity):
|
||||
"""Representation of an Ecobee sensor."""
|
||||
|
||||
_attr_device_class = BinarySensorDeviceClass.OCCUPANCY
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(self, data, sensor_name, sensor_index):
|
||||
"""Initialize the Ecobee sensor."""
|
||||
self.data = data
|
||||
self._name = f"{sensor_name} Occupancy"
|
||||
self.sensor_name = sensor_name
|
||||
self.sensor_name = sensor_name.rstrip()
|
||||
self.index = sensor_index
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the Ecobee sensor."""
|
||||
return self._name.rstrip()
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier for this sensor."""
|
||||
|
@ -101,11 +98,6 @@ class EcobeeBinarySensor(BinarySensorEntity):
|
|||
"""Return the status of the sensor."""
|
||||
return self._state == "true"
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this sensor, from DEVICE_CLASSES."""
|
||||
return BinarySensorDeviceClass.OCCUPANCY
|
||||
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest state of the sensor."""
|
||||
await self.data.update()
|
||||
|
|
|
@ -310,6 +310,8 @@ class Thermostat(ClimateEntity):
|
|||
|
||||
_attr_precision = PRECISION_TENTHS
|
||||
_attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||
_attr_name = None
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self, data: EcobeeData, thermostat_index: int, thermostat: dict
|
||||
|
@ -318,7 +320,7 @@ class Thermostat(ClimateEntity):
|
|||
self.data = data
|
||||
self.thermostat_index = thermostat_index
|
||||
self.thermostat = thermostat
|
||||
self._name = self.thermostat["name"]
|
||||
self._attr_unique_id = self.thermostat["identifier"]
|
||||
self.vacation = None
|
||||
self._last_active_hvac_mode = HVACMode.HEAT_COOL
|
||||
|
||||
|
@ -364,16 +366,6 @@ class Thermostat(ClimateEntity):
|
|||
supported = supported | ClimateEntityFeature.AUX_HEAT
|
||||
return supported
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the Ecobee Thermostat."""
|
||||
return self.thermostat["name"]
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier for this ecobee thermostat."""
|
||||
return self.thermostat["identifier"]
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information for this ecobee thermostat."""
|
||||
|
@ -388,7 +380,7 @@ class Thermostat(ClimateEntity):
|
|||
identifiers={(DOMAIN, self.thermostat["identifier"])},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=model,
|
||||
name=self.name,
|
||||
name=self.thermostat["name"],
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -44,27 +44,19 @@ class EcobeeHumidifier(HumidifierEntity):
|
|||
"""A humidifier class for an ecobee thermostat with humidifier attached."""
|
||||
|
||||
_attr_supported_features = HumidifierEntityFeature.MODES
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, data, thermostat_index):
|
||||
"""Initialize ecobee humidifier platform."""
|
||||
self.data = data
|
||||
self.thermostat_index = thermostat_index
|
||||
self.thermostat = self.data.ecobee.get_thermostat(self.thermostat_index)
|
||||
self._name = self.thermostat["name"]
|
||||
self._attr_unique_id = self.thermostat["identifier"]
|
||||
self._last_humidifier_on_mode = MODE_MANUAL
|
||||
|
||||
self.update_without_throttle = False
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the humidifier."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return unique_id for humidifier."""
|
||||
return f"{self.thermostat['identifier']}"
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information for the ecobee humidifier."""
|
||||
|
@ -79,7 +71,7 @@ class EcobeeHumidifier(HumidifierEntity):
|
|||
identifiers={(DOMAIN, self.thermostat["identifier"])},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=model,
|
||||
name=self.name,
|
||||
name=self.thermostat["name"],
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -36,7 +36,7 @@ class EcobeeNumberEntityDescription(
|
|||
VENTILATOR_NUMBERS = (
|
||||
EcobeeNumberEntityDescription(
|
||||
key="home",
|
||||
name="home",
|
||||
translation_key="ventilator_min_type_home",
|
||||
ecobee_setting_key="ventilatorMinOnTimeHome",
|
||||
set_fn=lambda data, id, min_time: data.ecobee.set_ventilator_min_on_time_home(
|
||||
id, min_time
|
||||
|
@ -44,7 +44,7 @@ VENTILATOR_NUMBERS = (
|
|||
),
|
||||
EcobeeNumberEntityDescription(
|
||||
key="away",
|
||||
name="away",
|
||||
translation_key="ventilator_min_type_away",
|
||||
ecobee_setting_key="ventilatorMinOnTimeAway",
|
||||
set_fn=lambda data, id, min_time: data.ecobee.set_ventilator_min_on_time_away(
|
||||
id, min_time
|
||||
|
@ -92,7 +92,6 @@ class EcobeeVentilatorMinTime(EcobeeBaseEntity, NumberEntity):
|
|||
"""Initialize ecobee ventilator platform."""
|
||||
super().__init__(data, thermostat_index)
|
||||
self.entity_description = description
|
||||
self._attr_name = f"Ventilator min time {description.name}"
|
||||
self._attr_unique_id = f"{self.base_unique_id}_ventilator_{description.key}"
|
||||
|
||||
async def async_update(self) -> None:
|
||||
|
|
|
@ -42,7 +42,6 @@ class EcobeeSensorEntityDescription(
|
|||
SENSOR_TYPES: tuple[EcobeeSensorEntityDescription, ...] = (
|
||||
EcobeeSensorEntityDescription(
|
||||
key="temperature",
|
||||
name="Temperature",
|
||||
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -50,7 +49,6 @@ SENSOR_TYPES: tuple[EcobeeSensorEntityDescription, ...] = (
|
|||
),
|
||||
EcobeeSensorEntityDescription(
|
||||
key="humidity",
|
||||
name="Humidity",
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -58,7 +56,6 @@ SENSOR_TYPES: tuple[EcobeeSensorEntityDescription, ...] = (
|
|||
),
|
||||
EcobeeSensorEntityDescription(
|
||||
key="co2PPM",
|
||||
name="CO2",
|
||||
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
|
||||
device_class=SensorDeviceClass.CO2,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -66,7 +63,6 @@ SENSOR_TYPES: tuple[EcobeeSensorEntityDescription, ...] = (
|
|||
),
|
||||
EcobeeSensorEntityDescription(
|
||||
key="vocPPM",
|
||||
name="VOC",
|
||||
device_class=SensorDeviceClass.VOLATILE_ORGANIC_COMPOUNDS,
|
||||
native_unit_of_measurement=CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -74,7 +70,6 @@ SENSOR_TYPES: tuple[EcobeeSensorEntityDescription, ...] = (
|
|||
),
|
||||
EcobeeSensorEntityDescription(
|
||||
key="airQuality",
|
||||
name="Air Quality Index",
|
||||
device_class=SensorDeviceClass.AQI,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
runtime_key="actualAQScore",
|
||||
|
@ -104,6 +99,8 @@ async def async_setup_entry(
|
|||
class EcobeeSensor(SensorEntity):
|
||||
"""Representation of an Ecobee sensor."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
entity_description: EcobeeSensorEntityDescription
|
||||
|
||||
def __init__(
|
||||
|
@ -119,7 +116,6 @@ class EcobeeSensor(SensorEntity):
|
|||
self.sensor_name = sensor_name
|
||||
self.index = sensor_index
|
||||
self._state = None
|
||||
self._attr_name = f"{sensor_name} {description.name}"
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -20,5 +20,15 @@
|
|||
"abort": {
|
||||
"single_instance_allowed": "[%key:common::config_flow::abort::single_instance_allowed%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"number": {
|
||||
"ventilator_min_type_home": {
|
||||
"name": "Ventilator min time home"
|
||||
},
|
||||
"ventilator_min_type_away": {
|
||||
"name": "Ventilator min time away"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ class EcobeeWeather(WeatherEntity):
|
|||
_attr_native_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||
_attr_native_visibility_unit = UnitOfLength.METERS
|
||||
_attr_native_wind_speed_unit = UnitOfSpeed.METERS_PER_SECOND
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, data, name, index):
|
||||
"""Initialize the Ecobee weather platform."""
|
||||
|
@ -64,6 +66,7 @@ class EcobeeWeather(WeatherEntity):
|
|||
self._name = name
|
||||
self._index = index
|
||||
self.weather = None
|
||||
self._attr_unique_id = data.ecobee.get_thermostat(self._index)["identifier"]
|
||||
|
||||
def get_forecast(self, index, param):
|
||||
"""Retrieve forecast parameter."""
|
||||
|
@ -73,16 +76,6 @@ class EcobeeWeather(WeatherEntity):
|
|||
except (IndexError, KeyError) as err:
|
||||
raise ValueError from err
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
"""Return a unique identifier for the weather platform."""
|
||||
return self.data.ecobee.get_thermostat(self._index)["identifier"]
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device information for the ecobee weather platform."""
|
||||
|
@ -98,7 +91,7 @@ class EcobeeWeather(WeatherEntity):
|
|||
identifiers={(DOMAIN, thermostat["identifier"])},
|
||||
manufacturer=MANUFACTURER,
|
||||
model=model,
|
||||
name=self.name,
|
||||
name=self._name,
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -25,6 +25,7 @@ def ecobee_fixture():
|
|||
vals = {
|
||||
"name": "Ecobee",
|
||||
"modelNumber": "athenaSmart",
|
||||
"identifier": "abc",
|
||||
"program": {
|
||||
"climates": [
|
||||
{"name": "Climate1", "climateRef": "c1"},
|
||||
|
@ -83,7 +84,7 @@ def thermostat_fixture(data):
|
|||
|
||||
async def test_name(thermostat) -> None:
|
||||
"""Test name property."""
|
||||
assert thermostat.name == "Ecobee"
|
||||
assert thermostat.device_info["name"] == "Ecobee"
|
||||
|
||||
|
||||
async def test_aux_heat_not_supported_by_default(hass: HomeAssistant) -> None:
|
||||
|
|
Loading…
Reference in a new issue