OpenWeatherMap Icon - use as image in rule?

I just did this myself. It isn’t super straight forward and there may be easier ways to do it if you are not running in Docker.

First of all, at least with 2.5 M1 you can link the Icon Channel to a String and that String will be the URL path to the icon. However, the icon will be a gif. So this Rule downloads it using wget, then converts it to a png so it can be used on my sitemap. Unfortunately ImageIO cannot convert to svg so you are on your own if you need that format.

Since you are just emailing the image, you can probably just keep it as a gif.

rule "Copy the conditions icon"
when
  Item vWeather_Conditions_Icon received update or
  Item Test received command
then
    // Were to save the downloaded file
    val file = "/openhab/conf/icons/classic/weather.gif"

    // Download it using wget
    executeCommandLine("/usr/bin/wget -q -O " + file + " " + vWeather_Conditions_Icon.state.toString, 5000)

    // Convert from gif to png
    val input = new File(file)
    val output = new File(file.replace("gif", "png"))
    ImageIO::write( ImageIO::read(input), "png", output)

    // Remove the gif
    executeCommandLine("rm " + file)

    // Set the icon for what ever Item is linked to the Conditions to <weather>
end