I am trying to connect to a MQTT broker and get data from it.
According to the docs I did the following:
- Installed MQTT Binding
- Created the broker connection (can be seen in Services and shows “Online” in Things
- Created a new thing and used the configured broker connection as bridge
- Within the thing I created an new channel of type “Number Value”
- Configured this channel with a label and a channel-id as well as the topic to subscribe to. Left other things empty
- Created a new items (in PaperUI) through linking the thing to a “new item”
- Finally, created in the sitemap a text element linked to the above item.
However, I do not see any data on my sitemap. Nor do I see any updates regarding the data of this channel. I simply used
mosquitto_pub to publish a message simply “400”.
But I do not see any further details about OpenHAB having got the message received.
I´Can someone guide me to configure an MQTT item somehow? Currently I just want to display, modifying will follow later.
Thanks a lot!
You’ll have to show us all your configuration, including details on your Mosquitto setup.
thanks for taking care of this issue here.
As I went again through all these settings I added the availability channel to it and it appears to be working now…
So the following is just for completeness. Looks like I have to configure the availability now matter why:
What should I show you in detail? I will post some screenshots.
First, the MQTT broker works fine; I tested this with the
I am free to create topics from my device just as I will.
First, the broker settings:
These are the thing’s settings.
I configured the LWT topic for availability ON/OFF and it works just fine when publishing “ON” or “OFF” through
mosquitto_pub -t "Heizung_avail" -m "ON" -r
2021-01-11 12:34:26.374 [hingStatusInfoChangedEvent] - 'mqtt:topic:17ed64b6' changed from OFFLINE to ONLINE
Now this is how it looks in the channel configuration for the thnig:
And the channel configuration is this. I did not configure any additional stuff:
And that’s the item:
additional question now as the above appears to be working. My channel posts messages as key/value pair like this:
I am only interessted in the number of the “boostcount” value so I added a REGEX to the channel settings (REGEX transformation is installed):
Unfortunately I does not appear to be working for a reason I do not get. Someone having examples how to use the REGEX stuff here?
I alreaady tried:
None appears to be working, instead I see in the log:
2021-01-11 12:55:49.572 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload 'boostcount=0' not supported by type 'NumberValue'
Ok, looks like I read too much. The REGEX-Documentation told me a different expression than I should use in MQTT bindung. Don’t ask me why.
However, the following works:
Ok, playing around now and see if I can get my OpenHAB to send MQTT commands.