[SOLVED] MQTT data is not being received

  • Platform information:
    • Hardware: Raspberry Pi 3B
    • OS: Raspbian
    • Java Runtime Environment: 1.8.0_201
    • openHAB version: 2.5.0M1
  • Issue of the topic: There is no data pushed to influxdb
  • Please post configurations (if applicable):
    • new MQTT binding (2.x)
    • items configured in sensor.items:
Number:Temperature      Sensor_Salon_Temperature            "Salon Temperature [%.1f %unit%]" <temperature> (gPersist)  {channel="mqtt:homie300:MQTTBroker:pi:salon#temperature"}                                    
Number:Temperature      Sensor_Garden_Temperature           "Garden Temperature [%.1f %unit%]" <temperature> (gPersist)     {channel="mqtt:homie300:MQTTBroker:pi:ogrodek#temperature"}

My mqtt topics are homie based, and in Paper UI I can see the device “pi” correctly and it recognizes that there are two properties there: salon and ogrodek.
I copied the channelID from Paper UI into the sensor.items file, the items were created but both values are -NaN.

When I connect to the MQTT directly I can get that data.

Here’s how I push data to MQTT:

mosquitto_pub -h $MOS_IP -r -t homie/pi/ogrodek/temperature -m "2.3"       
mosquitto_pub -h $MOS_IP -r -t homie/pi/ogrodek/temperature/\$name -m "Temperatura"
mosquitto_pub -h $MOS_IP -r -t homie/pi/ogrodek/temperature/\$unit -m "°C"      
mosquitto_pub -h $MOS_IP -r -t homie/pi/ogrodek/temperature/\$datatype -m "float"

Did you push the “homie/pi/ogrodek/$properties” as well? You should do that last. Because the mqtt broker has only 200ms time to provide all property topics before openHAB starts to create the channel.

That is a shortcoming of the current implementation. See also the mqtt roadmap topic in the developer section of the forum.

Yes I did that after the settings above:

mosquitto_pub -h $MOS_IP -r -t homie/pi/ogrodek/\$name -m "Ogrodek"             
mosquitto_pub -h $MOS_IP -r -t homie/pi/ogrodek/\$properties -m "temperature"  

And it finds it in Paper UI, so I assume I did that correctly, the only issue is that it doesn’t read the values

And this was it: https://github.com/eclipse/smarthome/issues/6828
Workaround from pavax:

#!/bin/sh echo "cleaning " $1 " :: usage: cleanmqtt &lt;host&gt;" mosquitto_sub -h $1 -t "#" -v | while read line _; do mosquitto_pub -h $1 -t "$line" -r -n; done

and running ./script.sh broker_ip

This should be run after each openhab restart (I think).
So now waiting for M2 release (I wonder if there are any plans for that)