Skip to content

Commit 4da93f6

Browse files
authored
Bump spotifyaio to 0.8.1 (#129573)
1 parent 5ed7d32 commit 4da93f6

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

homeassistant/components/spotify/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"iot_class": "cloud_polling",
1010
"loggers": ["spotipy"],
1111
"quality_scale": "silver",
12-
"requirements": ["spotifyaio==0.7.1"],
12+
"requirements": ["spotifyaio==0.8.1"],
1313
"zeroconf": ["_spotify-connect._tcp.local."]
1414
}

homeassistant/components/spotify/sensor.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections.abc import Callable
44
from dataclasses import dataclass
55

6-
from spotifyaio.models import AudioFeatures
6+
from spotifyaio.models import AudioFeatures, Key
77

88
from homeassistant.components.sensor import (
99
SensorDeviceClass,
@@ -25,14 +25,28 @@ class SpotifyAudioFeaturesSensorEntityDescription(SensorEntityDescription):
2525
value_fn: Callable[[AudioFeatures], float | str | None]
2626

2727

28+
KEYS: dict[Key, str] = {
29+
Key.C: "C",
30+
Key.C_SHARP_D_FLAT: "C♯/D♭",
31+
Key.D: "D",
32+
Key.D_SHARP_E_FLAT: "D♯/E♭",
33+
Key.E: "E",
34+
Key.F: "F",
35+
Key.F_SHARP_G_FLAT: "F♯/G♭",
36+
Key.G: "G",
37+
Key.G_SHARP_A_FLAT: "G♯/A♭",
38+
Key.A: "A",
39+
Key.A_SHARP_B_FLAT: "A♯/B♭",
40+
Key.B: "B",
41+
}
42+
43+
KEY_OPTIONS = list(KEYS.values())
44+
45+
2846
def _get_key(audio_features: AudioFeatures) -> str | None:
2947
if audio_features.key is None:
3048
return None
31-
key_name = audio_features.key.name
32-
base = key_name[0]
33-
if len(key_name) > 1:
34-
base = f"{base}♯"
35-
return base
49+
return KEYS[audio_features.key]
3650

3751

3852
AUDIO_FEATURE_SENSORS: tuple[SpotifyAudioFeaturesSensorEntityDescription, ...] = (
@@ -119,7 +133,7 @@ def _get_key(audio_features: AudioFeatures) -> str | None:
119133
key="key",
120134
translation_key="key",
121135
device_class=SensorDeviceClass.ENUM,
122-
options=["C", "C♯", "D", "D♯", "E", "F", "F♯", "G", "G♯", "A", "A♯", "B"],
136+
options=KEY_OPTIONS,
123137
value_fn=_get_key,
124138
entity_registry_enabled_default=False,
125139
),

requirements_all.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2710,7 +2710,7 @@ speak2mary==1.4.0
27102710
speedtest-cli==2.1.3
27112711

27122712
# homeassistant.components.spotify
2713-
spotifyaio==0.7.1
2713+
spotifyaio==0.8.1
27142714

27152715
# homeassistant.components.sql
27162716
sqlparse==0.5.0

requirements_test_all.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,7 @@ speak2mary==1.4.0
21622162
speedtest-cli==2.1.3
21632163

21642164
# homeassistant.components.spotify
2165-
spotifyaio==0.7.1
2165+
spotifyaio==0.8.1
21662166

21672167
# homeassistant.components.sql
21682168
sqlparse==0.5.0

tests/components/spotify/snapshots/test_sensor.ambr

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,16 @@
207207
'capabilities': dict({
208208
'options': list([
209209
'C',
210-
'C♯',
210+
'C♯/D♭',
211211
'D',
212-
'D♯',
212+
'D♯/E♭',
213213
'E',
214214
'F',
215-
'F♯',
215+
'F♯/G♭',
216216
'G',
217-
'G♯',
217+
'G♯/A♭',
218218
'A',
219-
'A♯',
219+
'A♯/B♭',
220220
'B',
221221
]),
222222
}),
@@ -254,16 +254,16 @@
254254
'friendly_name': 'Spotify spotify_1 Song key',
255255
'options': list([
256256
'C',
257-
'C♯',
257+
'C♯/D♭',
258258
'D',
259-
'D♯',
259+
'D♯/E♭',
260260
'E',
261261
'F',
262-
'F♯',
262+
'F♯/G♭',
263263
'G',
264-
'G♯',
264+
'G♯/A♭',
265265
'A',
266-
'A♯',
266+
'A♯/B♭',
267267
'B',
268268
]),
269269
}),
@@ -272,7 +272,7 @@
272272
'last_changed': <ANY>,
273273
'last_reported': <ANY>,
274274
'last_updated': <ANY>,
275-
'state': 'D♯',
275+
'state': 'D♯/E♭',
276276
})
277277
# ---
278278
# name: test_entities[sensor.spotify_spotify_1_song_liveness-entry]

0 commit comments

Comments
 (0)