Dynamic Icons/Images using attributes

Wanted to post about dynamic images for dashboard icons - having a lot of fun with ImageMagick (and it's offshoot - graphicsmagick)
I created a rule to push values from temp sensors into variables, then write the variables out to files in File Manager.
One tricky part was getting the files off the hub - then I remembered the 15 yr old 'WGet' tool... works perfect to 'pull' files from your hub.
Then I scripted an image generation from the txt into standalone png files. next, I layered the images onto each other to create a icon. I run this script every 10 minutes using Task Scheduler. I push the result back into a folder where I store icons (and background images).
Viola. dynamic icons!

I use OpenWeather to get outdoor temp, I show the garage temp and then I use the value from Average Plus to push a larger temp on top. Since it's PNG it's see through, so background colors come through.
Here's my code for an example:
@echo on
cd\users\jshimota.e-wiz\desktop
"C:\Program Files (x86)\GnuWin32\bin\wget" http://hubitat/local/garagetemp.txt -O garagetemp.txt
"C:\Program Files (x86)\GnuWin32\bin\wget" http://hubitat/local/owmtemp.txt -O owmtemp.txt
"C:\Program Files (x86)\GnuWin32\bin\wget" http://hubitat/local/houseavgtemp.txt -O houseavgtemp.txt
magick -background transparent -fill black -font /windows/fonts/century.ttf -pointsize 48 caption:"OWM" owm.png
magick -background transparent -fill black -font /windows/fonts/century.ttf -pointsize 120 caption:@owmtemp.txt owmtemp.png
magick -background transparent -fill black -font /windows/fonts/century.ttf -pointsize 96 caption:@garagetemp.txt garagetemp.png
magick -background transparent -fill black -font /windows/fonts/century.ttf -pointsize 184 caption:@houseavgtemp.txt houseavgtemp.png
magick convert houseavgtemp.png ( -background none -gravity center -font /windows/fonts/century.ttf -pointsize 184 -fill black caption:@houseavgtemp.txt -trim +repage ) ( -clone 1 -background red -shadow 80x3+5+5 ) ( -clone 1 -clone 2 +swap -background none -layers merge +repage ) -delete 1,2 -gravity center -compose over -composite houseavgtemp.png
magick convert bg.png -background rgba(0,0,0,0) -page +0+0 housetempsv1.png -page +125+55 owm.png -page +75+90 owmtemp.png -page +586+260 garagetemp.png -page +320+400 houseavgtemp.png -flatten temperature_background.png

Run time is 1,6 seconds.
I'm having a refresh problem on the dashboard - it seems to cache the image and not reload automatically... I'll have to find the cache and set that to no-cache - no biggee...
Hope this gives others ideas!

2 Likes