Change Location from GPS Tracker to OWM Weather

I want to change dynamically location of my weather depending on the coordinates from GPSTracker binding (MyOwnTracks app). I set up GPS tracer and the item that receives current coordinates from the app now I need to set up some kind of rule to read the state of the Location and write this to OH3 location? Question how to do this ???

Unless you are carrying your OH server around with you (boat, motorhome)? You might instead want to edit the location of the weather Thing, not the whole system.
Related -

Yes, it’s for the Camper so the location of the server is also changing constantly. I can retrieve the location from the GPS tracker no issues here also get this from the REST API now how to write this to OWM Weather location? using REST API and rules ???

If you’re just trying to update the location parameter of your OWM thing, you can use the following in a rule (example in javascript):

var ThingUID = Java.type('org.openhab.core.thing.ThingUID');
var Map = Java.type('java.util.HashMap');

var some_thing = things.get(new ThingUID('openweathermap:weather-and-forecast:78c6fb0b7f:local'));

var config = new Map();
config.put('location', '45.6789, -93.12345');
some_thing.getHandler().handleConfigurationUpdate(config);

The Thing will go into an ‘Unknown’ state until the next update cycle. Maybe there’s a way to force an update, haven’t looked at that.

1 Like

Just posting final solution for the GPS Own Tracks rule for the future
Set triger to your Items Update
and code ECAMScript

var ThingUID = Java.type('org.openhab.core.thing.ThingUID');
var Map = Java.type('java.util.HashMap');

var some_thing = things.get(new ThingUID('openweathermap:onecall:openweatherbridge:local'));
var new_location;
new_location = itemRegistry.getItem('GPSTracker20_Location').getState().toString();

var config = new Map();
config.put('location', new_location);
some_thing.getHandler().handleConfigurationUpdate(config);

Replace Thing UID with your THing and the same for GPS Item

Could You advice how to interact exactly this script with OH rules engine please?