Location and Presence for Homey (formally Owntracks client)
With this app you can enhance your Homey with presence detection based on geofences. This app is based on the Owntracks specification and available apps for Android and iPhone.
With the Owntracks app on your phone, you can define regions / geofences. These geofences are coordinates and a radius. These can be your home, workplace or any other place. Based on your username and geofence you can define triggers for Homey (as an example John leaves work and a trigger fires on Homey to increase the temperature at home so its nice and warm when he arrives home).
The Owntracks app on your phone needs to communicate with Homey. There are two ways to setup this communication:
- using the Athom cloud to communicate through HTTPS
- using MQTT to communicate to a MQTT broker
The advantages of using MQTT over HTTPS are:
- You are not using Athom cloud
- MQTT is a energy friendly protocol
- MQTT has persistence
- Other applications besides homey can subscribe to the locations messages also.
- You can push way points from homey to connected phones (to sync the fences)
Using HTTPS is the easiest way to start with. There is no need to setup a seperate broker. So
this guide will focus on setting up HTTPS.
When using HTTPS, you have to add users that are allowed to send events to the homey app. To do this, go to the apps settings page and go to the second button (Change users). Add the user name that you want to give access by entering the name in the empty field below the already known users. Press the “+” button to add the user.
After you have added the user, the user will show up in the user list and it will have a token generated that is used in the phone app to allow receiving of the events:
You can remove a user by pressing the “-” button. The “#” button can be used to generate a new token when you think the id has been comprimised.
In the app on your phone, you should select HTTP as connection:
Then select HOST:
The URL you have to enter here is as follows:
https://<cloudid>.connect.athom.com/api/app/nl.scanno.owntracks/events/?token=<tokenid from user>where <cloudid> is the Athom Cloud ID of your homey that you can find in Settings/System.
The tokenid is the id that is generated when you added the user.
In case you get a 401 error, then you need to adjust a small setting. The 401 is generated because the Owntracks app on your phone (at least on Android) expects HTTP authentication. Since it is not used on Homey that setting needs to be disabled. Go to Preferences/Configuration Management. There select the menu and select editor. And fill out the key and value field as shown in the picture below:
Using the Athom Cloud is the easiest way of getting started with owntracks. If you are more skilled you can also directly connect to your Homey by port forwarding. Keep in mind that homey itself does not support TLS/SSL. If you want to have a secured session, you need to use a proxy.
In addtion you can use a MQTT broker:
Setting up a MQTT brokers can be done in several ways. You can either use a broker on the internet (there are MQTT hosting services) or run a MQTT broker yourself.
There is a MQTT Broker app for Homey available in the App store.
For setting up a private MQTT broker in the cloud with CloudMQTT see the tutorial below:
- You need to enter minimal accuracy to 150 in the tweak section. When this value is not set, triggers will not fire.
- When first started, the app will send two notification about files not able to be read. This is “normal” because those files have not been created yet. This is nothing to worry about. As soon as there are users en geofences added, this problem is solved.