Developing Meross Binding using hivemq-mqtt-client instead of Paho, is that ok?!


I am about to develop a binding for Meross devices and was able to translate an existing python library to Java using the open-source mqtt client from Hive.
Now I am realizing that this might conflict with the already existing/included Paho client.
Would it be a deal breaker to use Hive’s client lib?

Thanks for advise and sorry that I haven’t researched enough beforehand…

1 Like

Could you please explain a bit more why you develop a device specific binding using mqtt protocol while we have a mqtt binding in place.

1 Like

well, my understanding is that Meross has a mix of a rest-api and a mqtt broker. And I need to call the rest api first in order to get user/pw and some other stuff needed for the mqtt connection. I am far from being an expert in this field, maybe I could have used the existing mqtt binding from my binding in order to achieve the same result? :thinking:

the original rev-eng’d python lib -
my work in progress java port -

I’m not a developer so my comments are probably not all that worth while. However I had the same question as hmerk.

Based on what you describe it sounds like it might be more appropriate as an extension of the MQTT 2 binding than as a separate binding. The binding currently has support for Homie and Home Assistant which both do automatic discovery of MQTT topics and creates appropriate Things for you. This “feels” like it could be a third type supported by the MQTT binding.

Is this a one time thing or does it need to be frequently? If it’s a one time thing, it seems reasonable and not at all unusual to require those steps be performed manually and used to configure the Things needed.

I do not know if it is possible for bindings to use each other like this in OH 2, but I do know that some stuff that is commonly used, like connections to serial devices, have been pulled out into their own bundles. Perhaps MQTT should be done so as well?

I had a quick look at the repos, as the user id and password are md5 hashed, there is indeed a need for a binding combining a REST and MQTT client.

@David_Graeff is it possible to create a MQTT broker connection with user and password via openHAB REST API ?

If this is possible, a dedicated Meross Binding could retrieve needed information via REST and create according thing(s) via REST.


Sure. You can create an mqtt broker think via the rest API. But a binding would be nicer than that hackish way I guess.

I have separated the mqtt parts recently and the homie and HomeAssistant bundles are indeed good examples on how to use the base mqtt bundle.

In this case it seems like a 3rd mqtt broker think would need to be implemented.

1 Like

Ok, so if I understand this correctly, I should rather extend the existing mqtt2 binding using the mqtt client available and add a thing(s) provider following the Homie/HA example…
Correct? Sounds doable to me.

It depends if that reliefs you from some work.

If you need to be more to the metal, you can use the openHAB mqtt transport bundle directly (there is a slim paho wrapper class MqttBrokerConnection to be used with a simple nice async API).

it doesn’t. not at all actually. I would have to rebuild all the mqtt logic and that was a quite painful and long lasting experience.
I was under the impression developing a new binding is easier. I am not familiar with Eclipse, never worked with it, and I couldn’t set up the addons project in Intellij. My hope was to either copy some simple binding or follow the presumably easy dev documentation. My plan now is to look at the zigbee/zwave bindings and maybe use that approach. Seems a lot easier…

I couldn’t set up the addons project in Intellij

If you import existing addons from within the “bundles/” directory that will work in Intellij.
You probably have read about the current build system migration away from the former very eclipse specific setup.

Starting an openHAB instance does not work though. But that doesn’t work in Eclipse either at the moment, not so well / painless at least. We haven’t figured out a guide for development yet.

ok, but how to satisfy all the crazy dependencies to the openhab core stuff…do I need to checkout the core project and build it once locally?

What I did now:

  • cloned master of addons repo
  • create new project / module based on exiting sources in one of the binding folders (chose mihome)
  • tried mvn compile -> complains about missing deps (understandably)

maven does this for you. You import the addons2 project as maven project into Intellij and the IDE should run maven for you.

I didn’t even know that this goal is a thing. You usually do mvn install which does all required steps. I’m not a maven master as well, I’m using gradle usually, but the above command can be found on the internet everywhere :smiley:

I would consider myself an advanced Maven user. Thanks for the advice.
The mvn compile goal is part of the lifecycle and executed way before install. It checks deps and compiles the source code (surprise!).
Anyhow. The dependencies defined in the addons project cannot be found in a public mvn repo (check). That is why I assumed one needs to checkout the core project and build it once locally. That would install the artifacts in the local mvn repo which then can be found by all sorts of clients (like your IDE or even Gradle(!))

I see. Check the reactor pom of openhab2-addons. All repositories are defined there. But you are right that you probably need to execute maven from the root directory once, before you can use it in subdirectories.

And: We don’t use (maven central) but bintray

I was wondering if you managed to get a working binding for meross switch?
Thank you!

1 Like

Has there been any work on a meross binding? I’d like to integrate my MSS310 plugs into Openhab, but this does not seem to be straightforward