Bump spotifyaio to 0.8.1 (#129573)

This commit is contained in:
Joost Lekkerkerker 2024-11-01 15:12:15 +01:00 committed by Bram Kragten
parent b25ab04d2c
commit df2506bfbb
5 changed files with 35 additions and 21 deletions

View File

@ -9,6 +9,6 @@
"iot_class": "cloud_polling",
"loggers": ["spotipy"],
"quality_scale": "silver",
"requirements": ["spotifyaio==0.7.1"],
"requirements": ["spotifyaio==0.8.1"],
"zeroconf": ["_spotify-connect._tcp.local."]
}

View File

@ -3,7 +3,7 @@
from collections.abc import Callable
from dataclasses import dataclass
from spotifyaio.models import AudioFeatures
from spotifyaio.models import AudioFeatures, Key
from homeassistant.components.sensor import (
SensorDeviceClass,
@ -25,14 +25,28 @@ class SpotifyAudioFeaturesSensorEntityDescription(SensorEntityDescription):
value_fn: Callable[[AudioFeatures], float | str | None]
KEYS: dict[Key, str] = {
Key.C: "C",
Key.C_SHARP_D_FLAT: "C♯/D♭",
Key.D: "D",
Key.D_SHARP_E_FLAT: "D♯/E♭",
Key.E: "E",
Key.F: "F",
Key.F_SHARP_G_FLAT: "F♯/G♭",
Key.G: "G",
Key.G_SHARP_A_FLAT: "G♯/A♭",
Key.A: "A",
Key.A_SHARP_B_FLAT: "A♯/B♭",
Key.B: "B",
}
KEY_OPTIONS = list(KEYS.values())
def _get_key(audio_features: AudioFeatures) -> str | None:
if audio_features.key is None:
return None
key_name = audio_features.key.name
base = key_name[0]
if len(key_name) > 1:
base = f"{base}"
return base
return KEYS[audio_features.key]
AUDIO_FEATURE_SENSORS: tuple[SpotifyAudioFeaturesSensorEntityDescription, ...] = (
@ -119,7 +133,7 @@ AUDIO_FEATURE_SENSORS: tuple[SpotifyAudioFeaturesSensorEntityDescription, ...] =
key="key",
translation_key="key",
device_class=SensorDeviceClass.ENUM,
options=["C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B"],
options=KEY_OPTIONS,
value_fn=_get_key,
entity_registry_enabled_default=False,
),

View File

@ -2707,7 +2707,7 @@ speak2mary==1.4.0
speedtest-cli==2.1.3
# homeassistant.components.spotify
spotifyaio==0.7.1
spotifyaio==0.8.1
# homeassistant.components.sql
sqlparse==0.5.0

View File

@ -2159,7 +2159,7 @@ speak2mary==1.4.0
speedtest-cli==2.1.3
# homeassistant.components.spotify
spotifyaio==0.7.1
spotifyaio==0.8.1
# homeassistant.components.sql
sqlparse==0.5.0

View File

@ -207,16 +207,16 @@
'capabilities': dict({
'options': list([
'C',
'C♯',
'C♯/D♭',
'D',
'D♯',
'D♯/E♭',
'E',
'F',
'F♯',
'F♯/G♭',
'G',
'G♯',
'G♯/A♭',
'A',
'A♯',
'A♯/B♭',
'B',
]),
}),
@ -254,16 +254,16 @@
'friendly_name': 'Spotify spotify_1 Song key',
'options': list([
'C',
'C♯',
'C♯/D♭',
'D',
'D♯',
'D♯/E♭',
'E',
'F',
'F♯',
'F♯/G♭',
'G',
'G♯',
'G♯/A♭',
'A',
'A♯',
'A♯/B♭',
'B',
]),
}),
@ -272,7 +272,7 @@
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'D♯',
'state': 'D♯/E♭',
})
# ---
# name: test_entities[sensor.spotify_spotify_1_song_liveness-entry]