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):
"""Representation of an Freedompro binary_sensor."""
_attr_has_entity_name = True
_attr_name = None
def __init__(
self, device: dict[str, Any], coordinator: FreedomproDataUpdateCoordinator
) -> None:
"""Initialize the Freedompro binary_sensor."""
super().__init__(coordinator)
self._attr_name = device["name"]
self._attr_unique_id = device["uid"]
self._type = device["type"]
self._attr_device_info = DeviceInfo(
@ -60,7 +62,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], BinarySensorEnt
},
manufacturer="Freedompro",
model=device["type"],
name=self.name,
name=device["name"],
)
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):
"""Representation of an Freedompro climate."""
_attr_has_entity_name = True
_attr_hvac_modes = SUPPORTED_HVAC_MODES
_attr_temperature_unit = UnitOfTemperature.CELSIUS
@ -74,7 +75,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], ClimateEntity):
super().__init__(coordinator)
self._session = session
self._api_key = api_key
self._attr_name = device["name"]
self._attr_name = None
self._attr_unique_id = device["uid"]
self._characteristics = device["characteristics"]
self._attr_device_info = DeviceInfo(
@ -83,7 +84,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], ClimateEntity):
},
manufacturer="Freedompro",
model=device["type"],
name=self.name,
name=device["name"],
)
self._attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
self._attr_current_temperature = 0

View file

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

View file

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

View file

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

View file

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

View file

@ -54,12 +54,14 @@ async def async_setup_entry(
class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SensorEntity):
"""Representation of an Freedompro sensor."""
_attr_has_entity_name = True
_attr_name = None
def __init__(
self, device: dict[str, Any], coordinator: FreedomproDataUpdateCoordinator
) -> None:
"""Initialize the Freedompro sensor."""
super().__init__(coordinator)
self._attr_name = device["name"]
self._attr_unique_id = device["uid"]
self._type = device["type"]
self._attr_device_info = DeviceInfo(
@ -68,7 +70,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SensorEntity):
},
manufacturer="Freedompro",
model=device["type"],
name=self.name,
name=device["name"],
)
self._attr_device_class = DEVICE_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):
"""Representation of an Freedompro switch."""
_attr_has_entity_name = True
_attr_name = None
def __init__(
self,
hass: HomeAssistant,
@ -44,7 +47,6 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SwitchEntity):
super().__init__(coordinator)
self._session = aiohttp_client.async_get_clientsession(hass)
self._api_key = api_key
self._attr_name = device["name"]
self._attr_unique_id = device["uid"]
self._attr_device_info = DeviceInfo(
identifiers={
@ -52,7 +54,7 @@ class Device(CoordinatorEntity[FreedomproDataUpdateCoordinator], SwitchEntity):
},
manufacturer="Freedompro",
model=device["type"],
name=self.name,
name=device["name"],
)
self._attr_is_on = False