Tasker + Custom Device Tracker

Hey I am using trying to use Tasker to mimic GPSLogger to send location data back to HA with HTTP Post command:
Tasker HTTP POST Command
Server:Port = https://ha.url.com
Path = /api/webhook/xxxxxxxxxxxxxxxxxxxxxx
Data/File = latitude=%allatitude&longitude=%allongitude&device=pixel3&battery=%BATT
Content Type = application/x-www-form-urlencoded

I keep getting a 422 response code and no bueno on getting a device_tracker entity. Anybody got any ideas. I can get this https://community.home-assistant.io/t/tutorial-using-the-new-auth-system-with-tasker/82423 to create a entity correctly under HA but Google Travel Time never changes, it either stays at 0 mins or is Unknown.

Are you set on using http? You could just send back data via MQTT.

Dont take this the wrong way but I dont understand the reasoning behind MQTT. It dosen’t make sense to me to use a Sensor->Broker->HA when I can just go Sensor->HA. I have really never understood the benefits to using a MQTT broker.? I try to keep it KISS

No offense taken.

MQTT just works with multiple clients/devices and makes more sense than using HTTP. I was just offering that in case you were already using MQTT.

I couldn’t get this to work with GPSLogger, either. But I managed to do it with OwnTracks component.

Here’s my HTTP POST configuration in Tasker:

Server:Port = https://my.server.com
Path = /api/webhook/xxxxxxxxxxxxxxxxxxxxxx
Data/File = {"_type":"location","tid":"lc","acc":%LOCACC,"batt":"%BATT","lat":"%LOC1","lon":"%LOC2","t":"u","tst":"%LOCTMS","vel":"%LOCSPD","alt":"%LOCALT","topic":"owntracks/username/devicename"}
Content Type = application/json

Tasker’s HTTP Post seems to be having some issues with handling responses, I have used RESTtask for Tasker plugin and it works. I’m on the cloud and it also works fine with GPSLogger webhook.
I’m not really tracking my location and I do not have any location/zone based automations yet, so I cannot say how accurate is tasker as compared to GPSLogger app.

Care to share the tasker.xml?
edit:
and the automation?
edit2:

Finaly did it - took me 2 hours

owntracks_pub.tsk.xml

<TaskerData sr="" dvi="1" tv="5.7.1">
	<Task sr="task13">
		<cdate>1556968304770</cdate>
		<edate>1556976574054</edate>
		<id>13</id>
		<nme>owntracks_pub</nme>
		<pri>100</pri>
		<Action sr="act0" ve="7">
			<code>902</code>
			<se>false</se>
			<Int sr="arg0" val="0"/>
			<Int sr="arg1" val="10"/>
			<Int sr="arg2" val="0"/>
			<Int sr="arg3" val="0"/>
		</Action>
		<Action sr="act1" ve="7">
			<code>590</code>
			<Str sr="arg0" ve="3">%LOCN</Str>
			<Str sr="arg1" ve="3">,</Str>
			<Int sr="arg2" val="0"/>
		</Action>
		<Action sr="act2" ve="7">
			<code>116</code>
			<Str sr="arg0" ve="3">https://yoururl.xxy.com</Str>
			<Str sr="arg1" ve="3">/api/webhook/d000000owntrackswebhookxyz</Str>
			<Str sr="arg2" ve="3">{"_type":"location","tid":"lc","acc":%LOCACC,"batt":"%BATT","lat":"%LOCN1","lon":"%LOCN2","t":"u","tst":"%LOCTMS","vel":"%LOCSPD","alt":"%LOCALT","topic":"owntracks/USER/NAME"}</Str>
			<Str sr="arg3" ve="3"/>
			<Str sr="arg4" ve="3"/>
			<Int sr="arg5" val="10"/>
			<Str sr="arg6" ve="3">application/json</Str>
			<Str sr="arg7" ve="3"/>
			<Int sr="arg8" val="0"/>
		</Action>
	</Task>
</TaskerData>

Create an Owntracks integration - past the webhook ID to <Str sr="arg1" ve="3">/api/webhook/ and you can change the "topic":"owntracks/USER/NAME"} part.
Now I only need a nice trigger.

Your task looks almost the same as mine. However, it looks that you are using GPS as source in “Get Location”. I think the you should then get the coordinates from %LOC variable (as %LOCN stands for network location).

I have set Tasker to run this task whenever I enter or leave my home (Event: Wifi Connected), area around my home or work (Cell Near) and my car (BT Connected).

%LOC doesnt get me any output at all
I ll just delete the GPS surce (better for the battery i overread)

Locaton change would be a nice trigger…

I used RESTask for Tasker for a while but had problems with it. Sometimes it stopped working and wouldn’t send any requests until Tasker had been restarted. I couldn’t figure out what was causing this. But it seems that the plugin has not been updated since 2015.

Sorry, I’ve been away for some time… I have noticed the same problem with RESTask but since it is not a top priority for me I did not really looked into it - maybe another tasker automation that would kill it and restart (if that’s possible) every hour or so would make it more reliable?

i use trasker as a device tracker using http post.

i used this post here to communicate with h.a.

maybe that will help u

I’m not able to get this to work for some reason - I get a device_tracker set up in Hassio but only the gps flag comes through and none of the data, so the location isn’t correctly reported. It looks like all the variables are set correctly (I adjusted a few to integers as indicated by the Owntracks documentation but this didn’t help). Any idea what I might be doing incorrectly?