Get openHabs version info in rule / script

  • Platform information:
    • Hardware: arm/4GB/16 GB
    • OS: Docker / Linux 5.10.63-v7l+
    • Java Runtime Environment: from Docker image
    • openHAB version: 3.2.0

Is there a way to get information about the current openHab version in an ECMAScript?

When OH reaches the startup complete level an ECMAScript sends me an telegram message with a short information about the startup.

Because I configured the systemctl to delete the container and the openhab/openhab:latest image when the service is stopped to force an update to the newest image when starting the container I’d like to know in which version OH is running. So my idea is to add the version and maybe other interesting information to that telegram message.

But I didn’t find any information about how to openhab information - other than from the systeminfo binding.

There version info is located in userdata/etc/version.properties. You can lead and parse that file. I’m sure there is a REST API endpoint with the version too since MainUi can show it. Look I the API Docs for that.

API request URL for that is http://pi:8080/rest/ and it returns:

{
  "version": "5",
  "locale": "en_DE",
  "measurementSystem": "SI",
  "runtimeInfo": {
    "version": "3.2.0",
    "buildString": "Release Build"
  },
  "links": [
    {
      "type": "links",
      "url": "http://pi:8080/rest/links"
    },
    {
      "type": "services",
      "url": "http://pi:8080/rest/services"
    },
    {
      "type": "auth",
      "url": "http://pi:8080/rest/auth"
    },
    {
      "type": "systeminfo",
      "url": "http://pi:8080/rest/systeminfo"
    },
    {
      "type": "uuid",
      "url": "http://pi:8080/rest/uuid"
    },
    {
      "type": "events",
      "url": "http://pi:8080/rest/events"
    },
    {
      "type": "discovery",
      "url": "http://pi:8080/rest/discovery"
    },
    {
      "type": "ui",
      "url": "http://pi:8080/rest/ui"
    },
    {
      "type": "config-descriptions",
      "url": "http://pi:8080/rest/config-descriptions"
    },
    {
      "type": "things",
      "url": "http://pi:8080/rest/things"
    },
    {
      "type": "audio",
      "url": "http://pi:8080/rest/audio"
    },
    {
      "type": "iconsets",
      "url": "http://pi:8080/rest/iconsets"
    },
    {
      "type": "thing-types",
      "url": "http://pi:8080/rest/thing-types"
    },
    {
      "type": "sitemaps",
      "url": "http://pi:8080/rest/sitemaps"
    },
    {
      "type": "voice",
      "url": "http://pi:8080/rest/voice"
    },
    {
      "type": "habpanel",
      "url": "http://pi:8080/rest/habpanel"
    },
    {
      "type": "profile-types",
      "url": "http://pi:8080/rest/profile-types"
    },
    {
      "type": "channel-types",
      "url": "http://pi:8080/rest/channel-types"
    },
    {
      "type": "addons",
      "url": "http://pi:8080/rest/addons"
    },
    {
      "type": "rules",
      "url": "http://pi:8080/rest/rules"
    },
    {
      "type": "persistence",
      "url": "http://pi:8080/rest/persistence"
    },
    {
      "type": "bindings",
      "url": "http://pi:8080/rest/bindings"
    },
    {
      "type": "module-types",
      "url": "http://pi:8080/rest/module-types"
    },
    {
      "type": "templates",
      "url": "http://pi:8080/rest/templates"
    },
    {
      "type": "spec",
      "url": "http://pi:8080/rest/spec"
    },
    {
      "type": "inbox",
      "url": "http://pi:8080/rest/inbox"
    },
    {
      "type": "items",
      "url": "http://pi:8080/rest/items"
    }
  ]
}
1 Like