Migrate Snooz to has entity name (#98940)

This commit is contained in:
Joost Lekkerkerker 2023-08-24 21:05:00 +02:00 committed by GitHub
parent 948b34b045
commit 417fd0838a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,7 @@ from homeassistant.const import STATE_OFF, STATE_ON
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_platform
from homeassistant.helpers.device_registry import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.restore_state import RestoreEntity
@ -71,15 +72,18 @@ async def async_setup_entry(
class SnoozFan(FanEntity, RestoreEntity):
"""Fan representation of a Snooz device."""
_attr_has_entity_name = True
_attr_name = None
def __init__(self, data: SnoozConfigurationData) -> None:
"""Initialize a Snooz fan entity."""
self._device = data.device
self._attr_name = data.title
self._attr_unique_id = data.device.address
self._attr_supported_features = FanEntityFeature.SET_SPEED
self._attr_should_poll = False
self._is_on: bool | None = None
self._percentage: int | None = None
self._attr_device_info = DeviceInfo(identifiers={(DOMAIN, data.device.address)})
@callback
def _async_write_state_changed(self) -> None: