OH3, LocationItems and expire binding

After an SD card failure I’ve had to upgrade in a hurry from v1 bindings to v3. After a month of pain and rewrites, most stuff is working again. However, I’ve been unable to work out how to use Groups with LocationItems and an expire binding.
As background, my partner is an avid Airbus Beluga watcher and we’re less than a mile from the Airbus factory, on the flightpath. I’m using dump1090-mutability, the HTTP binding and a ton of JSON and REGEX to pull data about Belugas nearby into OH3. I’m assigning matching GPS coordinates to one of 10 predefined LocationItems with an expire time of 30 seconds. In OH2 I was able to find out how many Belugas had valid coordinates using

Group:Number:COUNT("0,0")   gADSB_Alerts    "Airbus Belugas in range"

along with

Location Beluga1 "Beluga F-GSTA, No. 1" <airplane> (Home, gADSB_Alerts) {expire="30s,0,0"}

but this doesn’t seem to work in OH3.

The other thing I’m having trouble with is the expire binding. The idea is that while there is a Beluga transmitting a callsign nearby, the corresponding LocationItem gets updated via Rules, and automatically resets to “0,0” after a preset time. This way I was able to use

Mapview    item=Beluga1    height=15    visibility=[Beluga1 != "0,0"]
Mapview    item=Beluga2    height=15    visibility=[Beluga2 != "0,0"]

in my sitemap. But entering expire times in OH3 results in corruption of the info. I enter

update state = "0,0"

into the Metadata but when I check back the data says

update state = "0

I’ve had the same result using ‘send command’ instead of ‘update state’.

I hate asking for help, but I’ve been stuck on this for weeks.

Where on earth do you put that?

I would guess the surfeit of commas messes up here.
Try being more explicit -

Do you happen to have German language, such that 0,0 can be read as 0 point 0 decimal?

rossko57 I’m in Britain where the decimal point is used.
Adding metadata eg expire times is done in the new OH3 GUI, by looking under the items tab on the left, selecting an Item, and editing it’s Metadata on the right.

A Location item can be set by passing a string such as “52,4,100” meaning lat, long, alt. (Altitiude is optional). That’s what I’m trying to do; set the lat, long of the Beluga item to zero “0,0” after a timeout.
It used to work with my old OH2.2 setup.
Some of the .items and .sitemap parts I quoted were from my old installation and worked then. I’ve had to migrate everything from .items files to the OH3 database and this is one of the things that have changed in implementation.

The same comma-using format would apply to Color type Items, so surprised no-one has run into it before. Looks like a GUI deficiency; you might check the Item metadata in API Explorer to see if it offers clues.

A more conventional way to indicate stale data would be to set state UNDEF on expiry, which might give you a workaround.

As rossko recommends, as a temporary work around, instead of expiring to “0,0” you can expire to NULL or UNDEF. Since “0,0” essentially means it has an invalid coordinate you should be able to use either of those as a stand in instead of “0,0”. However, I don’t know if the Group COUNT will work with either. It seems like it should but I don’t know.

When you don’t supply the update state, the Expire functionality will default to NULL or UNDEF (I can’t remember which).

Also definitely check the actual saved metadata using the REST API explorer (or looking in the JSONDB directly). If it’s actually saving just “0” then try putting the value in quotes in the form. Maybe even try single quotes.

Another thing to try is to click on the code tab and see what it looks like there and adding the “0,0” directly on the code page with various types of quotes. Directly entering the value on the code tab should bypass some of the checking and changing that the UI form might be doing.

I have tried editing the code directly, but as I don’t really understand what I’m doing, or the correct and available options, it’s not easy. I’ve migrated from OH1 .items and .rules etc., to the OH3 way of doing things but the changes are terribly confusing, to me at least. Last time I did any programming was mid-1980s Z80 assembly language and ZX Basic, so I don’t really have a good grasp on the modern day basics.

Still can’t tell if it’s even supported to combine the LocationItem with an Expiry. Don’t know if it’s failing due to my error or because it just isn’t supposed to work like that.

But I’m able to do things with Openhab that I couldn’t do otherwise, so it’s all worth it in the end.

We think you should be able to ‘expire’ a Location, as you have tried. Maybe it’s a bug or some magic sleight of hand is needed.

Meantime, you got to work with what you have.
All Item types can be ‘expired’ to state UNDEF. We’re suggesting you do that, it’s the subtle difference between “this location is special and I’m going to treat it as imaginary” and “this location is just invalid”
You’d have to change your rules etc, to work with that, looking for state UNDEF e.g. sitemap
... visibility=[Beluga1 != UNDEF]

We don’t think it’s your error. We are mainly suggesting things to figure out the reason why it’s not working as expected and hopefully find a work around or gather enough evidence to post an issue. As rossko57 said, it’s supposed to work.

If you leave the “State” field blank it will expire the Item to UNDEF.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.