noel1983 wrote:Now that’s a script and a half!! Nice!!
Ha thanks, it's actually not that bad - and to be honest, with Domopad now I could probably skip most of this and just embed the widget as a live control page.
As it stands today there are two files that I created, a bit convoluted and I could probably trim this down a good bit, but it works soooooo...
It relies on a beautiful little command line tool called webkit2png, that as the name suggests, converts a webpage to a png image. It's not on the mac by default so you'll have to install it using homebrew. Assuming you have loaded homebrew on your Indigo server, run this to install webkit2png
- Code: Select all
brew install webkit2png
As I mentioned earlier, Darksky makes available several nice widgets that you can embed on your personal webpage:
https://darksky.net/widgetsThis particular widget is no longer listed on the above page, but it still works, here is a blog post referencing the one I use:
https://blog.darksky.net/forecast-embeds/Because I wanted the webpage that will be converted to an image to be a specific size, rather than point webkit2png directly at the widget URL, I created a local HTML file to size everything as I wanted:
- Code: Select all
<!DOCTYPE html>
<html>
<head>
<style>
#timeline {
width: 800px;
height: 210px;
background-color:transparent;
border: 0px none;
margin-top: -50px;
margin-left: -24px;
}
</style>
</head>
<body>
<iframe id="timeline" src="https://forecast.io/embed/#lat=33.39&lon=-86.71" scrolling="no" frameborder="0" ></iframe>
<script type="text/javascript">
</script>
</body>
</html>
I named that HTML file "forecast.html" and I made sure that it worked like I wanted by opening it in Safari. When I was happy with it put it in my Indigo scripts folder along with the following shell script:
- Code: Select all
!/bin/sh
/usr/local/bin/webkit2png -F /Library/Application\ Support/Perceptive\ Automation/Scripts/forecast.html --transparent -D /Library/Application\ Support/Perceptive\ Automation/Indigo\ 7/IndigoWebServer/static/ -o forecast --delay=3
All that script does is call webkit2png with my local webpage as an input, it creates the image and places it in the proper directory for the control page to fetch as a refreshing image. I use --delay=3 to make webkit2png wait 3 seconds to give the page time to render the webpage fully before creating the image. likewise the --transparent option created the PNG with a transparent background.
Once you can run that command from the terminal and successfully create images, it's just a matter of creating a schedule in Indigo to run the command at whatever interval you want, and then of course designing the control pages, which is the really hard part for me...
Terry