mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use shorthand attributes for Ecobee (#99239)
* Use shorthand attributes for Ecobee * Use shorthand attributes for Ecobee
This commit is contained in:
parent
a4818c5f54
commit
775f815afc
@ -43,7 +43,6 @@ class EcobeeBinarySensor(BinarySensorEntity):
|
|||||||
self.data = data
|
self.data = data
|
||||||
self.sensor_name = sensor_name.rstrip()
|
self.sensor_name = sensor_name.rstrip()
|
||||||
self.index = sensor_index
|
self.index = sensor_index
|
||||||
self._state = None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
@ -93,11 +92,6 @@ class EcobeeBinarySensor(BinarySensorEntity):
|
|||||||
thermostat = self.data.ecobee.get_thermostat(self.index)
|
thermostat = self.data.ecobee.get_thermostat(self.index)
|
||||||
return thermostat["runtime"]["connected"]
|
return thermostat["runtime"]["connected"]
|
||||||
|
|
||||||
@property
|
|
||||||
def is_on(self):
|
|
||||||
"""Return the status of the sensor."""
|
|
||||||
return self._state == "true"
|
|
||||||
|
|
||||||
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()
|
||||||
@ -107,5 +101,5 @@ class EcobeeBinarySensor(BinarySensorEntity):
|
|||||||
for item in sensor["capability"]:
|
for item in sensor["capability"]:
|
||||||
if item["type"] != "occupancy":
|
if item["type"] != "occupancy":
|
||||||
continue
|
continue
|
||||||
self._state = item["value"]
|
self._attr_is_on = item["value"] == "true"
|
||||||
break
|
break
|
||||||
|
@ -310,6 +310,9 @@ class Thermostat(ClimateEntity):
|
|||||||
|
|
||||||
_attr_precision = PRECISION_TENTHS
|
_attr_precision = PRECISION_TENTHS
|
||||||
_attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
_attr_temperature_unit = UnitOfTemperature.FAHRENHEIT
|
||||||
|
_attr_min_humidity = DEFAULT_MIN_HUMIDITY
|
||||||
|
_attr_max_humidity = DEFAULT_MAX_HUMIDITY
|
||||||
|
_attr_fan_modes = [FAN_AUTO, FAN_ON]
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
@ -324,20 +327,19 @@ class Thermostat(ClimateEntity):
|
|||||||
self.vacation = None
|
self.vacation = None
|
||||||
self._last_active_hvac_mode = HVACMode.HEAT_COOL
|
self._last_active_hvac_mode = HVACMode.HEAT_COOL
|
||||||
|
|
||||||
self._operation_list = []
|
self._attr_hvac_modes = []
|
||||||
if self.settings["heatStages"] or self.settings["hasHeatPump"]:
|
if self.settings["heatStages"] or self.settings["hasHeatPump"]:
|
||||||
self._operation_list.append(HVACMode.HEAT)
|
self._attr_hvac_modes.append(HVACMode.HEAT)
|
||||||
if self.settings["coolStages"]:
|
if self.settings["coolStages"]:
|
||||||
self._operation_list.append(HVACMode.COOL)
|
self._attr_hvac_modes.append(HVACMode.COOL)
|
||||||
if len(self._operation_list) == 2:
|
if len(self._attr_hvac_modes) == 2:
|
||||||
self._operation_list.insert(0, HVACMode.HEAT_COOL)
|
self._attr_hvac_modes.insert(0, HVACMode.HEAT_COOL)
|
||||||
self._operation_list.append(HVACMode.OFF)
|
self._attr_hvac_modes.append(HVACMode.OFF)
|
||||||
|
|
||||||
self._preset_modes = {
|
self._preset_modes = {
|
||||||
comfort["climateRef"]: comfort["name"]
|
comfort["climateRef"]: comfort["name"]
|
||||||
for comfort in self.thermostat["program"]["climates"]
|
for comfort in self.thermostat["program"]["climates"]
|
||||||
}
|
}
|
||||||
self._fan_modes = [FAN_AUTO, FAN_ON]
|
|
||||||
self.update_without_throttle = False
|
self.update_without_throttle = False
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
@ -432,16 +434,6 @@ class Thermostat(ClimateEntity):
|
|||||||
return self.thermostat["runtime"]["desiredHumidity"]
|
return self.thermostat["runtime"]["desiredHumidity"]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
|
||||||
def min_humidity(self) -> int:
|
|
||||||
"""Return the minimum humidity."""
|
|
||||||
return DEFAULT_MIN_HUMIDITY
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_humidity(self) -> int:
|
|
||||||
"""Return the maximum humidity."""
|
|
||||||
return DEFAULT_MAX_HUMIDITY
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self) -> float | None:
|
def target_temperature(self) -> float | None:
|
||||||
"""Return the temperature we try to reach."""
|
"""Return the temperature we try to reach."""
|
||||||
@ -465,11 +457,6 @@ class Thermostat(ClimateEntity):
|
|||||||
"""Return the fan setting."""
|
"""Return the fan setting."""
|
||||||
return self.thermostat["runtime"]["desiredFanMode"]
|
return self.thermostat["runtime"]["desiredFanMode"]
|
||||||
|
|
||||||
@property
|
|
||||||
def fan_modes(self):
|
|
||||||
"""Return the available fan modes."""
|
|
||||||
return self._fan_modes
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_mode(self):
|
def preset_mode(self):
|
||||||
"""Return current preset mode."""
|
"""Return current preset mode."""
|
||||||
@ -498,11 +485,6 @@ class Thermostat(ClimateEntity):
|
|||||||
"""Return current operation."""
|
"""Return current operation."""
|
||||||
return ECOBEE_HVAC_TO_HASS[self.settings["hvacMode"]]
|
return ECOBEE_HVAC_TO_HASS[self.settings["hvacMode"]]
|
||||||
|
|
||||||
@property
|
|
||||||
def hvac_modes(self):
|
|
||||||
"""Return the operation modes list."""
|
|
||||||
return self._operation_list
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_humidity(self) -> int | None:
|
def current_humidity(self) -> int | None:
|
||||||
"""Return the current humidity."""
|
"""Return the current humidity."""
|
||||||
|
@ -44,6 +44,10 @@ 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_available_modes = [MODE_OFF, MODE_AUTO, MODE_MANUAL]
|
||||||
|
_attr_device_class = HumidifierDeviceClass.HUMIDIFIER
|
||||||
|
_attr_min_humidity = DEFAULT_MIN_HUMIDITY
|
||||||
|
_attr_max_humidity = DEFAULT_MAX_HUMIDITY
|
||||||
_attr_has_entity_name = True
|
_attr_has_entity_name = True
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
|
||||||
@ -90,31 +94,11 @@ class EcobeeHumidifier(HumidifierEntity):
|
|||||||
if self.mode != MODE_OFF:
|
if self.mode != MODE_OFF:
|
||||||
self._last_humidifier_on_mode = self.mode
|
self._last_humidifier_on_mode = self.mode
|
||||||
|
|
||||||
@property
|
|
||||||
def available_modes(self):
|
|
||||||
"""Return the list of available modes."""
|
|
||||||
return [MODE_OFF, MODE_AUTO, MODE_MANUAL]
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_class(self):
|
|
||||||
"""Return the device class type."""
|
|
||||||
return HumidifierDeviceClass.HUMIDIFIER
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return True if the humidifier is on."""
|
"""Return True if the humidifier is on."""
|
||||||
return self.mode != MODE_OFF
|
return self.mode != MODE_OFF
|
||||||
|
|
||||||
@property
|
|
||||||
def max_humidity(self):
|
|
||||||
"""Return the maximum humidity."""
|
|
||||||
return DEFAULT_MAX_HUMIDITY
|
|
||||||
|
|
||||||
@property
|
|
||||||
def min_humidity(self):
|
|
||||||
"""Return the minimum humidity."""
|
|
||||||
return DEFAULT_MIN_HUMIDITY
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mode(self):
|
def mode(self):
|
||||||
"""Return the current mode, e.g., off, auto, manual."""
|
"""Return the current mode, e.g., off, auto, manual."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user