Hi, just wanna share a little project I did a few days ago.
See it in action:
Spent a few hours last weekend on my new Lovelace dashboard template. There’s nothing special about it, just the usual sidebar + button design, but I was having a hard time finding a media player card I want to use, so I end up making one myself.
My original concept was to have a vinyl record or CD image on the edge of the dashboard mimicking the real thing, with the album cover artwork in the center. I am no expert in coding so the goal was to achieve the above using just existing Lovelace cards and tools/methods provided by the Home Assistant package.
I broke down the problem into smaller problems:
-
Test and see if CSS animation is possible.
-
Link the animation with an entity state change.
-
Extract the artwork image from the media player.
-
Wrap up and add control elements.
And I did the following:
-
I use card-mod (https://github.com/thomasloven/lovelace-card-mod) to enable CSS support on Lovelace cards. The CSS animation works without any issue, one problem solved.
-
I use a template with the is_state() function to check the media player’s “playing” state, if validated true, it then injects the CSS animation code to start the animation.
-
With the Developer Tools, I was able to find the property holding the link to the cached artwork image (entity_picture). But for some reasons I can’t use that link directly in a Picture card, so I end up using the Markdown card and display the image using the HTML “img” tag. The artwork is rectangular so I use the CSS clip-path to create a masked round version and then place it on top of the vinyl image (which is wrapped in a Picture card, with transparent background) using the CSS z-index property.
-
With all the major problems solved, I overlaid a simplified media control UI on top of the image layers and this is the final result.
There are still a lot of improvements that can be done, but I hope you enjoyed my little project.
If you need more details on this project, please visit the project page.