Owntracks forced updates

Owntracks on Android never reflects accurately where I am on home assistant, owntracks is on cloud mqtt and my switches are on mosquitto, bridge is working because I can see published topics from my switches on cloud mqtt. How can one force owntracks to send location to homeassistant, say, via automation?

You can publish a “reportLocation” command to the device’s cmd subtopic. Give it a try and see how reliably works for you.

https://owntracks.org/booklet/tech/json/#_typecmd

I did this today it works great.

Topic: ‘owntracks/user/device/cmd’
Payload: ‘{"_type":“cmd”,“action”:“reportLocation”}’

When my phone connects to a new wifi or exactly 5 and 10 minutes after disconnecting to wifi i use a force update. It helps ensure the home and away is more promptly reported. I use tasker app for this.

I have done so, it does send something to cloudmqtt but it does not seem to result in anything, this is what I see in Cloudmqtt websockets UI:

owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation", "batt": %BATT}
owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation", "batt": %BATT}
owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation", "batt": %BATT}
owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation", "batt": %BATT}
owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation", "batt": %BATT}

from this config:

  - alias: Refresh Owntracks
    trigger:
      platform: time
      seconds: '/5'
    action:
      - service: mqtt.publish
        data:
          topic: "owntracks/Caswell/cn_hp10/cmd"
          payload_template: '{"_type": "cmd","action": "reportLocation", "batt": %BATT}' 

It’s case sensitive Caswell vs caswell.

Try without the batt part. The batt part doesn’t make sense.

thanks, it now shows this:

owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation"}
owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation"}
owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation"}
owntracks/Caswell/cn_hp10/cmd
{"_type": "cmd","action": "reportLocation"}

should I perhaps have a sub in my mosquito to force it to bring it in to HA

Get mqtt dash on your cellphone.
Connect to the cloud mqtt broker.
Subscribe to
owntracks/Caswell/cn_hp10/cmd
and
owntracks/Caswell/cn_hp10

When you force update from h.a. you should see
{"_type": “cmd”,“action”: “reportLocation”} on the cmd topic. This tells you that you are sending the MQTT command properly.

Then you should see a reply in owntracks on the phone on the other topic with the location on the other topic.

Thanks, I did the subscription, it shows location, but it does not translate to an HA update, I read somewhere that the accuracy parameter should be relaxed, will try the raspberry pi zero W Bluetooth beacon solution.

It doesn’t update in the gui if it’s already up to date.
I find combining owntracks with the mac address (for local ping) does a good job of tracking our phones.
I haven’t set an accuracy parameter.

It’s always showing “home” I’m at work now, but alas, HA is still showing “home”, will have to find another solution.

Did you define the zones in the yaml or did you define them in owntracks or both?

When you restart ha you lose the owntracks defined zones unless you click regions -> three dots -> publish way points.