Automate changing an ActionTiles media image with a GET Request from WebCoRE


#1

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


#2

I admit, I am a bit surprised that ActionTiles can display a JPEG that has a PNG extension…
(but hey, if it works, don’t fix it, LOL)


#3

You’re right, and it wouldn’t of been any drama sticking to one file type for images. But I guess when you do maverick, out-of-the-box thinking, you get pleasant surprises. :wink:


#4

*brushes a speck of imaginary lint off of his lapel*