New openhab-cli to use OH from CLI

if this is wrong place to put it please move it to proper place

openhab-cli

Gradle check
Latest release

openhab-cli is a command-line client for the openHAB REST API. It provides the oh command for inspecting and managing an openHAB installation from a terminal, a script, or an AI coding agent.

The command tree follows the openHAB API. It covers items, things, rules, add-ons, persistence, services, sitemaps, voice, and the other endpoints exposed by the bundled OpenAPI specification.

Installation

Download the latest build from GitHub Releases. Each release contains:

  • a Linux x86-64 executable;
  • a Windows x86-64 executable; and
  • a runnable JAR for other platforms. The JAR requires Java 21 or newer.

Rename the native executable to oh (oh.exe on Windows) and place it in a directory on your PATH. On Linux, make it executable first:

chmod +x oh-<version>-linux-x86_64
sudo mv oh-<version>-linux-x86_64 /usr/local/bin/oh

Run the JAR directly with:

java -jar oh-<version>.jar

Initial setup

Save the URL of your openHAB server:

oh _config server set https://openhab.example.com

Next, save an OAuth token. Omitting its value opens an interactive prompt, which keeps the token out of your shell history:

oh _config account login --oauth-token

Username and password authentication is also supported:

oh _config account login --username --password

Token authentication is recommended. To use a username and password, enable Basic Authentication in Main UI → Settings → API Security on the openHAB server.

The default configuration file is ~/.oh/oh-cli.properties. Pass --properties-file to a configuration command to use another file.

Usage

Run oh to list the available command groups:

oh

Append --help at any level of the command tree to inspect its commands and options:

oh items --help
oh items itemByName --help

For example, list every item:

oh items items

Retrieve one item by name:

oh items itemByName KitchenLight

Enum values are case-insensitive. JSON output is pretty-printed by default; use --no-pretty-print when compact output is more convenient for a script.

This looks really useful, thanks for sharing!

One remark though:
I’d suggest to change the package name used inside your CLI from org.openhab to something else (e.g. io.github.magx2.openhab).

From the trademark policy:

  1. Only the openHAB project is authorized to develop or maintain software packages that use openHAB namespaces such as ‘org.openhab’ in their namespace. This naming convention is used to identify code that has been developed as part of the openHAB project.

And not to be picky, but there already is an openhab-cli tool that comes with apt/dnf installed openHAB instances. Of course that tool does something completely different. But I worry about confusion caused by there being two completely different tools with the same name.

I like idea a whole lot! Thanks for posting it!