Connection from docu to UI-Setup

  • Platform information:
    • Hardware: ARM
    • OS: Linux
    • Java Runtime Environment: Openjdk Zulu 17.0.9
    • openHAB version: 4.0.4
  • Issue of the topic: I have been working with Openhab since a while now but still can’t figure out how to connect from the documentation to how I configure it in the UI: As examples in the documentation of bindings they always talk about how it has to look in the demo.things-file, but as it is recommended for OH4 I only configure inside the UI in Settings->Things where I would for example see the channels or get access to the Code in YAML. Why is there no documentation instead of how the demo.things-file should look like but how the Code should look like in YAML? What am I missing here?

My recent example:
To connect to my APSolar inverter I installed the http-binding. The Inverter responds with a GET to http://<inverter’s IP>:8050/getOutputData with

{
	"data": {
		"p1": 5,
		"e1": 0.23740,
		"te1": 9.96658,
		"p2": 7,
		"e2": 0.24420,
		"te2": 10.09439
	},
	"message": "SUCCESS",
	"deviceId": "E07000027183"
}

No I tried to setup a Thing like

UID: http:url:0ef228b5b1
label: APSolar GetOutputData
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: <inverter's IP>:8050
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  timeout: 3000
  bufferSize: 2048
channels:
  - id: Solar
    channelTypeUID: http:number
    label: Number
    description: null
    configuration:
      mode: READONLY
      stateExtension: /getOutputData
      stateTransformation: JSONPATH:$.data.e1

This was accomplished by copying from a youtube video screen, but I do not get how the documentation like

Thing http:url:foo "Foo" [
    baseURL="https://example.com/api/v1/metadata-api/web/metadata",
    headers="key1=value1", "key2=value2", "key3=value3",
    refresh=15] {
        Channels:
         Type string : text "Text" [ stateTransformation="JSONPATH:$.metadata.data" ]
}

can be transferred to this…
Sidenote: my Thing appears online, but I get “NULL” as a value for it in the model…

Only rarely should you need to mess with the YAML of a managed Thing in the first place. If you are using the UI to configure Things, use the UI forms.

Over all the syntax for . things files is covered in the Things page under Configuration. The specific properties used by a specific binding will be documented in the binding’s docs. The parameters have the same name between the. this files and the YAML representation you’ll see in the code tab on Thing’s page in MainUI.

But if you are trying to configure a managed Thing like that, you should use the form in MainUI. Then reach field is described and you don’t need to know the names of the properties or structure of the config.

Be sure to go through the Getting Started Tutorial Advanced Things page for the overall approach.