OwnTracks & Automation

Background:
I setup mosquitto and verified that it is running and able to see my devices. I’m also able to view battery information.

Issue:
I setup an automation based on @brusche OwnTracks Refresh example. It is supposed to refresh the location and battery information every 15 minutes, but it does not seem to work. There is also a button to do a manual refresh, but my battery information doesn’t refresh using that as well. The only time it updates my info is when i enter a zone. Any ideas?

Configs:
refresh_devices.yaml

 alias: "Device Refresh"
 sequence:
   - service: mqtt.publish
     data:
       topic: "owntracks/vbm/vbm6splus/cmd"
       payload_template: '{"_type":"cmd","action":"reportLocation"}'
   - service: mqtt.publish
     data:
       topic: "owntracks/sdm/iphone/cmd"
       payload_template: '{"_type":"cmd","action":"reportLocation"}'

My automation script set to run every 5 min:

alias: "Owntracks Refresh"
trigger:
  - platform: time
    minutes: '/5'
    seconds: 0
action:
service: script.refresh_devices

I removed my commented out my mosquitto config to disable the ACL file in case that was the issue, but it still doesn’t update. I see a change in HA when i manually publish my location using the OwnTracks app on my iPhone or if i enter or exit a zone (from my configuration.yaml file).

Is there something on the owntracks ios app i need to enable for it to receive the messages? is there somewhere i can test to make sure my device is seeing the publications from HA?

Have you enabled the allow remote commands option in the owntracks app?

I was looking for that option but I don’t see where you enable that. I thought it was already subscribed to that or am I mistaken?

I think the option is in preferences -> advanced -> Remote Commands (make sure it’s enabled). Not sure what the default state is, though. If it’s not that, I’d check your MQTT sub/pub topics and make sure you don’t have an extra slash or something. Hope you get it working!

Ok I looked everywhere on the IOS app where I can modify any preferences. The only way i found where I can enable cmd: true is by exporting my current otrc file, modifying it and then re-importing it. so far it is working now. If anyone has been able to find where to modify preferences please let me know.

Well I may just go back to iCloud monitoring and live with the notifications about someone tracking me every time I restart HA. iPhone just doesn’t play nice with owntracks. It doesn’t reliably update locations and other data the way I would like. Maybe my next phone should just be an android.

I’m not sure is relevant to your problem, but I also have a very poor experience with OwnTracks on iPhone 5c. I can reproduce a bug almost daily but I couldn’t find any help yet from the community yet, nor a way to troubleshoot this.

Basically, from MQTT and HA perspective all is good, and even OwnTracks app seems reacting ok to region enter/exit events (I get push notification at the right time and place), but the actual message gets published into the MQTT topic only when I bring the application in foreground, hence invalidating the whole automation process.

I can can reproduce this with 50% accuracy more or less, i.e. one time works and one time doesn’t. I wonder if it’s something related with my iPhone version or if it’s affecting every iOS installation. Personally I’m really looking forward to drop OwnTracks at all and just use HA mobile app (still waiting for the beta so I couldn’t test it yet)

Yes I would like to get my hands on the iOS beta as well. I created an otrc file last night and it does seem to be a little better but still not automation worthy.

I can confirm it works BUT iPhone needs to be on and Owntracks needs to be active AND foreground. Does anyone have this working otherwise?

Kman

I do get the updates but yes OwnTracks needs to be active and in the foreground. It really does not work otherwise unless i setup regions on the app. also, i was able to get the steps counter up and running, but again it needs to be in the foreground or it will never update on HA. really useless IMO.

ok an update. I added qos: 2 to my sensor file and the next time owntracks woke up, it updated everything. still not instantaneous, but it works.

Are you saying that you have Owntracks in the background responding when it feels like doing so. If that is case are you sure it’s the automation triggering it or just Owntracks doing its thing. To be sure put it in manual mode and see if it responds. Mine will respond in manual mode when I send a reportLocation CMD but again app needs to be foreground and open etc.

Ok so adding QoS to my sensor file did NOT work. However the following setup worked every time…

sensor file:

- platform: mqtt
  state_topic: "owntracks/user/iphone/step"
  name: "Vince Step Counter"
  value_template: "{{ value_json.steps }}"

script file:

- service: mqtt.publish
  data:
    topic: "owntracks/user/iphone/cmd"
    payload_template: '{"_type":"cmd","action":"reportSteps"}'
    qos: 2

Before the only time it was working was when I called the script and I had OwnTracks running in the foreground at the same time the script was called. Now, when i call the script and OwnTracks is running in the background, it will report my steps as soon as i switch the OwnTracks app to the foreground. Also, if it is running in the background, I can confirm without a doubt that when OwnTracks “wakes up” it reports the steps as well.I just don’t know the “wake” interval for the app.

Yes but again this relies on having Owntracks open and on the foreground. As far as I have tested it does nothing until it becomes the foreground app and you’ve confirmed that. It’s almost kind of pointless, or at least for my use it is. If it responded whilst in the background it would have been very useful.