Use attributes in comfoconnect fan (#73892)

This commit is contained in:
epenet 2022-06-23 12:42:05 +02:00 committed by GitHub
parent b4cc9367cf
commit 0787ee1345
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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."""