I’m in the process of migrating from a working MQTT 1.x setup to a MQTT 2.x setup. I’m using mosquitto as my broker as migrated all 1.x configuration to 2.x. This is my configuration after doing the migration:
mqtt.things:
Bridge mqtt:broker:mosquitto [ host="192.168.0.164", secure=false ] {
Thing topic esp_1 "ESP Test" {
Channels:
Type number : temperature "temperature" [ stateTopic="oh2/esp-1/bme/Temperature" ]
Type number : humidity "humidity" [ stateTopic="oh2/esp-1/bme/Humidity" ]
Type number : presssure "presssure" [ stateTopic="oh2/esp-1/bme/Presssure" ]
}
}
mqtt.items
Number mqtt_test_temp "Temperature [%.1f °C]" {channel="mqtt:topic:mosquitto2:esp_1:temperature"}
Paper UI shows both the broker and the generic mqtt thing as “online”. the thing with channels according to the config file.
So everything looks fine but I dont get any data from this mqtt sensors. Nothing is showing up in my event.log (even though I can clearly see - using MQTT fx - that the ESPEasy sends climate updates to the mosquitto broker)
The openhab.log shows mqtt:topic:mosquitto:esp_1’ changed from OFFLINE (BRIDGE_OFFLINE) to ONLINE and mosquitto log (set to debug,all) shows nothing interesting, although the openhab client (paho something) seems to strangly disconnect shortly after doing the initial connect.
I did several restarts, change the Bridge to localhost or 127.0.0.1 - nothing changes.
If using mosquitto broker make sure the broker name is correct. Below I see mosquitto and mosquitto2.
Also, you have nothing defined in the Things/Items regarding “esp_1”???
Bridge mqtt:broker:mosquitto [ host="192.168.0.164", secure=false ] {
Thing topic esp_waschkeller "ESP Waschkeller" {
Channels:
Type number : temperature "temperature" [ stateTopic="/oh2/esp-waschkeller/bme/Temperature" ]
Type number : humidity "humidity" [ stateTopic="oh2/esp-abstellkeller/bme/Humidity" ]
Type number : presssure "presssure" [ stateTopic="oh2/esp-abstellkeller/bme/Presssure" ]
}
}
I’ve yet to convert my Esp Easy items from 1.x but the only questionable thing is the need for the leading slash so try it both ways. Also remember that you will need to restart OH each time you edit/change the things file.
Bridge mqtt:broker:mosquitto [ host="192.168.0.164", secure=false ] {
Thing topic esp_waschkeller "ESP Waschkeller" {
Channels:
Type number : temperature "temperature" [ stateTopic="oh2/esp-waschkeller/bme/Temperature" ]
Type number : humidity "humidity" [ stateTopic="oh2/esp-abstellkeller/bme/Humidity" ]
Type number : presssure "presssure" [ stateTopic="oh2/esp-abstellkeller/bme/Presssure" ]
}
}
Number mqttneu_wasch_temp "Temperature [%.1f °C]" {channel="mqtt:topic:mosquitto:esp_waschkeller:temperature"}
In the above you have the state topic using esp-waschkeller and the channel using esp_waschkeller, maybe try using esp_waschkeller only. Other than the possible “_” issue the thing/item looks good.
Good to know, and double thanks for the info. I’ve already changed all tasmota firmware devices to use 2.x so looks like esp will be just as easy. Guess that why they call it Esp Easy. Sorry, I know it’s corny but I couldn’t resist.
Even with Homie support, I would still use files for all my things/items. I know it sounds stupid to do so, and I have no specific reasons for choosing the stupid route, it’s just the way I like it. Guess you could give OH another, for being versatile, even for us hard heads.
Myself aside, I really do hope Homie support comes soon. You @David_Graeff have contributed more to the 2.x binding than most on the forum realize. I thank you for your time and effort and keep up the great job.
I just reverted all changes (that I introduced trying to get things running) a simple restart:
Now values from one ESP do show up while the others are still not working. (The leading / was not the problem as I had removed them from my ESPEasy configs before.)
I guess I still have some typos / errors in my configuration but I guess I can identify them by myself - doing a restart every time I change a configuration.
Thank you very much for your support!
Fun Fact: Some days ago I had a problem with another binding. In the end it was due to the fact that I hadn’t restarted OH2 after activating the binding. So, after installing mqtt v2 I did a restart just to be sure. Having to perform a restart every time I change a config didn’t come to my mind though…
That is usually not required and I’m sorry for this experience. I’m not developing with textual configuration in mind and do not test that as well. I don’t even know the syntax for thing and item files
Usually that also doesn’t matter but in this case the unfortunate order in which openHAB restarts the binding thing handlers after a text change makes mqtt struggle a lot. I hope I can tackle that for oh 2.5.