OH3 MQTT via script

Hello again,
since I set up my new pi4 with OH3 a couple of weeks are gone. But now I want to migrate step by step from OH2.5. From the begining I decidet to set up and cofigure a much as possible per script. I had some success with homeatic devices. Now I want to move on with the MQTT. I would be happy if anybody could point me how to set up the Broker and the attached things in the THING-file. Binding and jasonpath transformation is allready installed.
Many thanks in advance

Don’t know your starting point.

Oh great and many thanks for the fast reply. I will try that out.

// MQTT Things
Bridge mqtt:broker:Broker1 [host="IP.of.my.PI4.running.OH3", secure=false ]{

    Thing MQTTExamples Solar-Inverter-Phase-1 { // "MQTTExamples" is the topic name the solar inverter is transmiting on and "Solar-Inverter-Phase-1" is the CLIENTID

            Type number : pvpower "PV-Leistung" [ stateTopic="MQTTExamples", commandTopic="" ]

This is what i tried but it say "Communication error - connection refused
I’m confused

What’s confusing? openHAB cannot connect to your broker. You need to check your broker installation, does it allow connections without password? You need to check your OH Thing, have you provided the correct path?

Do I need to install a broker via the web UI of OH3? I thougt this can be done per script like it is possibel for the homematic bridge

Edit: Ok I see what I misunderstood. But would you propose a external borker like mosquito or the internal OH3 broker?

OH3 does not have an internal MQTT broker - install Mosquito.

Ok I installed the mosquito. My Broker occurs now as thing and is online, but the channel not. I think there is some confusion in my synthax.

Yes. Are you going to fix it? As in the examples you have already looked at, your topic Thing needs to given a type, topic

This should be:

Thing topic solar-inverter-phase-1

It literally needs to say Thing topic. topic is not a placeholder.

Ok many thanks for your help. I will try.

So I found some time for testing. Now It shows a Thing “Solar Inverter 1” in the web UI. But it contains no channel.
Here is my code:

// MQTT Things
Bridge mqtt:broker:Broker1 [host="", secure=false ]{

    Thing mqtt:topic:SolarInverter1 "Solar Inverter 1" (mqtt:broker:Broker1) { // "MQTTExamples" is the topic name the solar inverter is transmiting on and "Solar-Inverter-Phase-1" is the CLIENTID

            Type number : text "PV-Leistung" [ stateTopic="MQTTExamples", commandTopic="" ]

Is there an syntax error in the channel configuration?

The part inside the parentheses below is only needed when you are putting the Thing definition outside of the Broker definition. Because you’re putting your Thing inside your Broker, you can (Should?) remove it, although having it there shouldn’t be a problem.

Thing mqtt:topic:SolarInverter1 "Solar Inverter 1" (mqtt:broker:Broker1) 

The rest seems OK to me in terms of syntax. I even tried it on my system and I can see a channel in the thing.