Set has_entity_name in freedompro (#94603)

Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
Erik Montnemery 2023-06-14 21:42:51 +02:00 committed by GitHub
parent c48afebbfc
commit fa9c31d3db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 16 deletions

View file

@ -46,12 +46,14 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], BinarySensorEntity): class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], BinarySensorEntity):
"""Representation of an Freedompro binary_sensor.""" """Representation of an Freedompro binary_sensor."""
_attr_has_entity_name = True
_attr_name = None
def __init__( def __init__(
self, device: dict[str, Any], coordinator: FreedomproDataUpdateCoordinator self, device: dict[str, Any], coordinator: FreedomproDataUpdateCoordinator
) -> None: ) -> None:
"""Initialize the Freedompro binary_sensor.""" """Initialize the Freedompro binary_sensor."""
super().__init__(coordinator) super().__init__(coordinator)
self._attr_name = device["name"]
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._type = device["type"] self._type = device["type"]
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
@ -60,7 +62,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], BinarySensorEnt
}, },
manufacturer="Freedompro", manufacturer="Freedompro",
model=device["type"], model=device["type"],
name=self.name, name=device["name"],
) )
self._attr_device_class = DEVICE_CLASS_MAP[device["type"]] self._attr_device_class = DEVICE_CLASS_MAP[device["type"]]

View file

@ -60,6 +60,7 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], ClimateEntity): class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], ClimateEntity):
"""Representation of an Freedompro climate.""" """Representation of an Freedompro climate."""
_attr_has_entity_name = True
_attr_hvac_modes = SUPPORTED_HVAC_MODES _attr_hvac_modes = SUPPORTED_HVAC_MODES
_attr_temperature_unit = UnitOfTemperature.CELSIUS _attr_temperature_unit = UnitOfTemperature.CELSIUS
@ -74,7 +75,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], ClimateEntity):
super().__init__(coordinator) super().__init__(coordinator)
self._session = session self._session = session
self._api_key = api_key self._api_key = api_key
self._attr_name = device["name"] self._attr_name = None
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._characteristics = device["characteristics"] self._characteristics = device["characteristics"]
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
@ -83,7 +84,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], ClimateEntity):
}, },
manufacturer="Freedompro", manufacturer="Freedompro",
model=device["type"], model=device["type"],
name=self.name, name=device["name"],
) )
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
self._attr_current_temperature = 0 self._attr_current_temperature = 0

View file

@ -48,6 +48,9 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], CoverEntity): class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], CoverEntity):
"""Representation of an Freedompro cover.""" """Representation of an Freedompro cover."""
_attr_has_entity_name = True
_attr_name = None
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
@ -59,7 +62,6 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], CoverEntity):
super().__init__(coordinator) super().__init__(coordinator)
self._session = aiohttp_client.async_get_clientsession(hass) self._session = aiohttp_client.async_get_clientsession(hass)
self._api_key = api_key self._api_key = api_key
self._attr_name = device["name"]
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
identifiers={ identifiers={
@ -67,7 +69,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], CoverEntity):
}, },
manufacturer="Freedompro", manufacturer="Freedompro",
model=device["type"], model=device["type"],
name=self.name, name=device["name"],
) )
self._attr_current_cover_position = 0 self._attr_current_cover_position = 0
self._attr_is_closed = True self._attr_is_closed = True

View file

@ -35,6 +35,9 @@ async def async_setup_entry(
class FreedomproFan(CoordinatorEntity[FreedomproDataUpdateCoordinator], FanEntity): class FreedomproFan(CoordinatorEntity[FreedomproDataUpdateCoordinator], FanEntity):
"""Representation of an Freedompro fan.""" """Representation of an Freedompro fan."""
_attr_has_entity_name = True
_attr_name = None
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
@ -46,7 +49,6 @@ class FreedomproFan(CoordinatorEntity[FreedomproDataUpdateCoordinator], FanEntit
super().__init__(coordinator) super().__init__(coordinator)
self._session = aiohttp_client.async_get_clientsession(hass) self._session = aiohttp_client.async_get_clientsession(hass)
self._api_key = api_key self._api_key = api_key
self._attr_name = device["name"]
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._characteristics = device["characteristics"] self._characteristics = device["characteristics"]
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
@ -55,7 +57,7 @@ class FreedomproFan(CoordinatorEntity[FreedomproDataUpdateCoordinator], FanEntit
}, },
manufacturer="Freedompro", manufacturer="Freedompro",
model=device["type"], model=device["type"],
name=self.name, name=device["name"],
) )
self._attr_is_on = False self._attr_is_on = False
self._attr_percentage = 0 self._attr_percentage = 0

View file

@ -40,6 +40,9 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], LightEntity): class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], LightEntity):
"""Representation of an Freedompro light.""" """Representation of an Freedompro light."""
_attr_has_entity_name = True
_attr_name = None
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
@ -51,13 +54,12 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], LightEntity):
super().__init__(coordinator) super().__init__(coordinator)
self._session = aiohttp_client.async_get_clientsession(hass) self._session = aiohttp_client.async_get_clientsession(hass)
self._api_key = api_key self._api_key = api_key
self._attr_name = device["name"]
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, device["uid"])}, identifiers={(DOMAIN, device["uid"])},
manufacturer="Freedompro", manufacturer="Freedompro",
model=device["type"], model=device["type"],
name=self.name, name=device["name"],
) )
self._attr_is_on = False self._attr_is_on = False
self._attr_brightness = 0 self._attr_brightness = 0

View file

@ -33,6 +33,9 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], LockEntity): class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], LockEntity):
"""Representation of an Freedompro lock.""" """Representation of an Freedompro lock."""
_attr_has_entity_name = True
_attr_name = None
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
@ -45,7 +48,6 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], LockEntity):
self._hass = hass self._hass = hass
self._session = aiohttp_client.async_get_clientsession(self._hass) self._session = aiohttp_client.async_get_clientsession(self._hass)
self._api_key = api_key self._api_key = api_key
self._attr_name = device["name"]
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._type = device["type"] self._type = device["type"]
self._characteristics = device["characteristics"] self._characteristics = device["characteristics"]
@ -55,7 +57,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], LockEntity):
}, },
manufacturer="Freedompro", manufacturer="Freedompro",
model=self._type, model=self._type,
name=self.name, name=device["name"],
) )
@callback @callback

View file

@ -54,12 +54,14 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SensorEntity): class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SensorEntity):
"""Representation of an Freedompro sensor.""" """Representation of an Freedompro sensor."""
_attr_has_entity_name = True
_attr_name = None
def __init__( def __init__(
self, device: dict[str, Any], coordinator: FreedomproDataUpdateCoordinator self, device: dict[str, Any], coordinator: FreedomproDataUpdateCoordinator
) -> None: ) -> None:
"""Initialize the Freedompro sensor.""" """Initialize the Freedompro sensor."""
super().__init__(coordinator) super().__init__(coordinator)
self._attr_name = device["name"]
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._type = device["type"] self._type = device["type"]
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
@ -68,7 +70,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SensorEntity):
}, },
manufacturer="Freedompro", manufacturer="Freedompro",
model=device["type"], model=device["type"],
name=self.name, name=device["name"],
) )
self._attr_device_class = DEVICE_CLASS_MAP[device["type"]] self._attr_device_class = DEVICE_CLASS_MAP[device["type"]]
self._attr_state_class = STATE_CLASS_MAP[device["type"]] self._attr_state_class = STATE_CLASS_MAP[device["type"]]

View file

@ -33,6 +33,9 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SwitchEntity): class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SwitchEntity):
"""Representation of an Freedompro switch.""" """Representation of an Freedompro switch."""
_attr_has_entity_name = True
_attr_name = None
def __init__( def __init__(
self, self,
hass: HomeAssistant, hass: HomeAssistant,
@ -44,7 +47,6 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SwitchEntity):
super().__init__(coordinator) super().__init__(coordinator)
self._session = aiohttp_client.async_get_clientsession(hass) self._session = aiohttp_client.async_get_clientsession(hass)
self._api_key = api_key self._api_key = api_key
self._attr_name = device["name"]
self._attr_unique_id = device["uid"] self._attr_unique_id = device["uid"]
self._attr_device_info = DeviceInfo( self._attr_device_info = DeviceInfo(
identifiers={ identifiers={
@ -52,7 +54,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SwitchEntity):
}, },
manufacturer="Freedompro", manufacturer="Freedompro",
model=device["type"], model=device["type"],
name=self.name, name=device["name"],
) )
self._attr_is_on = False self._attr_is_on = False