Hi,
It’s a stupid question but… how do you set a value of a location item ?
Thanks,
Hi,
It’s a stupid question but… how do you set a value of a location item ?
Thanks,
This area of openHAB is not well documented and has a few incomplete UI bits, but here’s what you can do.
items:
String MyCarLocString
Location MyCarLoc
Number DistanceFromHome
rule:
import org.openhab.core.library.types.PointType // remove under OH2
rule MapMyCar
when
Item MyCarLocString changed
then
var PointType home = new PointType("your home's lat,long")
var PointType car = new PointType(MyCarLocString.state.toString)
MyCarLoc.postUpdate(car)
DistanceFromHome.postUpdate(car.distanceFrom(home))
end
The string format for creating a PointType
is lat,long[,alt]
(the lat and long are standard -90…90,-180…180, and the [
and ]
are not part of the string and are just to indicate to you that the third bit, altitude in meters, is optional.)
If your Location
item is a member of a Group
and you drill down into the group in the classic UI, you will get a map with a pin at the location of your car. I don’t see any evidence that this works in the Android app. Also, openHAB/ESH needs a Map
UI sitemap element to do this better (maybe it even exists but isn’t documented; I haven’t looked).
On a related note, the 1.8 version of the MQTT binding will be able to directly update Location
items without having to proxy through a String
item with a rule. Other published or in-the-works bindings may also be able to directly update Location
items, but I haven’t looked.
This worked for me in classic UI on openHAB 1.8.3, but on 2.2-SNAPSHOT I just get 0 rather then a map.
Hi,
I was wondering, is there any way to display an Item of type Location in the BasicUI (or potentially even the Android app)?
Thx,
Dries
See the Typ Conversion or the iCloud Data thread for examples. I’m on the phone right now so can’t link. Please use the search function.
The sitemap element you want to use is “Mapview”
Thanks! Got it!
Frame label="Location of xxx" {
Mapview item=mqtt_Phone_Location height=10
}
[EDIT]
Works with BasicUI on the browser, but not on the Android app.
I just discovered it does not work for Android app also.
Are there any plans to fix this? Is it possible anyway?
Same for iOS app, doesn’t work