Owntracks Battery Tracker & MQTT

Hi All,

I am really starting to get the hang of HA until I have now created a local MQTT service and trying to do more with it.

Coding and development is not my strongest and I am muddling through but I am really struggling with MQTT,

I have sorted Owntrack tracking but I am trying to now detect battery level via Owntracks and a local MQTT service. I’m sure I’m missing something but cant work out what.

I currently have the following:

within configuration.yaml

mqtt:
    broker: 192.168.0.63
    port: 1883
    client_id: hass
    keepalive: 60
    username: !secret MQTT_USERNAME
    password: !secret MQTT_PASSWORD

within sensors.yaml

 - platform: mqtt
   state_topic: MIKES_OWNTRACKS
   name: "Mike's GS7 Battery"
   unit_of_measurement: "%"
   value_template: '{{ value_json.batt }}'

It is showing in the frontend like so, but the actual % isn’t being pulled in.

Sorry if this is a simple one I just can’t find the answer anywhere and as I said dev and coding is not my strongest so I’m struggling to understand the doc’s around MQTT.

Thanks in advance
Mike

Have the same issue, for me it just meant my phone’s owntracks hasn’t connected to the mqtt server.

I am getting it connected as confirmed on my phone but I’m not sure if there is a setting I am missing or more code.

Your state_topic: looks wrong. Owntracks topics looks like “owntracks/xxx/yyy”.

Cheer’s mate I didnt realise I forgot to put the !secret part in my state_topic is actually "owntracks/mike/mike"

Still not working tho? Any Ideas?

Thanks

Mike, did you find a resolution to your problem?

Hi Michael,

I did for my android it was just me being stupid and not having the correct owntracks/name/name details. But for my mrs iPhone I had no joy! It managed to show it but would never update from the original figure it gave me!

In the end I gave up completely!

What was the solution for the Android phone? I just cant find the right state_topic I think.

Honestly I can’t really remember as I don’t have HA setup anymore it just wasn’t working for me and I have moved systems completely to smartthings which I am getting on with much better

From memory I think it was just owntracks/Mike/mike for me (note the capital M on the first Mike) but sorry mate I can’t really remember!

Thanks Mike, I’ll keep playing around.

Hi,

on your mosquitto-server, try to listen whats going on:
mosquitto_sub -u USERNAME -P PASSWORD -v -t \#
with this, you can see everything going through. Maybe this helps.
Keep an eye on slashes and such things.

ambassadoro, your suggestion worked perfectly except I had to remove the \ from the topic.

I needed to add state_topic: “owntracks/Michael/hlte”

Thanks for your help.

HI…
Please help. When I tried mosquitto_sub for owntracks data I get an error ¨connection refused: not auithorised¨

Not sure what is wrong.

@KvRajan , same issues happened to me as well. There are number of things need to be checked.

First double check your created users and passwords. As the passwords are encrypted in the file, if you forgot then best to just create a new password, it will replace the old.

Check the mosquitto configuration file.
Then do a restart. If all good, you should be able to connect to the server. If still problem persists, do a clean install again. By the way, which OS you are on ?

Thanks

@MikeCranium can you share working example of settings on android?

Anyone manage to get this working on iphone? Please share configuration?

This is good howto for android phone:
https://community.home-assistant.io/t/setting-up-owntracks-with-integrated-mqtt-broker/51711

How to setup owntacks ios app?