Upgrade discogs_client to 2.3.0 (#39164)

* Upgrade discogs_client to 2.3.0

* Fix pylint issue
This commit is contained in:
Fabian Affolter 2020-08-23 18:41:11 +02:00 committed by GitHub
parent f757e258a7
commit 7874711936
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

View File

@ -2,6 +2,6 @@
"domain": "discogs",
"name": "Discogs",
"documentation": "https://www.home-assistant.io/integrations/discogs",
"requirements": ["discogs_client==2.2.2"],
"requirements": ["discogs_client==2.3.0"],
"codeowners": ["@thibmaek"]
}

View File

@ -122,16 +122,11 @@ class DiscogsSensor(Entity):
@property
def device_state_attributes(self):
"""Return the state attributes of the sensor."""
"""Return the device state attributes of the sensor."""
if self._state is None or self._attrs is None:
return None
if self._type != SENSOR_RANDOM_RECORD_TYPE:
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_IDENTITY: self._discogs_data["user"],
}
if self._type == SENSOR_RANDOM_RECORD_TYPE and self._state is not None:
return {
"cat_no": self._attrs["labels"][0]["catno"],
"cover_image": self._attrs["cover_image"],
@ -142,16 +137,24 @@ class DiscogsSensor(Entity):
ATTR_IDENTITY: self._discogs_data["user"],
}
return {
ATTR_ATTRIBUTION: ATTRIBUTION,
ATTR_IDENTITY: self._discogs_data["user"],
}
def get_random_record(self):
"""Get a random record suggestion from the user's collection."""
# Index 0 in the folders is the 'All' folder
collection = self._discogs_data["folders"][0]
if collection.count > 0:
random_index = random.randrange(collection.count)
random_record = collection.releases[random_index].release
self._attrs = random_record.data
return f"{random_record.data['artists'][0]['name']} - {random_record.data['title']}"
return None
def update(self):
"""Set state to the amount of records in user's collection."""
if self._type == SENSOR_COLLECTION_TYPE:

View File

@ -485,7 +485,7 @@ devolo-home-control-api==0.13.0
directv==0.3.0
# homeassistant.components.discogs
discogs_client==2.2.2
discogs_client==2.3.0
# homeassistant.components.discord
discord.py==1.4.1