Weatherforecast depending on GPS position


I am currently installimg Victron Solarsystem in my RV. The Victron equipment is monitored via Venus OS on an independant Pi and the data is send via MQTT to an other Pi running Openhab.
My goal is to use Openhab together with Grafana to have a nice overview on the Status of my solar, battery weatherforecast and sun set/rise

Now my question. Is there a possibility in openhab to get the actual weather of the currnt position of my RV? In the waether or astro binding binding I can set one position, but there is now possibility to have it dynamically depending on my current position.

Does anybody of you know away to do such a thing?

Thanks for your help!


That would take a binding that supports a GPS receiver. I do not know of such a binding.

Most of us would be concerned if our house moved. :rofl: :rofl:

1 Like

I think it can be done but it’s not going to be super easy.

  1. You would need some way to track your current location. If you have a spare old phone you could use OwnTracks to report the current lat/lon.

  2. Using the REST API Docs, query for your Astro Thing. Copy the JSON formatted String to a text file. Replace the lat/lon values with some easily findable string like $LATITUDE$ and $LONGITUDE$.

  3. When the location changes significantly, trigger a Rule.

  4. In the Rule:

    • load the JSON for your Things into a variable. var astroThing = executeCommandLine("cat /path/to/astro.thing")
    • replace the place holders with the new latitude and longitude: astroThing = astroThing.replace("$LATITUDE", triggeringItem.state.latitude).repalce("$LONGITUDE", triggeringItem.state.longitude)
    • update the Things for the Astro and what ever weather binding you are using. This can be done using OH’s REST API which you can access from Rules using sendHttp*Request or by calling curl using executeCommandLine

This will update the location used by those Things.

An alternative would be to use .things files and modify the the fields in the .things file instead using the same over all approach. Only instead of making HTTP calls you will be doing file writing.


Thanks for your response. Yes, it does not sound easy… I will have a look into it.

Getting the current position is not of an issue, I can get it via modbus from my RUT955 router.

Thanks again!


I think for Astro you would need to reinitialize the binding, to get the “daily schedule” updated with new location.
Beware that events could be missed, between significant changes of location.

Not sure if Weather would need a kick too, or would pick up new data at next scheduled call. I suspect it would.
Might be useful -

1 Like

If using the REST API to make the change would that still be the case? Do we need to restart the Astro binding when changing a Thing through PaperUI? I’ve not changed my Astro Things in years so I’ve no experience with this, but my recollection is that saving changes to the Thing (mainly applying an offset) caused the recalculation of the day’s events. But perhaps something changed along the way or I’m remembering incorrectly.

I would imagine the behavior is binding dependent.

1 Like

For Weather info I would suggest looking at the Helper Libraries for openHAB Scripted Automation and the OpenWeatherMap community sample. This dynamically generates the items so that all forecast info is available.

You would obviously need to update the Thing with the new GPS and I am also not sure if this will require a restart (this is actually my first post).

1 Like