Migrate Deluge to new entity naming style (#75359)

This commit is contained in:
Robert Hillis 2022-07-17 10:59:13 -04:00 committed by GitHub
parent 8d63f81821
commit 460f522d6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -73,6 +73,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
class DelugeEntity(CoordinatorEntity[DelugeDataUpdateCoordinator]): class DelugeEntity(CoordinatorEntity[DelugeDataUpdateCoordinator]):
"""Representation of a Deluge entity.""" """Representation of a Deluge entity."""
_attr_has_entity_name = True
def __init__(self, coordinator: DelugeDataUpdateCoordinator) -> None: def __init__(self, coordinator: DelugeDataUpdateCoordinator) -> None:
"""Initialize a Deluge entity.""" """Initialize a Deluge entity."""
super().__init__(coordinator) super().__init__(coordinator)

View File

@ -52,14 +52,14 @@ SENSOR_TYPES: tuple[DelugeSensorEntityDescription, ...] = (
), ),
DelugeSensorEntityDescription( DelugeSensorEntityDescription(
key=DOWNLOAD_SPEED, key=DOWNLOAD_SPEED,
name="Down Speed", name="Down speed",
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND, native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
value=lambda data: get_state(data, DOWNLOAD_SPEED), value=lambda data: get_state(data, DOWNLOAD_SPEED),
), ),
DelugeSensorEntityDescription( DelugeSensorEntityDescription(
key=UPLOAD_SPEED, key=UPLOAD_SPEED,
name="Up Speed", name="Up speed",
native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND, native_unit_of_measurement=DATA_RATE_KILOBYTES_PER_SECOND,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
value=lambda data: get_state(data, UPLOAD_SPEED), value=lambda data: get_state(data, UPLOAD_SPEED),
@ -92,7 +92,6 @@ class DelugeSensor(DelugeEntity, SensorEntity):
"""Initialize the sensor.""" """Initialize the sensor."""
super().__init__(coordinator) super().__init__(coordinator)
self.entity_description = description self.entity_description = description
self._attr_name = f"{coordinator.config_entry.title} {description.name}"
self._attr_unique_id = f"{coordinator.config_entry.entry_id}_{description.key}" self._attr_unique_id = f"{coordinator.config_entry.entry_id}_{description.key}"
@property @property

View File

@ -29,7 +29,6 @@ class DelugeSwitch(DelugeEntity, SwitchEntity):
def __init__(self, coordinator: DelugeDataUpdateCoordinator) -> None: def __init__(self, coordinator: DelugeDataUpdateCoordinator) -> None:
"""Initialize the Deluge switch.""" """Initialize the Deluge switch."""
super().__init__(coordinator) super().__init__(coordinator)
self._attr_name = coordinator.config_entry.title
self._attr_unique_id = f"{coordinator.config_entry.entry_id}_enabled" self._attr_unique_id = f"{coordinator.config_entry.entry_id}_enabled"
def turn_on(self, **kwargs: Any) -> None: def turn_on(self, **kwargs: Any) -> None: