Revert "Adapt tplink to use has_entity_name" (#85595)

Revert "Adapt tplink to use has_entity_name (#85577)"

This reverts commit ca0fe488ba65abaf7a4b8560bd1a4295e1660199.
This commit is contained in:
Franck Nijhof 2023-01-10 10:06:58 +01:00 committed by GitHub
parent d40a4aa970
commit bba9ad3243
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 7 deletions

View File

@ -39,7 +39,7 @@ class CoordinatedTPLinkEntity(CoordinatorEntity[TPLinkDataUpdateCoordinator]):
"""Initialize the switch."""
super().__init__(coordinator)
self.device: SmartDevice = device
self._attr_has_entity_name = True
self._attr_name = self.device.alias
self._attr_unique_id = self.device.device_id
@property

View File

@ -154,7 +154,14 @@ class SmartPlugSensor(CoordinatedTPLinkEntity, SensorEntity):
self._attr_unique_id = (
f"{legacy_device_id(self.device)}_{self.entity_description.key}"
)
self._attr_name = self.entity_description.name
@property
def name(self) -> str:
"""Return the name of the Smart Plug.
Overridden to include the description.
"""
return f"{self.device.alias} {self.entity_description.name}"
@property
def native_value(self) -> float | None:

View File

@ -57,7 +57,7 @@ class SmartPlugLedSwitch(CoordinatedTPLinkEntity, SwitchEntity):
"""Initialize the LED switch."""
super().__init__(device, coordinator)
self._attr_name = "LED"
self._attr_name = f"{device.alias} LED"
self._attr_unique_id = f"{self.device.mac}_led"
@property
@ -93,9 +93,6 @@ class SmartPlugSwitch(CoordinatedTPLinkEntity, SwitchEntity):
super().__init__(device, coordinator)
# For backwards compat with pyHS100
self._attr_unique_id = legacy_device_id(device)
# Define names for single sockets
if device.is_strip_socket:
self._attr_name = device.alias
@async_refresh_after
async def async_turn_on(self, **kwargs: Any) -> None:

View File

@ -149,7 +149,6 @@ def _mocked_plug() -> SmartPlug:
plug.is_dimmer = False
plug.is_strip = False
plug.is_plug = True
plug.is_strip_socket = False
plug.device_id = MAC_ADDRESS
plug.hw_info = {"sw_ver": "1.0.0", "hw_ver": "1.0.0"}
plug.turn_off = AsyncMock()