Move attribution to standalone attribute [c-d] (#80150)

This commit is contained in:
epenet 2022-10-12 11:38:43 +02:00 committed by GitHub
parent 237b03150e
commit e9e3fb1cc8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 20 additions and 45 deletions

View file

@ -13,12 +13,7 @@ from homeassistant.components.sensor import (
SensorEntity,
SensorEntityDescription,
)
from homeassistant.const import (
ATTR_ATTRIBUTION,
CONF_MONITORED_CONDITIONS,
CONF_NAME,
CONF_TOKEN,
)
from homeassistant.const import CONF_MONITORED_CONDITIONS, CONF_NAME, CONF_TOKEN
from homeassistant.core import HomeAssistant
from homeassistant.helpers.aiohttp_client import SERVER_SOFTWARE
import homeassistant.helpers.config_validation as cv
@ -29,8 +24,6 @@ _LOGGER = logging.getLogger(__name__)
ATTR_IDENTITY = "identity"
ATTRIBUTION = "Data provided by Discogs"
DEFAULT_NAME = "Discogs"
ICON_RECORD = "mdi:album"
@ -111,6 +104,8 @@ def setup_platform(
class DiscogsSensor(SensorEntity):
"""Create a new Discogs sensor for a specific type."""
_attr_attribution = "Data provided by Discogs"
def __init__(self, discogs_data, name, description: SensorEntityDescription):
"""Initialize the Discogs sensor."""
self.entity_description = description
@ -135,12 +130,10 @@ class DiscogsSensor(SensorEntity):
"format": f"{self._attrs['formats'][0]['name']} ({self._attrs['formats'][0]['descriptions'][0]})",
"label": self._attrs["labels"][0]["name"],
"released": self._attrs["year"],
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_IDENTITY: self._discogs_data["user"],
}
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_IDENTITY: self._discogs_data["user"],
}