Store value in persistent/global variable

Is there a way to store a value in a variable that would persist while a device is on? I have a rule that each time it runs, I’d like to get and set a persistent variable. I’ve tried creating a custom item, but when I try to reference it, I get “The method or field prevVolume is undefined;” Is there another way to accomplish this?

We needs lots more details.

Rule written how? What language? Created the Item how? How are you trying to reference the Item?

I have one example: ‘home’ / ‘work’ / etc., locations.

Say I want to have rules that trigger based on distance from a Location item to a certain point. I want those points’ coordinates to be defined somewhere in OpenHAB.

There is an Item of type Location that stores a lat/lon value and has methods for measuring distance between Locations. Initialize it and set it to restoreOnStartup.

1 Like