OpenHabian don't receive MQTT messages

Hello,

  • Platform information:

    • Hardware: Raspberry Pi 3 Model B
    • OS: Raspbian 4.19.57-v7+
    • openHAB version: V2.5.3-1
  • Issue of the topic: I’m preparing a new version of the Openhabian to communicate with Sonoff R1 and R2, with Mosquitto.
    Mosquitto is working well, as demonstrated in this figures.

The Sonoffs are connecting with the broker:

In the folder /etc/openhab2/services, it was created the file mqtt.cfg with this content:
image

It was created an item to send MQTT message to Sonoff to turn on or off the light.

So, I tried to see if OpenHab is sending MQTT messages, the broker receives the answer to the Ping, but OpenHabian don’t send the MQTT message.

The light don’t turn On or Off, can anyone support me in this problem?
Thank you.

You’re probably using some old tutorial about MQTT binding version 1
MQTT version 2 binding uses quite different configuration, with Things and channels.
You need to be consistent about which you use.

I have already an Openhabian working with that configuration.
So, I’m preparing a new one with the OpenHabian new version.

Are you saying this don’t work anymore?

I’m saying if you want to configure MQTT binding using mqtt.cfg file, then you must install legacy MQTT binding version 1.

If you want instead to install and use the current MQTT binding version 2, then you will have to configure it a different way, using Things.

It’s up to you; I have no idea how your other system is set up or what is installed there.

In biddings only appear the version 2.5.3 to install.
I replicate what I had in the first Openhabian that is working. So, what I need to do?

If you want to be offered version 1 bindings in the list, I think you need to configure “enable 1.x legacy bindings” in PaperUI > Configuration > System

Or else you need to learn how to configure MQTT binding version 2.

I configure the “enable 1.x legacy bindings” and it works.

Thank you for your quick support

You may want to consider moving to the mqtt version 2 binding. You can use both versions and move devices one at a time. IMHO the V2 binding seems to work much better. If you like I can post some examples, although the forum has many, to help you get started.

I did some tests with the second version, and if I understood correctly is needed to create an new thing for each MQTT device.
This is correct?

Yes a new Thing for each device and then you can copy the channel link from PaperUI to use in the items file.

You can also migrate the Thing from text files using REST API. Here is a good guide, with pictures, on how to.

Thank you
I’ll try it