mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add unique ids to sensors (#71367)
This commit is contained in:
parent
c8f95b7dfc
commit
afe4892ae6
@ -3,8 +3,6 @@
|
|||||||
"name": "SABnzbd",
|
"name": "SABnzbd",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/sabnzbd",
|
"documentation": "https://www.home-assistant.io/integrations/sabnzbd",
|
||||||
"requirements": ["pysabnzbd==1.1.1"],
|
"requirements": ["pysabnzbd==1.1.1"],
|
||||||
"dependencies": ["configurator"],
|
|
||||||
"after_dependencies": ["discovery"],
|
|
||||||
"codeowners": ["@shaiu"],
|
"codeowners": ["@shaiu"],
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
|
@ -14,8 +14,10 @@ from . import DOMAIN, SIGNAL_SABNZBD_UPDATED
|
|||||||
from ...config_entries import ConfigEntry
|
from ...config_entries import ConfigEntry
|
||||||
from ...const import DATA_GIGABYTES, DATA_MEGABYTES, DATA_RATE_MEGABYTES_PER_SECOND
|
from ...const import DATA_GIGABYTES, DATA_MEGABYTES, DATA_RATE_MEGABYTES_PER_SECOND
|
||||||
from ...core import HomeAssistant
|
from ...core import HomeAssistant
|
||||||
|
from ...helpers.device_registry import DeviceEntryType
|
||||||
|
from ...helpers.entity import DeviceInfo
|
||||||
from ...helpers.entity_platform import AddEntitiesCallback
|
from ...helpers.entity_platform import AddEntitiesCallback
|
||||||
from .const import KEY_API_DATA, KEY_NAME
|
from .const import DEFAULT_NAME, KEY_API_DATA, KEY_NAME
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -127,9 +129,16 @@ class SabnzbdSensor(SensorEntity):
|
|||||||
self, sabnzbd_api_data, client_name, description: SabnzbdSensorEntityDescription
|
self, sabnzbd_api_data, client_name, description: SabnzbdSensorEntityDescription
|
||||||
):
|
):
|
||||||
"""Initialize the sensor."""
|
"""Initialize the sensor."""
|
||||||
|
unique_id = description.key
|
||||||
|
self._attr_unique_id = unique_id
|
||||||
self.entity_description = description
|
self.entity_description = description
|
||||||
self._sabnzbd_api = sabnzbd_api_data
|
self._sabnzbd_api = sabnzbd_api_data
|
||||||
self._attr_name = f"{client_name} {description.name}"
|
self._attr_name = f"{client_name} {description.name}"
|
||||||
|
self._attr_device_info = DeviceInfo(
|
||||||
|
entry_type=DeviceEntryType.SERVICE,
|
||||||
|
identifiers={(DOMAIN, DOMAIN)},
|
||||||
|
name=DEFAULT_NAME,
|
||||||
|
)
|
||||||
|
|
||||||
async def async_added_to_hass(self):
|
async def async_added_to_hass(self):
|
||||||
"""Call when entity about to be added to hass."""
|
"""Call when entity about to be added to hass."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user