Communication between openwb and openhab via MQTT - how to set it up?

Hello,

I’m quite new to openhab/raspi/linux and run openhab3 and openWB (Software for Wallboxes) on two separate Raspis since a few days. They’re supposed to communicate via MQTT with each other.

I installed Mosquitto via the openhab config/setup-tool, the binding/broker and a thing (channel/string to show text). Then I tested the connection with MQTT.fx with success. If I enter a text in MQTT and publish it, it’s shown in openhab.

My problem is that I don’t know how to get the data from openWB to Mosquitto. It’s supposed to be quite simple. I “only” need to (correctly) fill out the data (see screenshot which might clarify things)


I could imagine that these are the sources of my problems:

  • wrong prefix: What’s this about? So that openWB can find the mqtt-database? If so, what to enter (I don’t know where it is on my raspi)

  • TLS: I have to enter something in openWB. But when I activate it in MQTT.fx, it doesn’t work.

However, possibly this is not relevant; maybe openWB finds the database through the ip-address and/or changes the TLS settings itself? I have no idea … But if so, how can I access the data in openhab? →

  • the subscription codes for openWB are listed here: MQTT - openWB Forum in my test I used the one for “house consumption”: openWB/global/WHouseConsumption 4368
  • This is the thing-channel-code I created, maybe there’s a mistake here?:

UID: mqtt:topic:69a880d8e1:87a18698a6
label: openWB
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:69a880d8e1
channels:
-id: Hausverbrauch
channelTypeUID: mqtt:number
label: Hausverbrauch
description: “”
configuration:
stateTopic: pfx/openWB/global/WHouseConsumption 4368

Furthermore, here’s (OpenWB mit MQTT in OpenHAB - openWB Forum) a thread which addresses the connection between openWB and openhab. But it focuses on openhab and not on what to do to get the data into mqtt.

Although this might be considered more a mqtt or openWB question, maybe someone can tell me how to solve the issue?

Given that openHAB works and openwb doesn’t, and I suspect there are very very few, if any, users on this forum who have even heard of openwb, you will probably have better luck asking on an openwb forum.

Hi Rich,
thanks for your quick reply. I agree with you but it’s also got to do with mqtt and maybe someone

  • has an idea what is meant with the “prefix”
  • or knows where the mosquitto -database is (so I can try that path)
  • or knows about the TLS-part.
    But I’m not very optimistic either …

What ever is meant by “prefix” is defined by openwb. MQTT itself has no concept of a “prefix”. Perhaps it is the first part of a topic structure.

There is nothing in the mosquitto database that you need to be concerned about. It’s an internal thing that mosquitto uses when configured to to maintain retained messages and QOS 1 and QOS 2 messages that haven’t been delivered.

First welcome to the fun.

I don’t speak or read German so I can’t give specific example.

First for now forget about openHAB.

Can you connect your openwb and mqtt fx to your Mosquitto Broker?

The prefix on your openwb is probably just a friendly name to give your WB device. Change it to something that means something to you like. bedroom/

Now in MQTT FX subscribe to # to show you all the messages on the broker. I use http://mqtt-explorer.com/ but you can use any client you like.

Then control some stuff on your wall box to see if you are getting messages on the broker. You will probably on see state topics and not command ones.

Now you should be able to control the openwb using the mqtt client (fx or explorer)
You will need to publish a message to a topic.

Once you have figured out how to control your device using a client then post your results here.

1 Like

Hi James,

thank you for your help.
“Can you connect your openwb and mqtt fx to your Mosquitto Broker?” ← That’s exactly what I don’t know, openwb doesn’t give any information on that.
When I subscribe in mqtt fx with “#” I get nothing and scanning doesn’t get any results. MQTT-Explorer shows something, but I can’t really interpret it or tell if it’s from openwb. Anywhere in particular I could check?

Hi,
OpenWB has it’s own MQTT server.
So you can either configure a second MQTT Broker thing in Openhab (what I did), or use Mosqitto as an MQTT bridge. Then, you will get the payload via Mosquitto. But this needs configuration in Mosquitto.
For OpenWB MQTT data see
OpenWB MQTT forum thread
I got it running within minutes.
Joerg

2 Likes

@Ursusprimus,
With regards to your configuration in OpenWB: This is only necessary for option 2.
If you use OpenWB as in option 1 (own MQTT broker), you just need to configure the broker thing in OpenHAB with the IP-address of your openWB and port 1883.
And the same for MQTT.fx.
IP,port and subscribe to “OpenWB/#” because all topics start with “OpenWB” as visible in the link above.
Joerg

1 Like

THANK YOU SO MUCH, Jörg!
I spent several frustrating hours with that and the solution - as most of the time, once you know it … - is quite simple. I didn’t know that openhab stored its data in its own mqtt-database with its same IP-address. Well, now I do :slight_smile:
Made my afternoon :wink:

I have a similar problem. After I figured out, that in openHAB I need a MQTT broker and a generic MQTT Thing I was able to add channels and read stuff out of the openWB MQTT. :slight_smile:

But even more important for me is the possibility to write data to the openWB trough openHAB (via MQTT).
I figured out, that I am able to write to openWB/set/pv/W using MQTT Explorer. But if I try to send my PV current production to the openWB from openHAB it wont work.
I linked the item that holds my current production but it does not send anything to the openWB. I don’t know what I am doing wrong or how to even debug it, because I can not see anything in the logs.

I tried nearly all combinations of the settings, without any effect.

The items are linked correctly (when sun is shining there is a number gt 0 ;-))

Anyone has a clue?

Hi,
I’m not quite sure, if you can do this via the command payload.
I did it via a rule.
When item changes, send item state via publishMQTT
E.g

val mqttActions=getActions("mqtt","mqtt:broker:87c4e9b7")
mqttActions.publishMQTT("/broker/topic", "message")

Joerg

How are you doing that? To send an MQTT payload to a channel’s commandTopic requires you to send an openHAB command to the linked Item. A state update doesn’t count here.

So what am I supposed to do? What is the sense of linking items? Do I need to write a rule to update the item?
:flushed:

Start from where your data is coming from. Is that arriving in the form of an update to an Item? From some other binding, via a channel,perhaps?
There’s a number of ways.

You can write a rule that listens for updates to your Item, and sends commands to some other Item linked to the MQTT channel you’ve shown us.

Or, you can write a rule that listens for updates to your Item and sends MQTT messages directly, as @Joerg_Schreiner suggests.

You might find those methods convenient if you have to massage or encode the state in any way before sending.

Or,you can link your MQTT channel to the original Item, but using the special “follow” profile, which effectively listens for Item state changes and sends them as commands to the MQTT binding.