mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Migrate Deluge to new entity naming style (#75359)
This commit is contained in:
parent
8d63f81821
commit
460f522d6d
@ -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)
|
||||||
|
@ -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
|
||||||
|
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user