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

mqtt
Tags: #<Tag:0x00007f1e6dd89b30>
(Tino) #1

Hi,

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

(Hans-Jörg Merk) #2

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

(Tino) #3

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:

0 Likes

(Tino) #4

btw:
the original rev-eng’d python lib - https://github.com/albertogeniola/MerossIot
my work in progress java port - https://github.com/atzbert/meross-java

0 Likes

(Rich Koshak) #5

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?

0 Likes

(Hans-Jörg Merk) #6

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.

3 Likes

(David Graeff) #7

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

(Tino) #8

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.

0 Likes

(David Graeff) #9

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).

0 Likes

(Tino) #10

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…

0 Likes

(David Graeff) #11

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.

0 Likes

(Tino) #12

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)
0 Likes

(David Graeff) #13

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:

0 Likes

(Tino) #14

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(!))

0 Likes

(David Graeff) #15

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.org (maven central) but bintray

0 Likes