From 0787ee134504f8563d8600430632ee900d8e843f Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Thu, 23 Jun 2022 12:42:05 +0200 Subject: [PATCH] Use attributes in comfoconnect fan (#73892) --- homeassistant/components/comfoconnect/fan.py | 26 ++++---------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/comfoconnect/fan.py b/homeassistant/components/comfoconnect/fan.py index f52c065a547..dd2c9632d7c 100644 --- a/homeassistant/components/comfoconnect/fan.py +++ b/homeassistant/components/comfoconnect/fan.py @@ -53,12 +53,16 @@ def setup_platform( class ComfoConnectFan(FanEntity): """Representation of the ComfoConnect fan platform.""" + _attr_icon = "mdi:air-conditioner" + _attr_should_poll = False _attr_supported_features = FanEntityFeature.SET_SPEED current_speed = None def __init__(self, ccb: ComfoConnectBridge) -> None: """Initialize the ComfoConnect fan.""" self._ccb = ccb + self._attr_name = ccb.name + self._attr_unique_id = ccb.unique_id async def async_added_to_hass(self) -> None: """Register for sensor updates.""" @@ -74,7 +78,7 @@ class ComfoConnectFan(FanEntity): self._ccb.comfoconnect.register_sensor, SENSOR_FAN_SPEED_MODE ) - def _handle_update(self, value): + def _handle_update(self, value: float) -> None: """Handle update callbacks.""" _LOGGER.debug( "Handle update for fan speed (%d): %s", SENSOR_FAN_SPEED_MODE, value @@ -82,26 +86,6 @@ class ComfoConnectFan(FanEntity): self.current_speed = value self.schedule_update_ha_state() - @property - def should_poll(self) -> bool: - """Do not poll.""" - return False - - @property - def unique_id(self): - """Return a unique_id for this entity.""" - return self._ccb.unique_id - - @property - def name(self): - """Return the name of the fan.""" - return self._ccb.name - - @property - def icon(self): - """Return the icon to use in the frontend.""" - return "mdi:air-conditioner" - @property def percentage(self) -> int | None: """Return the current speed percentage."""