MQTT reading

Thanks for the update/correction. The URLs should be reliable now. :slight_smile:

In the mean time I did a complete new setup and it seems there was a misalignment between the arduino sending commands where I was configuring OH for states.

Remarkable the amount of time you can spend on something that stupidly simple.

Anyways, thanks for directing me to the page, copying the examples got me to the right solution.

the link no longer works.

The MQTT binding page MQTT - Bindings | openHAB
does not have any examples of reading input.

Did the move anywere else?

Four years have passed since this thread was active. openHAB was version 1 then, now version 3.
Are you really looking for version 1 docs?

Current docs are at the link you posted. People often miss following on from there to the things and channels page.

I did not ask for MQTT1 , I’m saying that there are no longer examples of how to read from MQTT.
Yes I look at the channels and the things, I don’t find an example on how to read from an MQTT topic.
I just want to read a number or a string, nothing complex, yet I don’t find the info. Not on this page, nor any other pages

Setting up MQTT is quite technical, so it all assumes you know what you want to do.
I suppose you have to frame your search in openHAB terms.
I’d like to get some data into an Item.
To get that from outside, you will need to use a binding - you’ve already found out to use the MQTT binding.
To get the binding to send the data to your Item, you need to set up Things and channels.

This looks relevant -

I have been using MQTT for years.
I know it’s set up correctly.
Also with Openhab I have been sending data to arduino’s around the house, that has been working for years.
Now I also want to read data in openhab.
The are lot’s of examples for sending data.
An din the old MQTT1 documentation there was info about reading data. (as the old answers were pointing to that.
So I find it strange that in the new documentation there is nothing for reading data.

I don’t really understand your problem then. What is different about your “reading data” to having an openHAB Item getting state updates from subscribing to an MQTT topic?

Try this

Ok, I’ll take a step back.
I was looking for a way to read information send by MQTT.
In a similar way as I send data.
What I forgot to mention (as for me it’s how I work and I forgot that it’s not the default anymore)
is that I configure everything though scripts.
So send data configuration something like

String NP60_4_Color (All) {mqtt=“>[mosquitto:164ARD/OpenColor/color:command:*:default]”}

And then some code in a rule like

var String color = redValue + “,” + greenValue + “,” + blueValue
NP60_4_Color.sendCommand( color )

And as far as I remember, examples like these were part of the MQTT binding documentation.
I think I need something like

Number test5 “test5 [%f]” {mqtt=“<[mosquitto:test-05:state:default]”}

==> this gives a number back, yet it’s not the number that was send. it’s just the state.
I might be close, or it might be completely off track, hence I’m looking for a few examples…

Okay, that is configuration syntax for MQTT binding version 1.
You cannot use that in openHAB 3.
You can use only that in openHAB 1.
In openHAB 2, you have a choice of installing MQTT binding version 1 or version 2.
Configuration is wildly different for binding v1 or v2.

So we really need to know your target environment.
It would be really helpful if you showed the topic and payload you want to subscribe to.

The world has moved in four years, but the archived v1 binding docs are not very difficult to find at

I’m running 2.5 at this moment I thought I had already switched to mqtt2, yet I notice that there are no script examples there, anyway, I’ll probably just upgrade to the new mqtt when I swap to 3.0

I had been looking for the documentation of previous mqtt, I did not find it.
when I do a search in the addin, they no longer show up. (or I do something wrong)
that is why’re I replied originally here, because here were (old) links to the documentation.

Anyway, thanks I’m going to try this out tomorrow evening.

isn’t that what I did when I wrote

Number test5 “test5 [%f]” {mqtt=“<[mosquitto:test-05:state:default]”}

I don’t know, most MQTT topics have more to them than “test-05” so I don’t know what I’m looking at without explanation. This whole exchange has been about you not knowing what to put in there, so I’ve no idea what you meant it to be.

For when you eventually upgrade to the V2/V3 binding

2 Likes

Like I said I wanted to read a number or a string.
That’s all. yes I have been trying multiple things ,before I got anything back.
So I pasted the code that gives me something back.

Okay, I’m giving up. I cannot guess what it is you are trying to do, only from a configuration that doesn’t do what you wanted.

What I wanted was the examples, as I knew I was close to figuring it out.
And in the link you gave with the old documentation helped me.

the

Number test5 “test5 [%f]” {mqtt=“<[mosquitto:test-05:state:default]”}

needed to be

Number test5 “test5 [%f]” {mqtt=“<[mosquitto:test-05:command:default]”}

I don’t know what else I could have said different. I have multiple devices (arduino and others) sending plain numbers over mqtt.
Now it works, so thank for sending the link.

That is very usefull information. Now that I have this working, and I realize I’m still on mqtt1, it might be good to look at going for mqtt2 in the comming weeks.

I’m a little confused. This text you linked states that you can have a mqtt 1 and an mqtt2 binding at the same time and we can convert things steps by step. (Which is really helpfull for converting)

Yet the mqtt2 binding states at the bottom that it should not be installed at the same time of the MQTT1 binding.

Which statement is correct?

Also you stated:

For when you eventually upgrade to the V2/V3 binding

Do I read this correctly that MQTTV2 and MQTT V3 are the same? or does that just mean that upgrading MQTT to V2 is a good preparation for MQTT in V3?

I don’t know the answer to that I’m afraid.

Yes, correct.

1 Like

Thanks, when I have again time for the next steps, I will test this out an report back.
It’s already good to know that MQT2 and MQT3 are the same, that is one less challenge for moving ahead.
yet that will be after covid lockdown when things are a little bit more normal …