I have tiles on my dashboard that trigger pistons to start various Internet radio stations on my DNLA speakers via GET Requests. I’ve always wanted a media image to update in real time with the radio station logo, like so…
An extremely helpful and way too clever human helped me to finally do it, in a matter of minutes! As I hadn’t seen anyone do this with ActionTiles before, I wanted to share it.
You need a Raspberry Pi with Python and Apache2 web server installed with CGI enabled and set up to process python scripts. ActionTiles media image points to http://“RPi-address”/python/current.png with a refresh rate. Put all the images you want to use, can be both .jpg and .png, doesn’t matter, into your var/www/html/python folder. for each image create a .py file referencing said image… (with full permissions).
#!/usr/bin/python3
import cgitb
import shutil
cgitb.enable()
shutil.copyfile('Radio1.jpg', 'current.png')
print("Content-Type: text/html;charset=utf-8")
print()
print("File copied")
Which “simply” copies/overwrites the current.png file.
Now each time I change stations I send a GET Request with the image I want displayed, i.e. http://“RPi-address”/python/Radio1.py