Unable to read MQTT value

Hello Everybody,

This week I tried to go a step ahead in my home automation with the implemantation of Arduino temperature, humidity, etc. sensors

I have installed Mosquitto broker on my Raspberry, It’s look like working (when I publish a value from a computer, I can read from another one).

Unfortunately, I am unable to read the values from OpenHab.

mqtt.things

Bridge mqtt:broker:myUnsecureBroker [ host="192.168.1.84", port=1883, secure=false ]
{
    Thing topic sensor {
    Channels:
        Type string : tempBathGround "Température salle de bain rez" [ stateTopic="temperature"]

    }
}

mqtt.items

Number Temp_bath "Température salle de bain rez [%.1f]" { channel="mqtt:topic:myUnsecureBroker:sensor:tempBathGround" }

Do you see something wrong in my code ?

Thanks for your help

Nothing leaps out. What MQTT message is your device sending?

Your Thing is listening for “temperature”, and that is all. Mine are more complex than that, but that’s the data my devices are sending. If you’ve got the wrong topic, the value won’t update.

If you subscribe with the command line tools, what messages do you see?

I am testing with mqtt fx application. The broker receive the value and, I can read them from another computer

What makes you think that MQTTfx needs a more specific topic subscribed to then openhab?
For MQTTfx you use “sensor/temperature” for openhab only “temperature”.

Try updating your channel to search for /sensor/temperature just like you have it in your tool. Maybe it’ll see those values. Mine are all complete topics like that.

Hello

I have tried but without success

Bridge mqtt:broker:myUnsecureBroker [ host="192.168.1.84", port=1883, secure=false ]
{
    Thing topic sensor {
    Channels:
        Type string : tempBathGround "Température salle de bain rez" [ stateTopic="sensor/temperature"]

    }
}

Try changing the thing type from string to number.
Example:

Bridge mqtt:broker:myUnsecureBroker [ host="192.168.1.84", port=1883, secure=false ]
{
    Thing topic sensor {
    Channels:
        Type number : tempBathGround "Température salle de bain rez" [ stateTopic="temperature"]

    }
}

Hello,

Thanks but unfortunatelly I am steel not a able to make it work.

My configuration is :

MQTT.things

Bridge mqtt:broker:myUnsecureBroker [ host="192.168.1.84", port=1883, secure=false ]
{
    Thing topic sensor {
    Channels:
        Type number : tempBathGround "Température salle de bain rez" [ stateTopic="temperature"]

    }
}

MQTT.items

Number Temp_bath "Température salle de bain rez [%.1f]" { channel="mqtt:topic:myUnsecureBroker:sensor:tempBathGround" }

Forgot to add sensor to the state topic.

Bridge mqtt:broker:myUnsecureBroker [ host="192.168.1.84", port=1883, secure=false ]
{
    Thing topic sensor {
    Channels:
        Type number : tempBathGround "Température salle de bain rez" [ stateTopic="sensor/temperature"]

    }
}

Thank you I had corrected that just after publishing but it is still not working

Everything looks good in the Things and Items file so changing from string to number was just me guessing.:wink:

Have you restarted OH since creating or modifying the mqtt files? If your using OH 2.4 there is a bug/issue that requires this for mqtt to work each time you make a file change. Use the commands below and see if you start getting the sensor value on OH.

sudo systemctl stop openhab2
sudo systemctl start openhab2