Hello there,
i just started with OpenHAB2 and got some problems creating an Temperature Item to display temperature published by MQTT.
Mosquitto MQTT Binding to OpenHAB seems to work, because i could receive MQTT Data with mqttFX.
My mqtt.cfg looks like this:
Define your MQTT broker connections here for use in the MQTT Binding or
URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883
mosquitto.url=tcp://localhost:1883
Optional. Client id (max 23 chars) to use when connecting to the broker.
If not provided a default one is generated.
mosquitto.clientId=lion
and my MQTT messages from the Sensor look like this:
mygateway1-out/2/0/1/0/1 60.0
mygateway1-out/2/1/1/0/0 24.0
mygateway1-out/2/0/1/0/1 62.0
mygateway1-out/2/1/1/0/0 25.0
Here is my problem… I dont realy know how to merge this to an working temperature Item:
I think it should look somethig like this…?
Number temperature “temp [%.1f]” {mqtt=”<mosquito:mygateway1-out/2/1/1/0/0"}
What you need is described under the section named “Item Configuration for Inbound Messages”, or you could skip directly to the first line under the section called “Example Inbound Configurations”, where the following example is given:
Number temperature "temp [%.1f]" {mqtt="<[publicweatherservice:london-city/temperature:state:default]"}
You need to replace “publicweatherservice” with the name of your MQTT broker (i.e. “mosquitto”) and “london-city/temperature” with your MQTT topic (i.e. "mygateway1-out/2/1/1/0/0) and you should be all set.
And with this line in my items file which gives me the whole mqtt string. Then i take the needed variables out of the whole string with a rule inside openhab: