forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add device info to Nextcloud integration (home-assistant#90328)
* add device_info * use entry_id as identifier + device name * use shorthand attributes * remove model from device info Co-authored-by: Franck Nijhof <[email protected]> --------- Co-authored-by: Franck Nijhof <[email protected]>
- Loading branch information
Showing
3 changed files
with
16 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
"""Base entity for the Nextcloud integration.""" | ||
|
||
|
||
from homeassistant.config_entries import ConfigEntry | ||
from homeassistant.helpers.entity import DeviceInfo | ||
from homeassistant.helpers.update_coordinator import CoordinatorEntity | ||
|
||
from .const import DOMAIN | ||
from .coordinator import NextcloudDataUpdateCoordinator | ||
|
||
|
||
class NextcloudEntity(CoordinatorEntity[NextcloudDataUpdateCoordinator]): | ||
"""Base Nextcloud entity.""" | ||
|
||
_attr_has_entity_name = True | ||
_attr_icon = "mdi:cloud" | ||
|
||
def __init__(self, coordinator: NextcloudDataUpdateCoordinator, item: str) -> None: | ||
def __init__( | ||
self, coordinator: NextcloudDataUpdateCoordinator, item: str, entry: ConfigEntry | ||
) -> None: | ||
"""Initialize the Nextcloud sensor.""" | ||
super().__init__(coordinator) | ||
self.item = item | ||
self._attr_name = item | ||
|
||
@property | ||
def unique_id(self) -> str: | ||
"""Return the unique ID for this sensor.""" | ||
return f"{self.coordinator.url}#{self.item}" | ||
self._attr_unique_id = f"{coordinator.url}#{item}" | ||
self._attr_device_info = DeviceInfo( | ||
name="Nextcloud", | ||
identifiers={(DOMAIN, entry.entry_id)}, | ||
sw_version=coordinator.data.get("nextcloud_system_version"), | ||
configuration_url=coordinator.url, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters