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.

Use CloudMQTT as a broker for ownTracks or MQTT App


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.

«1

Comments

  • Great. 
    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.
  • Yannick said:
    Great. 
    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" ;)


  • chrisboerchrisboer Member
    edited March 2017
    You can define different users on the Owntrack app, or have them create "their own" geofences then based on these different geofence you can identify which user is entering or leaving the geofence.

    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
  • I'm so happy with this solution. Couldn't get presence detection via WIFI to work properly on my girlfriends phone, but this works like a charm. Great job and thank you.

    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.
  • Jerpet said:
    I'm so happy with this solution. Couldn't get presence detection via WIFI to work properly on my girlfriends phone, but this works like a charm. Great job and thank you.

    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 
  • And how do I post an empty message on that topic in cloudmqtt?
  • Jerpet said:
    And how do I post an empty message on that topic in cloudmqtt?

    You could use the action card to post a message or something like MQTT lens (chrone plugin)
  • @MennoVanGrinsven, Do you think there is a difference in speed when an arrive/leave report is sent when using Cloudmqtt vs an own hosted broker?
  • Skorpion said:
    @MennoVanGrinsven, Do you think there is a difference in speed when an arrive/leave report is sent when using Cloudmqtt vs an own hosted broker?

    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. 
  • What do i add in the Owntracks Client (Homey) 
    I can't find a good tutorial of CloudMQTT with Homey Owntracks and the iOS app. Not even on google.
  • What do i add in the Owntracks Client (Homey) 
    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?
  • keverjeroenkeverjeroen Member
    edited August 2017
    Thanks for the tutorial! Working great!

    -edit- Geofences are not working.. :(
  • Owntracks Client settings (users, geofences) have been deleted while upgrading to 1.5.0
  • Fire69Fire69 Member
    edited August 2017
    Since the Homey app is still worthless for presence detection and because since the Android 7 upgrade, wifi detection is completely f***'ed up by Google, I followed this tutorial to install the Owntracks app.
    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.
  • edited August 2017
    @Fire69 You can also use HTTP now (through the athom cloud)   :# 

    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. 


  • @Fire69 You can also use HTTP now (through the athom cloud)   :# 

    Tried that first, too much typing work with the long url's and stuff  :p
    So I just went and registered the cloudmqtt  :D

    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. 
    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 :blush:
  • @Fire69 ;
    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. 



  • edited August 2017
    Removed 
  • Fire69Fire69 Member
    edited August 2017
    OK, I'll play around with it and see what happens when I get home...
    I'll let you know when it doesn't work as expected  :D

    [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?
  • @Fire69 the username used is the userid that is used to login to the mqtt broker. I would suggest to use a normal name. That way you can use another feature better....

    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 ......

  • @Fire69 the username used is the userid that is used to login to the mqtt broker. I would suggest to use a normal name. That way you can use another feature better....

    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 ......

    Yeah, I used my real name for the broker username, but in Owntracks there is username (so the login for the broker) and Device ID.  DeviceID doesn't matter what I use? (I can use something to identify my phone for example?)
  • edited August 2017
    @Fire69
    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) 
  • Noticed I hadn't received home/away notifications for some days now.
    Went to check my settings for the OwnTracks app and they're all gone :P

    Anybody had that happen to them before?
  • Fire69 said:
    Noticed I hadn't received home/away notifications for some days now.
    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? 

  • 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? 

    MQTT host and such are gone, geofences and usernames are still there.
  • Fire69 said:
    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? 

    MQTT host and such are gone, geofences and usernames are still there.

    That's strange because that is not in my control.


  • MennoVanGrinsven said:

    That's strange because that is not in my control.

    That's not stored in your own config-file?
  • So the latest conclusion is use HTTP above MQTT?
  • So the latest conclusion is use HTTP above MQTT?

    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. 
  • kooskortekaaskooskortekaas Member
    edited March 2018
    I tried it so many times with MQTT, but every time a fail. After three days it’s gonna work!

    Now hoping it stays alive!
Sign In or Register to comment.