Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions homeassistant/components/sabnzbd/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"name": "SABnzbd",
"documentation": "https://www.home-assistant.io/integrations/sabnzbd",
"requirements": ["pysabnzbd==1.1.1"],
"dependencies": ["configurator"],
"after_dependencies": ["discovery"],
"codeowners": ["@shaiu"],
"iot_class": "local_polling",
"config_flow": true,
Expand Down
11 changes: 10 additions & 1 deletion homeassistant/components/sabnzbd/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
from ...config_entries import ConfigEntry
from ...const import DATA_GIGABYTES, DATA_MEGABYTES, DATA_RATE_MEGABYTES_PER_SECOND
from ...core import HomeAssistant
from ...helpers.device_registry import DeviceEntryType
from ...helpers.entity import DeviceInfo
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
Expand Down Expand Up @@ -127,9 +129,16 @@ def __init__(
self, sabnzbd_api_data, client_name, description: SabnzbdSensorEntityDescription
):
"""Initialize the sensor."""
unique_id = description.key
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the key is not unique enough if more than one config entry is setup. We could prefix with the config entry entry_id if there's no better unique_id.

https://developers.home-assistant.io/docs/entity_registry_index#unique-id-requirements

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self._attr_unique_id = unique_id
self.entity_description = description
self._sabnzbd_api = sabnzbd_api_data
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):
"""Call when entity about to be added to hass."""
Expand Down