[SOLVED] Change Item State with mqtt message does not work

Hello :slight_smile:
I’m trying to change item states through mqtt messages in order to simulate Sensor-Measurements.
Openhab is running on a RasperberryPi3 and I followed this Tutorial to install and configure the mqtt Broker. I installed the mqtt Binding, installed mosquitto through openhabian-config and changed the mqtt.cfg to:

pid:org.openhab.mqtt
mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openHAB2
mosquitto.user=openhabian
mosquitto.pwd=****
mosquitto.qos=1

the item:

Number mqtt_kitchen_gas "Gas Level [%.1f]" {mqtt="<[mosquitto:Home/Floor1/Kitchen/Gas_Sensor:state:default]"}

the sitemap:

Text item=mqtt_kitchen_gas icon="gas"

I subscribed to my topic and when I publish a message to it this is the result:

I also subscribed to the topic via mqttLens and the published messages arrive there:

But the message does not change the item state :frowning: the Gas Sensor item keeps showing “-” on the sitemap:
image

What am I doing wrong ?

Is that the literal text in your items-file, or is the < just a copy-paste error? What does your openhab.log show when you save the file?

Oh sorry this is a copy paste error. This is the correct item definition :

If you are running openhab 2.4, which is the current release since yesterday, you need to either enable the legacy (1.x) binding, to support this syntax, or you need to port your definition to the 2.4 bindings syntax.

Thanks for your advice! But how do I port the definiton to th 2.4 bindings syntax?:flushed:

Apparently it is one item only so far.
Just use paper UI like described in the docs if you are not familiar with the text files yet.

Thanks for your help David :slightly_smiling_face:

I decided to try it with the 1.X Binding as Joachim said and now it’s working :heart_eyes: thank you so much!

Sorry to bump old thread. Is it possible to use legacy (1.x) binding with Openhab 3 ?

No. None of the 1.x bindings work with OH3.

Unless you also keep an openHAB 2 instance running, and connect it to your openHAB 3 instance using the remote openHAB binding.

If you are still running a v1 MQTT binding you could check this to convert, or use the new UI in OH3 - it’s pretty easy now!

1 Like