Owntracks and Battery attribute

yep exactly that happened to me…

@fiftys - do you have any regions setup within owntracks please? I mean not even -home? as I know you said you have none… and wondering if even -home is the problem

My zones are all in HA, none in OwnTracks if it matters.

No Regions setup in owntracks. when I had Home region I was having the disconnect issues.

when you have regions setup viewing the livelog in shell you will see that it stops updating the location : "calculating proximity’… stops when you enter the zone… I only use zone: home

zone:
  - name: home
    latitude: 33.xxxxx
    longitude: -11x.xxxx
    radius: 50
    icon: 'mdi:work'

and proximity:

proximity:
  me_distance:
    zone: home
    devices:
      device_tracker.jim_mys9
    tolerance: 50
1 Like

You beauty… I stripped my phone back, took out the OT regions, used your sensors etc… and I came home tonight and mine didn’t say unknown… but my wifes did… thank you so so much!

1 Like

awesome. I really like this battery setup… combine it with a tts to remind you to charge it:

- id: ttsreminder
  alias: Phone Battery Charge on
  trigger:
  - above: '1'
    below: '25'
    entity_id: sensor.jim_battery_level
    platform: numeric_state
  condition: []
  action:
  - data:
      entity_id: media_player.living_room_speaker
      message: Hey your battery needs charged
    service: tts.google_say

and a automatic float charge:

- id: '1564387716417'
  alias: phone charge on
  trigger:
  - below: '93'
    entity_id: sensor.jim_battery_level
    platform: numeric_state
  condition:
  - condition: state
    entity_id: binary_sensor.jim_battery_decrease
    state: 'on'
  action:
  - data:
      entity_id: switch.autocharge
    service: switch.turn_on
- id: '1564388614967'
  alias: phone charge turn off
  trigger:
  - above: '99'
    entity_id: sensor.jim_battery_level
    platform: numeric_state
  condition:
  - condition: state
    entity_id: binary_sensor.jim_battery_decrease
    state: 'off'
  - condition: state
    entity_id: person.jim
    state: home
  action:
  - data:
      entity_id: switch.autocharge
    service: switch.turn_off

and if you want to see it on a graph… install the mini graph card

card:
color_thresholds:
  - color: '#FFFFFF'
    value: 99
  - color: '#4b0082'
    value: 95
  - color: '#0000FF'
    value: 85
  - color: '#00FF00'
    value: 65
  - color: '#FFFF00'
    value: 45
  - color: '#FF7F00'
    value: 22
  - color: '#FF0000'
    value: 1
entities:
  - entity: sensor.jim_battery_level
  - entity: sensor.wifes_battery_level
    show_state: true
  - entity: sensor.kidsphone_battery_level
    show_state: true
hours_to_show: 12
lower_bound: 15
name: Phone Batteries
points_per_hour: 6
show:
  average: true
  extrema: true
  fill: false
  graph: line
  icon_adaptive_color: true
  labels: true
show_line: true
type: 'custom:mini-graph-card'

neat stuff…

1 Like

@MarkR - I think adding proximity is the trick. I’ve just updated my config and will keep an eye on it as I’m out and about today.

Thanks for the insight!

very well could be the case.

not sure, I did use proximity before, but I stripped out some unused zones and tidied up the script for proximity etc, thanks to Jims code

I came back home from A BBQ last night to “unknown” for my battery status.

So… this morning I went back to my old config (basically removed the proximity entry that I added), rebooted HA, took the dog for a walk (left the home zone) and when I returned, I still showed a battery percentage.

I’m scratching my head. I have to go out again later, will monitor the results.

Update: left the home zone came home and my battery status said unknown. I checked in a few times while I was out and it was reporting correctly. It only blanked when I got home. More digging required on my end.

Yup It stops as soon as you return home.

if you can run :
sudo journalctl -f -u homeassistant@yourusername

it will show the disconnect as you arrive.

if it never knows you arrived in the home region… it never disconnects…

least thats what ive assumed… and its workign for me lol

I think I finally understand. Gonna muck around with it tomorrow.

Thanks for the insight!

Hey @fiftys… question for you. Do you have your home zone defined only from your default location from configuration.yaml or do you also have defined in your zones.yaml too?

I only ask because I never explicitly defined my home zone in my zones.yaml. I let that one config from configuration.yaml and I’m wondering if that might make a difference.

(I put proximity back in, and that sensor is working… but it doesn’t seem to make a difference once I leave and return to my home zone.) I just defined “home” in my zones.yaml file and rebooted. Will keep an eye on it when I leave in a little bit.

just in config.yaml:

homeassistant:
  name: Home
  latitude: 33.xxx
  longitude: -11x.xxx

and in zone: which i have not split into zone.yaml yet.

zone:
  - name: home
    latitude: 33.xxx
    longitude: -11x.xxx
    radius: 50
    icon: 'mdi:home'
1 Like

few other things that im not sure if matter:
i run

- platform: tile

no home information listed.

- platform: ping
  interval_seconds: 30
  consider_home: 90
  count: 2
  hosts:
    jim_ping: phone_static_ip

and:

- platform: nmap_tracker
  hosts: 192.168.1.3-110
  interval_seconds: 32
  consider_home: 90
  home_interval: 13

then for person.jim i hve owntrack, ping, nmap, and my keys tile in: ‘Select the devices that belong to this person.’

Thanks!

Ok… then maybe I’m on the right track. I did not have my home zone explicitly designated in my zones file. Maybe that’s the lynchpin…

I’ve had my BT trackers set and working for a while but the only thing giving me problems is my android phone’s OwnTracks battery status when I get home. Everything else is working as it should.

1 Like

That seems to have done it! (Explicitly defining the home zone, that is.)

Thanks for your help!

1 Like

nice! glad its figured out…

now maybe try to add the regions back into owntrack… that should stop proximity from calculating the whole time we are at home… hmm