This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
Use CloudMQTT as a broker for ownTracks or MQTT App
MennoVanGrinsven
Member
MQTT brokers are very interesting for IOT. Also there are some nice implementations for the use with Homey. For those Homey enthousiast who do not want to host a MQTT broker themselves (or do not have the knowledge to do so) there are some solutions (free of charge) in the Cloud.
Using a public MQTT broker for location purposes (such as ownTracks) is not really a good idea privacy wise. But CloudMQTT has a nice solution and their free plan is good enough for simple usage.
Their CuteCat plan (10 concurrent sessions and 10 kbit/s) is good enough for small JSON messages that are send by the ownTracks phone app.
This is a small tutorial to show how to setup CloudMQTT for use with my ownTracks homey app (or any MQTT app).
Once you made an account and created a server, you can see the server details in your control panel.
Select detail to further setup your MQTT server. You will see the page below:
First you will need to add users to your MQTT server. Create a user for each device you want to connect. So a user for your Homey and each phone you want to use with ownTracks.
Once you created a username and password for your homey, you can add those data to the ownTracks or MQTT app:
Copy the data from the CloudMQTT Sever field into the IP adres / DNS field in the ownTracks/MQTT settings page.
Use the SSL Port filed from the CloudMQTT settings as portnumber in the ownTracks/MQTT settings page.
Make sure you enable the "use a secure connection with the broke (TLS)" (checkbox should be checked).
Fill in the Username and Password fields with the data your just created for your Homey.
Now you should be able to connect to your CloudMQTT broker through a secure connection.
BUT you are not done yet. The users must be given access rights to topics.
To give the users access to the owntracks topics, select the User you want to give access to and enter owntracks/# in the Topic field. Also give the user both Read Access and Write Access. Press the Save button.
That should be all.
Comments
Why would you want to create different users?
I just used the default user/pass from cloudmqtt for both phone and homey which works well as far as I can tell.
Because with different users you can set different access rights. With Owntracks for example, you can do some location spoofing by sending location messages on the topic of your wife / girlfriend whatever ....
In fact if you use your location to turn devices on or off, this can be "fun"
for example
huis_man geofence
huis_vrouw geofence
But you don't have to use same user for a "MQTT Broker" because I am using Mosquitto MQTT Broker on my NAS and the homey owntrack client has a complete different login.
Also the homey owntrack MQTT Client has an API with the Broker so the messages which are coming in there could be from all over the world and from completely different users
There's only one thing I don't understand. In the beginning I made some mistakes with adding my device. I'm using the owntracks app on android and cloudmqtt. When I look at my "friends" in owntracks I see 2 old devices I can't delete. Reinstalling app won't help. When I look at Cloudmqtt websocket UI I still see the 2 topics of these old devices.
I'm new to MQTT and don't understand how I can get rid of these old topics so they wont show up on the owntracks android app? Hope someone can help me.
Ah well MQTT messages are persistent. You can only remove them by posting an empty message on that topic or make the MQTT server non persistent
You could use the action card to post a message or something like MQTT lens (chrone plugin)
Hard to say.. There should not be much difference. There is, but that is in milliseconds (network traffic passing firewalls and routers). But that is depending on server load and such.
I would go for CloudMQTT unless you want to host yourself because you like to do such things yourself.
Personally I host MQTT myself, but I also host my own mailserver, owncloud server etc.
The small bandwidth of CloudMQTT and the max amount of users should be enough for normal household usage.
I can't find a good tutorial of CloudMQTT with Homey Owntracks and the iOS app. Not even on google.
The data you have to enter in the client is written in the tutorial. The only things you need to enter for this to work should be the server name and port number, username and password.
And enable TLS.
I don't have an iOS device, otherwise i could make some screenshots.
Is there anything specific you are running into?
-edit- Geofences are not working..
After some headscratching (I still don't completely get the MQTT concept...) I think I got it running.
- Registered at Cloudmqtt, created server, users (4 phones + Homey), ACL
- Configured the Owntracks app on Homey, created 4 users and 1 'Home' geofence
- Configured the Owntracks app on Android
Everything seems to be connecting ok.
And now what?
How do I define what the 'Home' geofence area is?
I also installed the MQTT Client app. Do I actually need it? I guess not.
There are three trigger cards (one for entering a fence, one for leaving a fence and one that gets triggered on enter and leave).
In these trigger cards you can specify the fence and user.
The users and fences should be added automatically, and can be checked in the settings page.
Please use the fence / user cards and not the cards that require a topic. Those topic cards will be removed in the next version.
Tried that first, too much typing work with the long url's and stuff
So I just went and registered the cloudmqtt
The users/fences will be added automatically? What is this, magic!?
I added the users in the app, I shouldn't have done that then? Hope this doesn't mess things up.
I'm at work now. It will automatically add this place as a geofence? How, when?
Sorry, lots of questions, don't quite get the way it works yet
No it will not automatically add a place, but when you add a new Geofence then it will send a way point message to the broker containing the Geofence name (please remember to enable the sharing option when you add a fence / region in the phone app. Otherwise it will not send the name and you need that name). If the Geofence is unknown, it will be added. You get notified when that happens in the homey notifications.
Also the homey owntracks app adds a unknown user when it receives a MQTT messages from that user (not when using HTTP ofc).
Also the condition card is useful. You can check then if there is nobody is at home or when there is someone at home.
I'll let you know when it doesn't work as expected
[edit]
1 more question, in the Android app, what do I use as Device ID? Does it matter, or is this the username Homey uses?
You can ask homey for the location of a user (homey will answer with the fence name or adress based on coordinates)
Dus: OK Homey, wat is de lokatie van ......
Device ID is not used in the homey app (not yet anyway) but the phone apps use it to display the device on the map (when using a MQTT broker)
Edit: oh no that's tracker id
Edit 2: device ID is part of the topic. Not using that inside the homey app. It's a bit of a mess when someone has multiple devices and uses that for location purposes. So using the username is more safe, then it does not matter what device is used (well that is at least my way of thinking)
Went to check my settings for the OwnTracks app and they're all gone :P
Anybody had that happen to them before?
Press delete user settings. The settings file is corrupt. If you restart the owntracks app, you will see that the files can't be read.
But are all settings gone or just the geofences and usernames?
That's strange because that is not in my control.
No. Why would you make that conclusion? HTTPS is for those setups or people.who don't want to setup a broker or don't have the knowledge to do so. For all the features you need a broker. You have several options. Use a cloud based broker like CloudMQTT, use your own MQTT broker on your own server or use the MQTT broker for Homey.
The last two options will require port forwarding and configuration of TLS certificates.
Now hoping it stays alive!