HomeGenie Forum

Development => Bug reporting => Topic started by: mvdarend on August 20, 2015, 08:36:54 PM

Title: MqttClientHelper Publish
Post by: mvdarend on August 20, 2015, 08:36:54 PM
I think I may have found a problem with the Publish method in MqttClientHelper.cs, in this forum message (http://www.homegenie.it/forum/index.php?topic=758.msg6253#msg6253) is a description of the problem.

Basically the Payload/Message looks like it's adding a string terminator to the beginning of the string, which doesn't play well with the MySensor nodes.

I downloaded the HomeGenie source and added an extra overload for MqttClientHelper Publish in
HomeGenie/Automation/Scripting/MqttClientHelper.cs.

Code: [Select]
/// <summary>
/// Publish a message to the specified topic.
/// </summary>
/// <param name="topic">Topic name.</param>
/// <param name="message">Message text as byte array.</param>
public MqttClientHelper Publish(string topic, byte[] message)
{
lock (mqttSyncLock)
{
mqttClient.PublishMessage(topic, message);
}
return this;
}

Calling it from HomeGenie with the following code works :) and the Payload is arriving at the MySensor node.

Code: [Select]
MqttClient.Publish("MyMQTT/21/1/V_LIGHT", Encoding.ASCII.GetBytes("1"));
Would it be possible to add this overload to MqttClientHelper? I'm not sure how to go about it in GitHub.
Title: Re: MqttClientHelper Publish
Post by: Gene on August 21, 2015, 02:42:54 AM
login to github and click the following link:

https://github.com/genielabs/HomeGenie/edit/master/HomeGenie/Automation/Scripting/MqttClientHelper.cs

there you can edit and publish the modified file. I'm just telling for future reference. If it's too much bother to create an account on github, I will do it for you.

g.
Title: Re: MqttClientHelper Publish
Post by: mvdarend on August 21, 2015, 06:18:58 AM
Thanks Gene, I was playing around with GitHub a while back as I'd like to help more, so I already had an account.

I'll give the GitHub documents a better readthrough today, as I still don't completely understand all the terms used (forking, pull request etc.)