Tryig to set up HA with Owntracks and MQTT on android phone

Guys

I’m a complete newbie on this and am using lots of your guys scripts and knowledge to get things up and running

I have used the code in the components area without any errors but I cant see to get any output or info into HA.

I know my MQTT is working as have send messages to the pi via HA but clearly am missing some coding or configuration of owntracks on my android phone to get the device from the phone populating HA

Any one managed to get this working. I have 4 kids and want to get this tracking software set up on their phones to use for safety and home automation

I’ve been using Owntracks and Mosquitto MQTT for about a year now. It works fairly well but you might also want to look at Zanzito too since it may offer more functionality, especially down the road.

Best way for us to help you out here is for you to post up your config files. Either through github or by using the pre-formatted text option (icon looks like “< />” above).

1 Like

I haven’t got very far on this at all so far.

I was reading the https://home-assistant.io/getting-started/presence-detection/ and thought it seems a good idea. So far I have downloaded the owntracks app on my mobile , but not sure how to configure it . But the rest of the home assistant site doesn’t really help me put this all together

In my yaml file so far all I have is

device_tracker:

  • platform: owntracks

mqtt:
broker: my ip address
port: 1883
username: mydetails
password my details

I used BruH video to set this part up and test it and I know mqtt is good

I have also set up a zone

zone:
name: Home
latitude: my details
longitude: my details
radius: 100

As I have said , I am very new to this and have just copied a load of code from here and you tube tutorials to get it up and running.

Im my HA home page nothing appears at this point but when I check the code all seems good

If you go to where your Home-Assistant files are stored and open known_devices.yaml do your devices show up there?

I have no know_devices.yaml file.

I have discovery up and running and they haven’t appeared on the home page. I do have a number of different *.conf files for other devices like by tv and hue lights but nothing for this owntracks device. I’m still in testing at the moment so I have opened up the port forwarding for the mqtt broker but my device is sat on my internal network

I have the connect mode set to private MQTT and the host is my pi ip address and port 1883 and in identification I have put the username and password I set up on the pi , device ID I have put my name and tracker ID is blank.

Being a newbie I’m trying to piece this all together as I go along but I’m very raw with this

Well I’m no expert on this stuff either but I will help where I can, usually with just the basic checks. So let’s start there.

Being a newbie I’m going to assume that you don’t have iptables or firewalld running on your Pi/MQTT server. Generally speaking if you didn’t set it up it won’t be running.

First question is, after setting up the configuration file did you restart the Home Assistant service? It seems like a silly question but I can’t tell you how many “problems” I’ve spent time trying to figure out only to realize I either never saved the config or didn’t actually restart the service.

If you open OwnTracks and click the menu icon, at the very bottom it should have an option to view the status. (Sorry, doing this from memory since I don’t currently have OT installed on my phone). Does it show as connected?

For tracker ID just throw in a 2 letter system (like initials) for ease of following multiple devices from OT app.

Sounds like you’ve got it set up to run at home. Are you running a DDNS service? afraid.org, duckdns, etc etc etc.?

You should be able to hit the hamburger (3 dashes upper left corner) and go to the map on your HA webpage and see your devices, when they are away. I’ve never seen mine when I’m local on my LAN other than telling me I’m in the specific ‘Home’ zone which appears on the main dashboard.

Hi Paul,
I’ve been starting with HA recently and this video helped me setting up owntracks with cloudmqtt:

There are some other helpful tutorials around there…

1 Like

Hi @forsquirel

At the moment I have registered duckdns but haven’t set up any port forwarding at home so not tested that far. as I was sat at home working yesterday I was hoping I could test from being inside my internal network. But im not even seeing a map on my HA set up

Im using a raspberry pi 3 running my home assistant install will MQTT broker set up on there

I will take a look at the tutorial later today as im in my office today and see if I can get it running

No map option on the left hand side to click?
No map at all?
Or just a patchy map?

In Chrome it works perfectly for me, but occasionally in Firefox i get a patchy map.
No map option at all - perhaps something is wrong with the HA install? The Map component is integrated, short of a reinstall of HA, I dont know how else to resolve that

As for the general functionality, take a look at this thread, and the links inside it

First thing Id do, is get your external DNS sorted, port forward in your home router, and then configure the owntracks app in your phone with the relevant details.
Once youve done that, the known_devices.yaml file should populate itself with your phones details providing youve got mqtt config right

If not, post any changes you made to any configs, any errors in your log, and the status of your owntracks app and we’ll see what we can do from there

Good luck :slight_smile:

@elPaulio @forsquirel @oembob

So guys im nearly there I think

I used the BruH video above and have set up my phone and my HA code below

device_tracker:

  • platform: owntracks
    max_gps_accuracy: 200

mqtt:
broker: m20.cloudmqtt.com
port: 18014
client_id: HA-1
keepalive: 60
username: MY Username
password: MY PASSWORD

now at the top of my HA Console it does show im not at home and the details I was expecting so thank you all (like a sensor switch)

However , I want to take this one step further, I have seen some clips with actually maps appear in the main console , what do I need to add to my scrip to add that

Thanks for all your time

This?

Yes that is exactly what I am after, I just need to yaml code for my product not the one in the example

best way to learn, code it. troubleshoot it until it works. if not, post here, and we’ll sort it out :slight_smile:

so im not getting any errors as when loading up but not getting any map showing up on the home page instead I get is Generic Camera (Error loading image) . All I have done is remove the demo.paulus. in the device tracker and enter owntracks (see the code below) but im guessing this is the bit that is wrong and it cant get the map image to display

I already have a video camera set up in the house so it forms part of this code

camera:
- platform: arlo
username: MY USERNAME
password: !secret Arlo_Password
- platform: generic
still_image_url: https://maps.googleapis.com/maps/api/staticmap?center={{ states.device_tracker.owntracks.attributes.latitude }},{{ states.device_tracker.owntracks.attributes.longitude }}&zoom=13&size=500x500&maptype=roadmap&markers=color:blue%7Clabel:P%7C{{ states.device_tracker.owntracks.attributes.latitude }},{{ states.device_tracker.owntracks.attributes.longitude }}
limit_refetch_to_url_change: true

don’t worry I manage to sort it, by changing the device tracker to the correct entity id I have sorted it

thanks for the advise

however @elPaulio as always want to take it to the next level

So now it shows my location at work, but I want to add the tracker to multiple devices and add zones like work and school.

The little bit of code I found on the site is a little lacking in detail, is this something you have done

Yeah, so all you need to do is add the owntracks app to whatever device, and when it checks in with your mqtt broker, your known_devices will get another few lines with a new device type in it. That will then show up as another entity in your home assistant.
For simplicity, you can use the same mqtt settings as you have in your first device which you have already set up

Rinse and repeat for all devices you want to show in HA

As for zones, in your YAML, you can use this

Note that, any devices that are in the HOME zone, will not show on the map. However, if you make a card to go on your home assistant view, you can list each device and its status. This will show ‘Home’ if its in the Home zone

brilliant I have got one of my children to add install owntracks and I can see his entry at the top of the HA screen at home so I know it has him but wondered will his image appear on the map when away from home without me adding another line in the yaml file for his device entity, like the one below for my device

still_image_url: https://maps.googleapis.com/maps/api/staticmap?center={{ states.device_tracker.owntracks.attributes.latitude }},{{ states.device_tracker.owntracks.attributes.longitude }}&zoom=13&size=500x500&maptype=roadmap&markers=color:blue%7Clabel:P%7C{{ states.device_tracker.owntracks.attributes.latitude }},{{ states.device_tracker.owntracks.attributes.longitude }}

I would assuming adding an duplicate entry to the above would add a 2nd map image not just put his location on my map ?

You assume correct…

You probably want this :slight_smile:

1 Like