Tasker emulating OwnTracks with MQTT (without OwnTracks)

  1. can you please paste the MQTT message that your android is sending, but HASS is not accepting?

and…

  1. can you please check your config/known_devices.yaml for any devices that are similar to the host in your MQTT messages
  1. Here’s the mqtt message

Topic
owntracks/xiaomimi6/marco
Message (%payload variable set with tasker)
{"_type":“location”,“tid”:“mi6”,“acc”:%alaccuracy,“batt”:%BATT,“lat”:%allatitude,“lon”:%allongitude,“tst”:%TIMES,"_cp":true}

Please notice that I use Autolocation Plugin with tasker who generates different values so I don’t have to slip defaul %LOC variable (I choose it because it doesn’t require gps updates to send location).

Here’s my mqtt broker configuration (mqtt is running in a separate docker using toke/mosquitto image)

mqtt:
discovery: true
broker: 192.168.2.100
port: 1883
client_id: home-assistant-1
username: myuser
password: mypassword

And finally here’s my tasker setup action:

Device_tracking

  1. A1: AutoLocation Location [ Configuration:Starting Location Monitor
    Retrieve First Location: true
    Expiration Time: 60 seconds
    Interval: 60 seconds
    Update Type: Balanced Timeout (Seconds):61 ]
  2. A2: Variable Set [ Name:%Payload To:
    {"_type":“location”,“tid”:“mi6”,“acc”:%alaccuracy,“batt”:%BATT,“lat”:%allatitude,“lon”:%allongitude,“tst”:%TIME S,"_cp":true} Recurse Variables:Off Do Maths:Off Append:Off ]
  3. A3: MQTT Publisher [ Configuration:192.168.2.100:1883 => owntracks/marco/xiaomimi6 QoS:2 Timeout
    (Seconds):10 ]
  4. A4: AutoLocation Location [ Configuration:Stopping Location Monitor
    Interval: 60 seconds
    Update Type: No Power Timeout (Seconds):60 ]

I don’t know why (because I haven’t changed anything)

But suddently I found an error in log:

Mon Apr 23 2018 16:28:23 GMT+0200 (W. Europe Daylight Time)

Unable to parse payload as JSON: {"_type":“location”,“tid”:“mr”,“acc”:14.12,“batt”:20,“lat”:xxx,“lon”:xxx,“tst”:1524429673,}

That JSON shouldn’t have that last comma. I wonder if that is the main issue you have? The expect that a comma indicates that another variable:value pair should follow.

Also; the owntracks MQTT should be owntracks/USER/DEVICE. So try owntracks/marco/xiaomimi6

Uhm,

that’s weird.

As you may see in my tasker setting there’s no comma :thinking:

{"_type":“location”,“tid”:“mi6”,“acc”:%alaccuracy,“batt”:%BATT,“lat”:%allatitude,“lon”:%allongitude,“tst”:%TIME S,"_cp":true}

And also: my mqtt setting is owntracks/marco/xiaomimi6 yet. May I’m missing something?

Ok must have been a typo a few posts up (post 22); thats why I thought your topic was the other way around:

And yeah that is odd, that the comma has shown up in the HASS error…?

Your ‘tid’ value should be xiaomimi6, on mine it is my devicename:

{"_type":"location","tid":"s7","acc":44,"lat":###,"lon":###,"tst":1524561411,"_cp":"true"}

i got this to post as payload but home assistant is not picking it up:
{"_type":"location","acc":.%LOCACC,"alt":%LOCALT",batt":%BATT,"lat":%LOC1,"lon":%LOC2,"t":"u","tid":"ke","tst":%TIMES,"vac":0,"vel":%LOCSPD}

any idea what i’m doing wrong?

nvm had a typo
{"_type":"location","acc":.%LOCACC,"alt":%LOCALT",batt":%BATT,"lat":%LOC1,"lon":%LOC2,"t":"u","tid":"ke","tst":%TIMES,"vac":0,"vel":%LOCSPD}

",batt":%

should be

{"_type":"location","acc":.%LOCACC,"alt":%LOCALT,"batt":%BATT,"lat":%LOC1,"lon":%LOC2,"t":"u","tid":"ke","tst":%TIMES,"vac":0,"vel":%LOCSPD}

,"batt":%

meh, still doesn’t work. i got the exact same payload as owntracks.

I’m sorry to hear you can’t get it working.

It always worked for me, but I’ve abandoned it long since the Google location sharing approach became reliable. I’d provide a link but I’m on my phone…