Any help needed regarding the MQTT gateway, count me in. It’s not that mysensors can’t work without it, but it’s so much better.
You can try different controllers, you can use even different controllers at the same time. And you can benefit from it without putting pressure on the openhab (my preferred controller) developers on some functionality, i.e. FOTA or topology mapping.
There is also some simple automation that you can do “outside” openhab that it’s easier with mqtt.
Thanks for the update and info. I certainly want to help, as this library is very important for my installation and I appreciate the work you already put into this.
I can see that the move to bnd requires some big changes. That is new for me too. If you can use some help with the MQTT specific part, does it require an update to to API changes in the org.eclipse.smarthome.io.transport.mqtt library or is it also due to the bnd changes? If you can give us some pointers, I might be able to help this weekend.
I compiled your latest code from github where you added the MQTT gateway again. I was able to install it and see great progress: the MQTT gateway is supported again, but I believe there is still an issue at the point where the MQTT broker is defined. It doesn’t seem to recognize the broker.
I’m glad you’re able to configure the MQTT gateway with the current code, because I was not able to test it yet.
And yes, as I feared, the problem with the binding that doesn’t recognize the broker hasn’t been solved yet.
I believe the MqttService is nowhere set. I don’t know exactly how you have to get this. I assume through the MQTT binding based on the name in the configuration?
I really believe it has something to do with getting the MQTTService. If I alter some settings on the MQTT Broker configuration, I can see things start working. I just can’t find any documentation on how to get the initial MQTT Service.
The MQTT Generic and Homie implementation seem to take a different approach.
I believe the best way forward is to change to a MQTTTopicDiscoveryService. By doing so, the MySensorsMQTT implementation doesn’t care anymore about the brokers. This would require a change in the MySensorsMqttConnection, but I believe this should be feasible.
The OSGI dependency injection works for the MQTTService as soon as I added @Reference annotations to setMqttService und unsetMqttService in MySensorsMqttService.
Since already with annotations that not always worked for me I build a workaround in MySensorsMqttConnection.establishConnection()
boolean connectionEstablished = false;
//Start workaround
if (MySensorsMqttService.getMqttService() == null) {
BundleContext bc = FrameworkUtil.getBundle(getClass()).getBundleContext();
final ServiceReference sr = bc.getServiceReference(MqttService.class.getName());
if (sr != null) {
final MqttService mqtt = (MqttService) bc.getService(sr);
if (mqtt != null) {
new MySensorsMqttService().setMqttService(mqtt);
}
}
}
//End workaround
if (MySensorsMqttService.getMqttService() == null) {
I just upgraded to 2.5 and I also report that mysensors do not work any more. The gateway seems to be online but the sensors do not report anything. It used to work just with openhab 2.4. the mysensors gateway is serial