MQTT 2.x binding not receiving events from espeasy

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.

Help would be highly appreciated.

Your item doesn’t match with your things file ^^. Use Paper UI for linking and report back if the auto created link works.

Wow, that was a quick reply. Sorry, I gues this was just a translation error - trying to get away from my german english setup.

Here’s the original one - 100% copy and paste:

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:mosquitto2:esp_waschkeller:temperature"}

Hopefully not copied 100%, otherwise there would be a starting slash too much.

You’re right - there are some mistakes within the config. Those are result of me fiddling around to get the setup working.

I double checked, this should be the config that I would expect to work - but doesn’t:

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"}

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.

This needs to be checked on the controllers config page: by default one will need a leading slash in ESPEasy:

1 Like

The reason I mentioned trying it both ways.:wink: It may be required to change the default Esp config in order to work with 2.x.:thinking:

Guess well see when the OP replies back, or I take the time config one of my Esp’s for 2.x

1 Like

That was pretty straight forward, took me about 30 min, but I only have 5 nodemcu’s.
I left the leading slash in place, works without any problems.

1 Like

Good to know,:grinning: and double thanks for the info.:+1: 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.:laughing: Sorry, I know it’s corny but I couldn’t resist.:rofl:

1 Like

Would be even easier if they’d support Homie. But that day may come some time.

1 Like

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,:+1: for being versatile, even for us hard heads.:rofl:

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.:+1:

2 Likes

Hello All,

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… :wink:

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 :joy:
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.

Cheers David