Homey Community Forum

Location and Presence (Owntracks) - HowTo

tools
app

#1

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:

https://forum.athom.com/discussion/2810/use-cloudmqtt-as-a-broker-for-owntracks-or-mqtt-app

Known issues:

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

Presence detection recommensation
Verwendung von Logic in Flows
#2

Goedemorgen,

Ik heb bovenstaande al een hele tijd draaien, en dit werkt eigenlijk altijd vlekkeloos.

Tot de nieuwe update van Owntracks naar 2.2.1, nu krijg ik namelijk de hele dag meldingen dat de MQTT broker onbereikbaar is, en 5 seconde later weer dat hij bereikbaar is.

image

Heeft iemand ook dit probleem? Of een oplossing? Ik heb alle instellingen nagelopen, en zowel de owntrack client als mn homey gereboot.


#3

Als een tijdelijke oplossing, kun je de notificaties voor de owntracks app uitzetten.
Probleem kan veroorzaakt worden door het feit dat de library die gebruikt wordt voor MQTT communicatie een probleem veroorzaakt.

Maak je toevallig gebruik van CloudMQTT? De enige meldingen die ik tot op heden gehad heb, waren van gebruikers die CloudMQTT als broker gebruiken.


#4

Hoi Menno,

Heb ze inderdaad nu uitgeschakeld, maar dan krijg ik ook geen meldingen wie er thuis komt.

Ik maak inderdaad gebruik van cloudmqtt, maar dat is voorheen altijd goed gegaan.

Patrick


#5

As we are in the English part of the forums plz keep it in English.


#6

My Owntracks is not working lately. The fence stays empty:

While the fence is there. And if I open my mobile app, the Owntracks client detects me being in the Fence (marked red).

The log files shows:

20190104-11:21:35 Broker State: CONNECTED
20190104-11:21:36 OnMessage called
20190104-11:21:36 received '{"t":"t","tst":1546594305,"acc":65,"_type":"location","alt":-3,"lon":5.0360418962593254,"vac":10,"lat":52.460436814600506,"batt":48,"conn":"w","tid":"qx"}' on 'owntracks/camille/camille'
20190104-11:21:36 We have received a location message
20190104-11:21:36 Set battery percentage for camille to 48%
20190104-11:21:36 OnMessage called
20190104-11:21:36 received '{"tst":1546592798,"acc":65,"_type":"location","alt":-2,"lon":4.8871961774959001,"vac":10,"p":103.69418334960938,"lat":52.404296875,"batt":98,"conn":"w","tid":"EM"}' on 'owntracks/esther/esther'
20190104-11:21:36 We have received a location message
20190104-11:21:36 Set battery percentage for esther to 98%

#7

If those logs are from the situation where you should be inside a fence, then check the phone app. The app on your phone thinks you are not inside a fence.


#8

When I open the app, it marks the fence where I’m in red. So the app is right.

It’s Homey that forgets that I’m in this fence somehow


#9

Have not seen that before. The only possibility is that the owntracks on your phone is not sending the transistion messages correctly. Please check the logging to see if you see transition messages with the name of the fence included.


#10

I’ve followed the guide, made a user in the Homey app, looked up my cloudid and entered

https://<cloudid>.connect.athom.com/api/app/nl.scanno.owntracks/events/?token=<tokenid from user>

with my codes in the Owntracks app for Android under Host. Looked easy enough, but I don’t see anything in the Homey app. Lon & Lat both say undefined. Do I need to do anything with Identication in Owntracks?

If I enter the complete URL in a browser I get this:

{“code”:404,“error”:“not_found”,“error_description”:“Not found: GET /api/app/nl.scanno.owntracks/events/”}


#11

Homey v1.5.x or Homey v2.0?


#12

2.0 … Funny thing is that on 1.5 presence didn’t work on my wife’s phone, but fine in mine. Now on 2.0, she’s spot on and my never registers anything (new phone though). Everything is set correctly, but nothing comes through so I’m looking for alternatives.

Also, when I try to create a geofence, should it pick up my GPS coordinates? GPS is working, checked with GPS info and nav software, but ‘Presence & Location’ says 0 0 & 0 for Lon, Lat and Radius. The Homey app has access to my location in Android, but it looks like it’s not registering anything.


#13

Are you sure there is no typo? If the connection is made, then the lon/lat will be shown next to the user.
If you define regions in the app on your phone, then they get created also on homey.
Oh and the error is correct because the browser does a GET while the app wants a POST.

What error do you see in status?. If its a 401, then you need to disable a setting in configuration management (select the menu and then editor) Then the key/value : auth / false

@Raytestrak let me know if that solves the problem. Added a picture and description also to the first post.


#14

Thanks, that’s was it. Now to see if it works. I’ve added two flows, one to mark my presence as away based on this and (surprise surprise) to mark my presence as home. That way I don’t have to change all my flows.


#15

You might want to start in “move monitoring” mode. Your phone will use the GPS and you get a more accurate location. When confirmed working, you can use “significant change”. But that might need some tweaking.

And set minimal accuracy to something like 150 meters (homey app)…


#16

Hi,. I was playing around with your app

I get a 417 error in owntracks app.

any tips?


#17

Homey v1.5 or 2.0?
If v2. 0 then probably your homey lost its cloud connection.

If v1. 5.x then in the url you need to replace connect with homey.


#18

I stoll have 1.5
Did what you said, it changed the error to a 500 error… Http:s.

And 2.0 will break it? :o


#19

What error do you see textual besides the 500.
Homey v2 is actually better with regards to this app. On homey v2 it is possible to send a response back. Now it is possible to get almost the same functionality with https as with MQTT.

Right now you will see (if on homey v2) other household memebers in the app on your phone.


#20

O. The own track only endpoint 500 error