Owntracks - Home/Not Home issue

Hi all,

Bit of a strange one here that I cant work out, looking to see if anyone else has the same issue or can help diagnose this problem.

I am using Owntracks on an iphone to publish my location via MQTT to HA. It works great 99% of the time but ive started to notice an issue recently where by it stops working. The only changes I have made in the last 6 months are upgrading HA to the latest version. Other than that I haven’t made any config changes in the last 6 months.

I have a zone setup in HA that surrounds my road and also a zone within owntracks as per the HA documentation. No issue here this works great.

The issue lies that all of a sudden after an undermined period that my presence will stop updating in home assistant. Even if I manually publish my location via own tracks, HA still sees me as being at home!

I have done some testing by sending a manual MQTT command via putty to the MQTT server with a GPS location thats in a totally different country from where I am. I send this command and then look at the log file thats flashing past the screen on HA and I get the following result

As you can see HA is getting the MQTT message so that’s good! But as you can see it seems to think i’m still inside the region defined by HA. I’m definitely not as I am UK based and the GPS coordinates I have in my test MQTT message are based somewhere in the USA so i’m definitely not inside my home region :stuck_out_tongue:

The problem goes away if I restart home assistant and it starts working fine again. Own tracks starts working again and using my test MQTT message also works and puts me as away from home.

Has anyone else seen this behavior or knows why its happening?

Id like to get it resolved as I use my presence location to turn off lights when I leave/arrive from home. I dont want to keep having to restart HA to resolve the issue.

Hi,

I had to turn off webhooks to get it to work.
Can you share your settings in configuration.yaml?

Hi,

My configuration is spread over multiple files, its not all in the configuration.yaml

Is there a specific part you are looking to see? That way I can send you what you need.

Id also like to point out that tracking with owntracks is working just fine.

It just randomly stops working all of a sudden and thinks im still in the home zone even when it has been sent Coordinates saying otherwise.

are you saying it doesn’t update your location when you are home? or when you leave?

It works fine for a period of time then stops working all of a sudden

Its when I leave home, it will not mark me as “away from home”.

As you can see I manually send a MQTT message to the MQTT server to tell it im away from home. I did this just to rule out the own tracks app being the problem (which it isnt). You can see in the screenshot I provided that even though those GPS coordinates put me outside of the HA home zone it still thinks that i’m within the zone and will not update its status.

A restart of the HA server is the only way I have found to fix the issue. It will then start to detect I am outside of the zone again. But this will only last so long before it stops working again and I have to repeat.

Are you using any other device trackers?

Nope just owntracks

The built in MQTT broker is quite limited. Have you tried setting up Mosquitto, or (if you don’t otherwise use MQTT on your own network) using a free CloudMQTT instance?

Hi all,

Apologies, I’m either not explaining my issue very well or my messages aren’t being ready carefully enough.

There is nothing wrong with MQTT or the own tracks app. The issue here lies with HA.

If you look at the screenshot I posted in my first post, you can clearly see the MQTT message makes it to home assistant just fine. Take a look at the last line, it says that it is ignoring the location message as the coordinates it just received thinks they are still within my HA home region (They are definitely not!), so it won’t update my location status as it thinks I haven’t moved.

Without revealing where I live by posting coordinates, my location is situated within London, UK. The home zone I have setup in HA surrounds my house. The coordinates displayed in my example image above are for some randomly chosen location in Antartica (This would definitely put me outside my HA home region).

The reason I am sending manual MQTT message to HA to test this is because I don’t want to have to keep walking out of my house to test this. You can send MQTT messages containing location data to update the device tracking component. For example -

mosquitto_pub -h m20.cloudmqtt.com -p 19621 -u ha -P #Passwordremoved -t "owntracks/phones/Ross's iPhone" -m '{"batt":22,"lon":51.40227085449863,"acc":65,"p":100.9838790893555,"vac":10,"lat":-80.130045,"t":"u","conn":"w","tst":1492169802,"alt":51,"_type":"location","tid":"ip"}'

When this issue occurs, I restart home assistant and then send the MQTT message above again to make HA think I have moved outside my home region and it works successfully. It sets me as away from home.

So what I’m trying to work out is, is why HA randomly starts thinking that any GPS coordinate that it receives is considered within my home zone. A restart is the only way to get it working again I have found so far.

1 Like

Hi Ross,
I can’t help with your particular issue, but I had weird behaviours with Owntracks and never found a way to make it work reliably. I tried the “debug” strategy, logged all the MQTT messages, reinstalled owntracks multiple times, reconfigured the home zone, with no success until I switched to Hassio and the Mosquitto Broker add-on. Without any other change it started working perfectly and never missed a single in/out switch.

You are talking about “HA regions” which surprised me. Owntracks has own regions which needs to be setup. Furthermore owntracks tracks your position and sends notifications about leaving and entering of regions. It looks like your region is not properly defined. Could you provide the settings of your iphone app?

PS. The configured region at you iPhone app must be shared and called “Home”.

I have the zones setup fine in own tracks too

As I say this works fine 99% of the time, then all of a sudden HA seems to think that wherever I am based on the Coordinates that Owntracks sends to my MQTT server which then passes it onto my HA server that I’m still within the home region when i know I’m not. I could be miles away from home and HA still thinks I’m in my home region.

I have even manually published my location from the Owntracks app by pressing the manual update button, HA receives the MQTT message but still says “nope, your still in the home region I’m not updating” not that exact message but thats pretty much what happens.

Can you tell me how I export my Owntracks settings?

Hmm… I will check the involved applications. One of the applications calculates the transition event (region enter, region leave). The transition is not calculated by home assistant for sure. Home assistant just react to a MQTT message called “transition” (JSON - OwnTracks Booklet). If HA misses the transition event it’s lost in space. Additional location updates won’t help then. Your mosquitto_pub isn’t sufficient, too. You could publish a transition event. This would help! Owntracks does not produce a new transition probably if you call “publish location”.

This fix could be intresting, too: https://github.com/home-assistant/home-assistant/pull/9338

I think I’m having the same problem. If as you say HA only updates the zone location if it gets a “leave” transition, then this seems hopelessly bad.

I imaging almost every time I leave my home, my OwnTracks will disconnect from my broker first (leaving my home wifi) and then be unable to send the leave transition before acquiring a new connection over cellular data.

Thus, I will always be “home”, unless another transition event (say at work) overrides this.

HA SHOULD use the GPS coordinates to decide that the tracker has indeed left the region, if those coordinates are sufficiently outside of the HA configured zone.

What should HA do when the OwnTracks region is not also a zone in HA? I don’t know. What is the current behavior? Is the tracked device only allowed to be in one region/zone at a time? From the docs it appears that or a region that is not a zone, HA will instead create a new tracker device_tracker.beacon_<region_name> and update that trackers location to the location in the “enter” event. (does it then keep updating that tracker location with new gps locations as long as the “device” (phone) is “in the region” (keys)? This is unclear to me.)

Any clarification and ideas on these issues would be very helpful. Thanks.