Change Location from GPS Tracker to OWM Weather

Tags: #<Tag:0x00007f433d63ee58> #<Tag:0x00007f433d63ed68>

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');

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