mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Upgrade discogs_client to 2.3.0 (#39164)
* Upgrade discogs_client to 2.3.0 * Fix pylint issue
This commit is contained in:
parent
f757e258a7
commit
7874711936
@ -2,6 +2,6 @@
|
|||||||
"domain": "discogs",
|
"domain": "discogs",
|
||||||
"name": "Discogs",
|
"name": "Discogs",
|
||||||
"documentation": "https://www.home-assistant.io/integrations/discogs",
|
"documentation": "https://www.home-assistant.io/integrations/discogs",
|
||||||
"requirements": ["discogs_client==2.2.2"],
|
"requirements": ["discogs_client==2.3.0"],
|
||||||
"codeowners": ["@thibmaek"]
|
"codeowners": ["@thibmaek"]
|
||||||
}
|
}
|
||||||
|
@ -122,22 +122,22 @@ class DiscogsSensor(Entity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
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:
|
if self._state is None or self._attrs is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if self._type != SENSOR_RANDOM_RECORD_TYPE:
|
if self._type == SENSOR_RANDOM_RECORD_TYPE and self._state is not None:
|
||||||
return {
|
return {
|
||||||
|
"cat_no": self._attrs["labels"][0]["catno"],
|
||||||
|
"cover_image": self._attrs["cover_image"],
|
||||||
|
"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_ATTRIBUTION: ATTRIBUTION,
|
||||||
ATTR_IDENTITY: self._discogs_data["user"],
|
ATTR_IDENTITY: self._discogs_data["user"],
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"cat_no": self._attrs["labels"][0]["catno"],
|
|
||||||
"cover_image": self._attrs["cover_image"],
|
|
||||||
"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_ATTRIBUTION: ATTRIBUTION,
|
||||||
ATTR_IDENTITY: self._discogs_data["user"],
|
ATTR_IDENTITY: self._discogs_data["user"],
|
||||||
}
|
}
|
||||||
@ -146,11 +146,14 @@ class DiscogsSensor(Entity):
|
|||||||
"""Get a random record suggestion from the user's collection."""
|
"""Get a random record suggestion from the user's collection."""
|
||||||
# Index 0 in the folders is the 'All' folder
|
# Index 0 in the folders is the 'All' folder
|
||||||
collection = self._discogs_data["folders"][0]
|
collection = self._discogs_data["folders"][0]
|
||||||
random_index = random.randrange(collection.count)
|
if collection.count > 0:
|
||||||
random_record = collection.releases[random_index].release
|
random_index = random.randrange(collection.count)
|
||||||
|
random_record = collection.releases[random_index].release
|
||||||
|
|
||||||
self._attrs = random_record.data
|
self._attrs = random_record.data
|
||||||
return f"{random_record.data['artists'][0]['name']} - {random_record.data['title']}"
|
return f"{random_record.data['artists'][0]['name']} - {random_record.data['title']}"
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Set state to the amount of records in user's collection."""
|
"""Set state to the amount of records in user's collection."""
|
||||||
|
@ -485,7 +485,7 @@ devolo-home-control-api==0.13.0
|
|||||||
directv==0.3.0
|
directv==0.3.0
|
||||||
|
|
||||||
# homeassistant.components.discogs
|
# homeassistant.components.discogs
|
||||||
discogs_client==2.2.2
|
discogs_client==2.3.0
|
||||||
|
|
||||||
# homeassistant.components.discord
|
# homeassistant.components.discord
|
||||||
discord.py==1.4.1
|
discord.py==1.4.1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user