MQTT 2.4, miflora = problems

I’m trying to migrate from MQTT1 to MQTT2.4 but i’m failing miserably.

As to speed-up the debugging process i’m using “temporary” miflora sensor and publishing straight to mqtt (for testing):

mosquitto_pub -t miflora/temporary -m “{"light": 4, "temperature": 22.7, "moisture": 9, "conductivity": 195, "battery": 825}”

Then i’m defining my broker in mqtt_broker.things file:

Bridge mqtt:broker:kopra “Kopra MQTT server”
[
host=“”,
username=“”,
password=“”,
clientID=“openhab”
]

And after that i’m trying to define my sensor in miflora.things file:

Thing mqtt:topic:kopra:temporary “temp” (mqtt:broker:kopra) {
Channels:
Type number : battery “Battery Charge” [ stateTopic=“miflora/temporary”, transformationPattern=“JSONPATH:$.battery” ]
}

In the end there’s item in miflora.items:

Number temporary_Battery “temporary [%d %%]” (gPlantBattery, gBatteryPercent) { channel=“mqtt:topic:kopra:temporary:battery” }

All seems good and no error’s anywhere … but no update of item as well :frowning:

But if i “merge” broker to same things file:

Bridge mqtt:broker:kopra “Kopra MQTT server”
[
host=“”,
username=“”,
password=“”,
clientID=“openhab”
]
{
Thing mqtt:topic:kopra:temporary “temp” (mqtt:broker:kopra) {
Channels:
Type number : battery “Battery Charge” [ stateTopic=“miflora/temporary”, transformationPattern=“JSONPATH:$.battery” ]
}
}

All seem’s to work like a charm … and i do get update to item.

As i read from the forum it should be possible to separate broker from things?
Can anyone tell me what i’m missing or what i’m doing wrong ?

Try:

channel="mqtt:topic:temporary:battery"

Your shouldn’t need to specify your broker in the Item, because that’s already defined by your Thing (and therefore the Channel).

1 Like

I was trying all different approaches but none of them seem’d to work …

Then i renamed my broker items file and suddenly everything started to work.

I’m thinking that my mqtt connection dies and that’s the problem - will investigate this idea …

Do you mean your broker Things file? If so, then yes openHAB sometimes has trouble when you’re making small edits and saving. I often intentionally corrupt the Things file (remove a } or something similar), save, then replace the } and save again.

Although it looks like you’ve got the hang of converting v1 to v2 you may find the following not obvious documentation useful:

As i read from the forum it should be possible to separate broker from things?
Can anyone tell me what i’m missing or what i’m doing wrong ?

A space here or there does wonders. Try and name your things different to broker.

  Thing mqtt:topic:foo "Foo Bar" (mqtt:broker:kopra) {
Channels:
      Type number : battery "Battery Charge" [ stateTopic="miflora/temporary", transformationPattern="JSONPATH:$.battery" ]
}  
Number Battery "Battery charge" {channel="mqtt:topic:foo:battery"}

Actually i think i had multiple problems…
At first it was a lot of misconfiguration and misunderstandings how things work…
Secondly with wrong configurations i managed to “kill” my Bridge and i might have tried right configuration and wrong configuration (i do suspect that because some configurations where without errors).
Thirdly i “restarted” Bridge (added one empty row and saved) - it got reconnected.
Then tried again my temporary item … and suddenly all started to work.

And as i later discovered … if i put Broker in same file as Thing configuration - connection to broker get’s reloaded/reconnected every time as i save the file.

In that … can someone direct to information where i can make some kind of trigger or where can i find how to detect “dead” Bridge? If that can be detected i could make some kind of trigger to notify me about this fact.

A space here or there does wonders. Try and name your things different to broker.

For future reference can you please point the wrong space - so others can benefit form it (without going trough extensive comparison).