MattP
(Matthew Purnell)
January 10, 2018, 12:30pm
1
Hi all.
I just wanted to pass on, that the combination of Tasker and OwnTracks is largely unnecessary (to make the OwnTracks reporting more reliable) - you can configure Tasker to send the same payload as OwnTracks.
I’m not sure what MQTT server options there are - I just have my own private instance running on the same box as HASS
I still left the OwnTracks configuration within Home Assistant configuration.yaml, and just uninstalled OwnTracks and got Tasker to provide the same MQTT payload that OwnTracks was. Works perfectly - the profile fires every ten minutes when not within 50m of home.
Here is my Tasker task config, I hope the import makes sense for someone…
<TaskerData sr="" dvi="1" tv="5.0u7m">
<Task sr="task61">
<cdate>1515562308016</cdate>
<edate>1515586767693</edate>
<id>61</id>
<nme>Owntracks</nme>
<pri>100</pri>
<Action sr="act0" ve="7">
<code>37</code>
<ConditionList sr="if">
<Condition sr="c0" ve="3">
<lhs>%HOME</lhs>
<op>0</op>
<rhs>0</rhs>
</Condition>
</ConditionList>
</Action>
<Action sr="act1" ve="7">
<code>902</code>
<Int sr="arg0" val="2"/>
<Int sr="arg1" val="61"/>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
</Action>
<Action sr="act2" ve="7">
<code>590</code>
<Str sr="arg0" ve="3">%LOC</Str>
<Str sr="arg1" ve="3">,</Str>
<Int sr="arg2" val="0"/>
</Action>
<Action sr="act3" ve="7">
<code>547</code>
<Str sr="arg0" ve="3">%Payload</Str>
<Str sr="arg1" ve="3">{"_type":"location","tid":"s7","acc":30,"batt":16,"lat":%LOC1,"lon":%LOC2,"tst":%TIMES,"_cp":true}</Str>
<Int sr="arg2" val="0"/>
<Int sr="arg3" val="0"/>
<Int sr="arg4" val="0"/>
</Action>
<Action sr="act4" ve="7">
<code>163134030</code>
<Bundle sr="arg0">
<Vals sr="val">
<ClientID>S7</ClientID>
<ClientID-type>java.lang.String</ClientID-type>
<Password>#######</Password>
<Password-type>java.lang.String</Password-type>
<Payload>%Payload</Payload>
<Payload-type>java.lang.String</Payload-type>
<Port>1883</Port>
<Port-type>java.lang.String</Port-type>
<QoS>-1</QoS>
<QoS-type>java.lang.Integer</QoS-type>
<Retain>true</Retain>
<Retain-type>java.lang.Boolean</Retain-type>
<SSL>false</SSL>
<SSL-type>java.lang.Boolean</SSL-type>
<Server>mqtt.server.address</Server>
<Server-type>java.lang.String</Server-type>
<Topic>owntracks/user/s7</Topic>
<Topic-type>java.lang.String</Topic-type>
<Username>matt</Username>
<Username-type>java.lang.String</Username-type>
<com.twofortyfouram.locale.intent.extra.BLURB>MQTT.server.address:1883 => owntracks/matt/s7 QoS:0</com.twofortyfouram.locale.intent.extra.BLURB>
<com.twofortyfouram.locale.intent.extra.BLURB-type>java.lang.String</com.twofortyfouram.locale.intent.extra.BLURB-type>
<net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS>Topic Payload ClientID Password Username Port Server</net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS>
<net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS-type>java.lang.String</net.dinglisch.android.tasker.extras.VARIABLE_REPLACE_KEYS-type>
<net.dinglisch.android.tasker.subbundled>true</net.dinglisch.android.tasker.subbundled>
<net.dinglisch.android.tasker.subbundled-type>java.lang.Boolean</net.dinglisch.android.tasker.subbundled-type>
</Vals>
</Bundle>
<Str sr="arg1" ve="3">net.nosybore.mqttpublishplugin</Str>
<Str sr="arg2" ve="3">net.nosybore.mqttpublishplugin.EditActivity</Str>
<Int sr="arg3" val="0"/>
</Action>
</Task>
</TaskerData>
4 Likes
RobDYI
January 10, 2018, 8:05pm
2
Nice work., For the iphone, i used Find my iphone to do the same.
I have used sosumi to create a php program that gets the info from iFind and puts it into a MQTT feed under owntracks for HA to pickup. This might be useful to find the location / battery of your iphone when you / HA commands instead of relying on owntrack ios app or icloud device tracker. I originally put it into a command line sensor but the 1 minute scan interval kills my iphone battery. I am going to setup how many times it requests through automation based on location / battery level / …
MattP
(Matthew Purnell)
January 10, 2018, 10:18pm
3
That seems to be a great way to get it done with minimal battery usage.
I used Tasker because a lot of my automations are driven from my phone - like voice commands, connecting to my car Bluetooth, leaving work etc
Jokerigno
(Jokerigno)
February 22, 2018, 6:16pm
4
Hi,
How can I setup the variable %HOME?
Sorry but I am a total noon on Tasker.
Right now I’m using zanzito as device tracker and I want to test something else.
Thank you
MattP
(Matthew Purnell)
February 22, 2018, 8:16pm
5
Oh - you don’t need the %HOME part - you can remove that line
I had it set up so that tasker set a HOME variable when I arrived at or left the house; triggered by creating a “Location” profile. You don’t need this bit at all though.
1 Like
Jokerigno
(Jokerigno)
February 27, 2018, 3:29pm
6
Ok perfect. But this will be intresting. Can you teach me who to let this task start only when I’m NOT at home or at work?
Thank you in advance!
1 Like
You can use AutoLocation to create geofences or if you always connect to wifi you can say when you are not connected to home/work wifi. check out the profile’s section so you can get a better idea of what will work for you. You can even have it do it when your phone is connected to your car’s bluetooth. Lots of ways to do it
I am fairly new to tasker as well but starting to love it the more I get a hang of it.
1 Like
Jokerigno
(Jokerigno)
March 4, 2018, 11:39am
8
Hey, I have a strange issue.
The Tasker profile send information correctly but HA doesn’t update the sensor status.
I have to delete info in mosquitto container.
There’s a way to force update?
MattP
(Matthew Purnell)
March 4, 2018, 12:40pm
9
Did you ever have Owntracks installed?
Jokerigno
(Jokerigno)
March 4, 2018, 12:44pm
10
No. I only have setup Tasker as you suggested me.
And the the component in device.tracker.yaml
MattP
(Matthew Purnell)
March 4, 2018, 7:18pm
11
Can you please paste your Home Assistant ‘Owntracks’ configuration? I might then see what could be wrong
Do you have a software that allows you to confirm that Tasker is sending the MQTT data?
Jokerigno
(Jokerigno)
March 4, 2018, 9:28pm
12
Here’s the export of the task:
Owntracks
A1: Get Location [ Source:Any Timeout (Seconds):60 Continue Task Immediately:On Keep Tracking:Off ]
A2: Variable Split [ Name:%LOC Splitter:, Delete Base:Off ]
A3: Variable Set [ Name:%Payload To:{"_type":"location","tid":"Xiaomimi6","acc":%LOCACC,"batt":%BATT,"lat":%LOC1,"lon":%LOC2,"tst":%TIMES,"_cp":true} Recurse Variables:Off Do Maths:Off Append:Off ]
A4: MQTT Publisher [ Configuration:mosquitto.domain.it:1883 => owntracks/Marco/xiaomimi6 QoS:2 Timeout (Seconds):0 ]
MattP
(Matthew Purnell)
March 5, 2018, 1:14am
13
What’s your Home Assistant config?
Jokerigno
(Jokerigno)
March 6, 2018, 7:06am
14
Here it is:
platform: owntracks
max_gps_accuracy: 200
Sorry for the delay but I noticed that if I play around with Qos and retain flag setting the data are updated in HA. May it be related?
MattP
(Matthew Purnell)
March 6, 2018, 7:02pm
15
If your problem was to do with an MQTT message being dropped somewhere - then QOS was your fix What is MQTT Quality of Service (QoS) 0,1, & 2? – MQTT Essentials: Part 6
If you set “retain” then that becomes effectively the default setting for your MQTT sensor (Owntracks) until another ‘retain’ is sent afterward; so HASS will get multiple chances of reading it. This might not be ideal, as restarting your Home Assistant could revert to an old, inaccurate reading - resulting in unpredicatable automations on restart, and make troubleshooting hard.
Jokerigno
(Jokerigno)
March 6, 2018, 9:34pm
16
Ok. I unflagged retain message and selected QoS 0.
Let’s see.
MattP
(Matthew Purnell)
March 6, 2018, 11:39pm
17
QOS 1 or 2 is fine - seemed to have fixed your issue? - I simply left it at 0 as that was default
Jokerigno
(Jokerigno)
April 22, 2018, 8:46pm
18
Nothing changed.
I also tried another mqtt publisher in Tasker called MQTT Client (found on play store).
I can see the payload variable with the correct values. But nothing change in HA.
I don’t know what to do…
MattP
(Matthew Purnell)
April 23, 2018, 12:01am
19
OK a few theories.
I am wondering whether it is being picked up, but is not related to the user object you expect. Have you enabled your Map? (in configuration.yaml, you just add simply: ‘map:’
Once you have your Map available on the left, maybe you might see some additional devices. If you look in config/known_devices.yaml, do you see any extra devices there?
Also, I am wondering about your MQTT broker. Where is it? Is it a cloud offering? Or are you running it on the same box as your Home Assistant?
Jokerigno
(Jokerigno)
April 23, 2018, 6:27am
20
Thank you for your support.
I restarted the configuration from scratch and I saw a first update with location and battery.
But then again I can’t spend updates on the same topic.
If I connect to my local hosted mosquitto broker I can see the messages. But ha can’t handle it.