Custom component for Home Assistant to fetch song lyrics from Genius by tracking media player entities. Component allows service calls for custom automations.
- Open HACS Settings and add this repository (https://github.com/robert-alfaro/netease-lyrics) as a Custom Repository (use Integration as the category).
- The
Netease Lyrics
page should automatically load (or find it in the HACS Store). - Click
Install
Copy the netease_lyrics
directory from custom_components
in this repository, and place inside your
Home Assistant installation's custom_components
directory.
- Create a Genius.com access token:
- Sign up for a free account at genius.com if you don't have one.
- Open the New API Client page and fill in App Name, App Website URL, and Redirect URL (this won't be used).
- Once you've saved the new client, click the button to generate a
Client Access Token
(record this somewhere safe).
- Install this integration
- Enable Netease Lyrics in
configuration.yaml
by adding the following (substitute your access token from step 1):
NOTE: Media player foobar
is just an example. Replace it with your media player's entity name.
netease_lyrics:
access_token: "3SxSxqZJOtz5fYlkFXv-12E-mgripD0XM7v0L091P3Kz22wT9ReCRNg0qmrYeveG"
entities:
- media_player.foobar
The above configuration will create a sensor entity sensor.foobar_lyrics
.
-
Create markdown card in lovelace:
type: vertical-stack cards: - type: media-control entity: media_player.foobar - type: conditional conditions: - entity: sensor.foobar_lyrics state: 'on' card: type: markdown content: >- ## {{ states.sensor.foobar_lyrics.attributes.media_artist }} - {{ states.sensor.foobar_lyrics.attributes.media_title }} {{ states.sensor.foobar_lyrics.attributes.media_lyrics }}
The above lovelace card groups the media player and lyrics sensor together. The conditional portion will hide the lyrics sensor when the media player is off.
{
"media_artist":"Protoje",
"media_title":"Mind of a King",
"entity_id":"sensor.foobar_lyrics"
}
media_artist: "Protoje"
media_title: "Mind of a King"
entity_id: sensor.foobar_lyrics
Thanks to
- @johnwmillr for
lyricsgenius
python package!