Closed mcguiresean closed 7 years ago
Thank you @mcguiresean !
There is one thing that is bugging me in your implementation and in my proof of concept: the binding itself establishes the connection to the MQTT broker. So, in my case for example, I'm using the MQTT binding (1.9) together with the MQTT event bus to establish a connection to the MQTT broker. In 1.X bindings it was possible to reuse this connection (done for example by the outdated binding mqttitude/owntracks). This way you are able to handle all MQTT related configuration in MQTT.cfg and only need one connection to the broker. In the binding you only subscribe to the topic you need.
I've not yet found an implementation of this mechanism in OpenHAB2, but I'm sure this should be doable. Maybe we have to wait for a native MQTT binding for OpenHAB2 and in the meantime handle the connection to the MQTT gateway in the binding.
@tobof I hadn't looked at the owntracks binding so didn't realise it could reuse the core MQTT binding's connection. This sounds like a more elegant solution than maintaining a separate connection in the MySensors binding itself but as you say, it may not be possible until there is a native 2.x version available.
I have a working PoC of the MQTT support using the built in transport rather than maintaining our own broker connection. Will submit a PR in due course.
@mcguiresean That is amazing! Can't wait to see the PR. I'm currently cleaning up the Repo and rebase to the refactored version.
This PR adds MQTT gateway support.
Summary:
New gateway type and parameters (broker URL, client ID, username, password, subscribe topic, and publish topic) New mqtt connection type, sits alongside current serial and ethernet options.