How to use the location set up during intial configuration

Hello all,

first of all I’m new to openHAB. I’ve managed to get it running and setting up the first items/things/… however they are called. During the initial setup I had to enter the location for this installation.
I’ve already created an OpenWeatherMap thing for my account there. But when I’m going to create (sub)things of it, I’m always asked to enter a location but I don’t find a way to say: “Use the default location I’ve entered during set up!”
Is there any way to use this location setting?
If not - and that’s a strange thing that should be corrected/enhanced - is there any chance to create a default location that can be used for other items/things/… requiring a location?

Thanks in advance for your help!

But at this time. I don’t think binding authors have access to that, or if they do not all binding authors take advantage of it.

I know this has been asked for and worked on in the past. I don’t know what came off it though, whether there was some intractable technical issue to make it available, or is shady been made available but binding authors don’t use it yet.

In fact, there are some Bindings, which can use the location, but some other don’t, because the location is based on the coordinates, while e.g. the weather thing asks for regions or cities, and while it should be possible to get the correct region and city from the coordinates, it may vary how to set the name correctly.

OpenWeatherMap e.g. is using coordinates, they can be entered directly or by clicking through a map, that’s not a problem. And it’s probably also not a problem if the locations of various things differ by a few meters but I like consistency.
I’ve created an “House” item of type location but I don’t find a way to assign coordinates to it … :neutral_face:
And then probably the next problem will be how to use this item in things requiring coordinates?

Then maybe there is already a local Thing in the Inbox (that’s the common way for e.g. astro and ntp)

You will have to set it e.g via rule. There is afaik no way to get the system home location in an Item (yes, would be appreciated)

Make a feature request. I once had a discussion with our main UI developer he showed me how to retrieve it you can probably find it if you search old issues of openhab-webui.
But it was no general solution that would also work in rules DSL and others.
I’d request a “system” type of channel so we easily get the data into items.

Location can be requested from the serivces in the REST API:

Result looks like:

  "timezone": "Europe/Berlin",
  "variant": "POSIX",
  "language": "en",
  "location": "52.31682772120481,8.863952398300173",
  "measurementSystem": "SI",
  "region": "DE"
1 Like

Cool. :slight_smile:

But while it’s perfectly possible to get the information:

rule "get location"
    Time cron "1 2/15 * * * ?" or // read once every 15 minutes
    System started
    createTimer(now.plusSeconds(10), [|
        val header = newHashMap("Authorization" -> "Bearer <here insert the token to use>",
                                "WWW-Authenticate" -> "Basic")
        val json = sendHttpGetRequest("http://openhabian:8080/rest/services/org.openhab.i18n/config",header,5000)
        val theLocation = transform("JSONPATH","$.location",json)
        logInfo("location","Location is {}",theLocation)

it seems to be a bit… err… complex… to get a more or less static information