I’m confused, is the MQTT module in HG a client and a broker or just a client and do I need to install mosquitto(sp?) or something similar on my PI?
Currently I have the module installed and set the server to my PI’s ip address but I get a continuous error “Exception connecting to broker”
I want to try the Owntracks APP on my android phone. This app communicates via MQTT and reports your position or simply if you are in a waypoint area. It only sends an update when your phone detects movement so it’s battery friendly(I hope).
Once I figure this out I will post step by step instructions. So please help me get this going.
There is an MQTT Interface you can install and if you use this you dont need mosquitto.
I would probably use a cloud based mqtt server unless you are happy exposting mqtt externally on your hg server to the world… I dont think the HG MQTT interface security is up to this personally.
I setup on cloudmqtt.com. I see Owntracks location messages on the cloud service as well as homegenie module messages. So both are talking TO the cloud service.
I can’t figure out how to get homegenie to receive the owntracks messages and use them.
You havent set up homegenie correctly… you need to write an app that subscribes to the mqtt topic and does something with it, the way you have done it is for linking HG systems…
Try something like this (put the startup code in the correct window and program code in the correct place…)
// Startup code
Program.AddOption("ClientId", System.Environment.MachineName, "0. Enter unique ID for this client", "text");
Program.AddOption("ServerAddress", "", "MQTT server address (Do not use 127.0.0.1)", "text");
Program.AddOption("ServerPort", "1883", "MQTT server port", "text");
Program.AddOption("ServerTopic", "#", "Topic", "text");
// Program code
string server = Program.Option("ServerAddress").Value.Trim();
int port = 1883;
int.TryParse(Program.Option("ServerPort").Value, out port);
string topic = Program.Option("ServerTopic").Value.Trim();
string clientid = Program.Option("ClientId").Value.Trim();
if (server == "")
{
Program.Notify("MQTT", "Please configure server address");
Pause(10);
return;
}
else
{
Program.Notify("mqttTest", "Connecting to " + server + "...");
try
{
MqttClient.Connect(port, clientid);
Program.Notify("mqttTest", "Connected!");
}
catch (Exception e)
{
Program.Notify("mqttTest", e.Message);
//Pause(5);
return;
}
}
MqttClient.Subscribe(topic, (mtopic, mpayload) => {
Program.Notify("mqttTest payload", mtopic);
});