openhab / openhab-core

Core framework of openHAB
https://www.openhab.org/
Eclipse Public License 2.0
885 stars 413 forks source link

[Persistence] Provide a way to exclude Items in .persist file (and UI when that gets merged) #3665

Open rkoshak opened 11 months ago

rkoshak commented 11 months ago

Periodically I'll see on the forum someone asking if there is a way to configure something like. "every Item except these" in their persistence config.

For example, a user may have 100 Items and they want to apply a default strategy to all but two of them. Today the only way to exclude those two Items is to configure the other 98 Items in the .persist file instead of creating a config for just those two.

I do not know what it takes to modify the syntax grammars (I understand it can be challenging) so I hesitate to recommend a syntax. But maybe it could be something as simple as prepending Item names with a ! to mean "not this Item".

Items {
    *, !Item1, !Item2 : strategy = everyChange // every Item but Item1 and Item2
    *,!DoNotPersist* : strategy = everyMinute // every Item but members of DoNotPersist
}

Your Environment

runtimeInfo:
  version: 4.0.0
  buildString: "Build #3500"
locale: en-US
systemInfo:
  configFolder: /openhab/conf
  userdataFolder: /openhab/userdata
  logFolder: /openhab/userdata/logs
  javaVersion: 17.0.7
  javaVendor: Eclipse Adoptium
  javaVendorVersion: Temurin-17.0.7+7
  osName: Linux
  osVersion: 5.15.0-75-generic
  osArchitecture: amd64
  availableProcessors: 4
  freeMemory: 318185456
  totalMemory: 754974720
  startLevel: 70
bindings: null
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: true
    windows: false
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: macos
    pixelRatio: 2
    prefersColorScheme: light
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 12
    language: en-US
    languages:
      - en-US
      - en
    onLine: true
    platform: MacIntel
  screen:
    width: 1920
    height: 1080
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: light
    filled: true
    pageTransitionAnimation: default
    bars: filled
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36
    (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
timestamp: 2023-06-19T16:21:54.143Z
clinique commented 1 month ago

I was considering to open exactly the same issue. By chance, I had the reflex to take a look wether it would already exist :-)

My approach would rather have been:

Vetoed {
    Item1, Item2, DoNotPersist*
}

excluding these items and item contained in group from all stategies