Background image for sensor values

This request may be out there already. If it is, I’m sorry for the repetition. I have updated my sensors that show battery levels to have a green, yellow or red battery picture based on the battery level. I do this by setting the entity picture. When I do this, it blocks out the numeric level. That’s not surprising. Now I want to have my cake and eat it too. Can the entity_picture be a background picture and optionally show the text values on top of it.

This is an example of what I have right now. I would like to be able to have the percentages show on top of the battery pictures.

I don’t think it’s possible this way.

If you make it a group it will show the picture on the left with the percentage on the right.

How do you set the image? Via a template? Perhaps you could have 100 different pictures?

It should be quite easy to make using a bash loop and image magick.

Looping through numbers inside a bash script: for i in {0..100}; do echo ${i}; done

Imagemagick installation on raspberry: sudo apt-get install imagemagick
To generate text with imagemagick you use the annotate command, for details on this check http://www.imagemagick.org/Usage/annotating/

Now, putting this together we can add text and generate 11 new images for 0-10%:

for i in {0..10}; do convert MyBatteryImage.jpg -gravity center -stroke '#000C' -strokewidth 2 -annotate 0 "${i}%" -stroke none -fill white -annotate 0 "${i}%" bat_${i}.jpg; done

This will use MyBatteryImage.jpg as the source and generate the images bat_0.jpg to bat_11.jpg