Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Gateway support using openhab transport #75

Closed
wants to merge 10 commits into from

Conversation

Projects
None yet
3 participants
@mcguiresean
Copy link

commented Mar 23, 2017

No description provided.

tobof and others added some commits Mar 22, 2017

Refactoring of the MySensors binding (#74)
* Initial commit of the refactored binding from @andreacioni

* mvn license:format execution

* mvn license:format execution (2)

* mvn clean install -P check --> corrections

* Changes to apply OpenHAB coding guidelines

Signed-off-by: Tim Oberföll <oberfoell@web.de>
// private so cannot be used.
mqttPublisher.publish(topicPublish, msg);
} catch (Exception e) {
logger.debug("Error sending MQTT message: {}", e.toString());

This comment has been minimized.

Copy link
@andreacioni

andreacioni Mar 23, 2017

Hi @mcguiresean. Good work! Just a little suggestion. I guess here you could use request MySensorsAbstractConnection.requestDisconnection(boolean flag). This cause the connection to go down and attempt to reconnect after 10 seconds.

This comment has been minimized.

Copy link
@mcguiresean

mcguiresean Mar 24, 2017

Author

Good idea @andreacioni
It would auto-connect as soon as the broker is available again but at least this way the bridge is informed of the unavailability. I've committed some changes to this effect.

Sean McGuire
Handle broker unavailable (nullpointerexception on publish) by
requesting disconnection of abstract connection.
@Override
public void processMessage(String topic, byte[] payload) {

logger.debug("MQTT message received. Topic: {}, Message: {}", topic, payload.toString());

This comment has been minimized.

Copy link
@tobof

tobof Mar 27, 2017

Owner

payload.toString() does not work. Use something like:
String message = new String(payload);

String messagetext = nodeId + ";" + childId + ";" + msgType + ";" + ack + ";" + subType + ";"
+ payload.toString() + "\n";
logger.debug("Converted MQTT message to MySensors Serial format. Sending on to bridge: {}",
messagetext);

This comment has been minimized.

Copy link
@tobof

tobof Mar 27, 2017

Owner

Please use messagetext.trim() to improve log readablility.

This comment has been minimized.

Copy link
@tobof

tobof Mar 27, 2017

Owner

Please move String generation to MySensorsMessage.

String payload = splitMessage[5];

String newTopic = topicPublish + "/" + nodeId + "/" + childId + "/" + msgType + "/" + ack + "/"
+ subType;

This comment has been minimized.

Copy link
@tobof

tobof Mar 27, 2017

Owner

Move string generation to MySensorsMessage to keep this class clean.

@tobof
Copy link
Owner

left a comment

I've done some first tests against mosquitto and this great work, thank you! I'll continue to test.

@tobof

This comment has been minimized.

Copy link
Owner

commented Mar 27, 2017

I've tested sending and receiving messages via a broker configured in mqtt.cfg. That's really good work!

The binding is receiving messages, but there is a bug in the payload conversion. Sending of messages seems to work. I've not yet tested it against a MQTTGateway but will do so.

One thing to keep in mind is: the binding adds the need for org.openhab.transport.mqtt regardless if mqtt is used or not. Similar to org.openhab.transport.serial. It's no problem, but maybe we find a way to avoid this in the future.

@mcguiresean

This comment has been minimized.

Copy link
Author

commented Apr 5, 2017

Hi @tobof ,
I've moved the string manipulations into the MySensorsMessage class by creating 2 new methods: parseMQTT and generateMQTTString. Hope this is what you meant?

@tobof tobof force-pushed the tobof:MySensors_Binding branch 2 times, most recently from 1791a10 to 27f6f42 Jul 12, 2017

@tobof

This comment has been minimized.

Copy link
Owner

commented Jul 14, 2017

Hey @mcguiresean !

After a lot of work to fulfill the requested changes needed for a integration into the official openhab2-addons repository, I'm now back to MQTT. 😄 Sorry for the long delay, but I needed to finish that one first.

The changes I've made now lead to conflicts with this PR. I think (and hope) it won't be that hard to resolve the conflicts. Please let me know if you've the time to look into it. Thank you!

@tobof tobof force-pushed the tobof:MySensors_Binding branch from 27f6f42 to 5a28ab5 Jul 14, 2017

@mcguiresean

This comment has been minimized.

Copy link
Author

commented Jul 17, 2017

Superceded by PR #85

@mcguiresean mcguiresean deleted the mcguiresean:MQTT_Support branch Jul 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.