Skip to content

Weather Forecast in openHAB based on OpenWeatherMap, using Ansible

After setting up OpenWeatherMap in openHAB, I had another project on my list: send a forecast for the next day.

That is rather easy to do with a Cron rule.



The rule is easy, it just combined a number of Items as text, and sends it to me, us. In this case it's Telegram, but that is a different story.

rule "Weather forecast for tomorrow"
    Time cron "0 30 17   ?"
    var weather_forecast = "Weather tomorrow 6am: " + String::format("%1$1d", (homef12Temperature.state as Number).intValue) + " °C"
    weather_forecast = weather_forecast + ", Humidity: " + homef12Humidity.state.toString
    weather_forecast = weather_forecast + ", Cloudiness: " + homef12Cloudiness.state.toString
    weather_forecast = weather_forecast + ", " + homef12Condition.state.toString

    var rain_value = homef12RainVolume.state.toString.split(' ').get(0)
    var rain_value_rounded = Math::round(Float::parseFloat(rain_value))
    var rain_unit = homef12RainVolume.state.toString.split(' ').get(1)

    if (rain_value_rounded > 0) {
        weather_forecast = weather_forecast + ", Rain: " + rain_value_rounded.toString + " " + rain_unit

    var snow_value = homef012SnowVolume.state.toString.split(' ').get(0)
    var snow_value_rounded = Math::round(Float::parseFloat(snow_value))
    var snow_unit = homef012SnowVolume.state.toString.split(' ').get(1)

    if (snow_value_rounded > 0) {
        weather_forecast = weather_forecast + ", Snow: " + snow_value_rounded.toString + " " + snow_unit

    logInfo("Weather forecast", weather_forecast)
    // send notification with the content of $weather_forecast

This rule is fired at 17:30 in the afternoon, uses the weather forecast data for 12 hours in the future, and creates a string which can be send using your favorite method.


ads' corner on : Install OpenWeatherMap in openHAB, using Ansible

Show preview
Next item on my home automation todo list: weather, and forecast. No good system without that data! After exploring the options which openHAB supports, I settled for OpenWeatherMap. Note: you need an account with OWM, the basic functionality is fr Comments ()


Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options