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