MarkR
June 9, 2019, 7:06am
1
Hello
I use the battery attribute from owntracks to display in HA. Since moving to 0.94, it changed name and but still reported and worked once I changed the sensor… Now after a couple of days the attribute has vanished…
Does anyone know what has happened to it please?
- platform: template
sensors:
mark_phone_battery:
friendly_name: 'Mark battery'
value_template: '{{ states.device_tracker.mark_mark.attributes.battery_level|float }}'
unit_of_measurement: "%"
entity_id:
- device_tracker.mark_mark
Cheers
Mark
MandM78
(Greg)
June 17, 2019, 1:32pm
2
I have a similar issue… when I reboot HA… the battery attribute from my OwnTracks tracker works fine. Then… about 12 hours later, it stops registering the battery attribute from my android phone, even though it updates the GPS location without issue.
I then get an error that says:
Log Details (ERROR)
Sun Jun 16 2019 19:06:24 GMT-0400 (Eastern Daylight Time)
Could not render template Android Battery: UndefinedError: ‘mappingproxy object’ has no attribute ‘battery_level’
I’m not sure why it’s failing all the sudden.
Im having the same problem. Upgraded to 0.94.3 from 0.93.2 and now I dont get battery to my devices.
sensor:
- platform: template
sensors:
saras_batteri:
friendly_name: "Saras Batteri"
unit_of_measurement: "%"
value_template: "{{ state_attr('device_tracker.sara_android_owntracks', 'battery') }}"
device_class: battery
Whats wrong with my setup?
MandM78
(Greg)
June 18, 2019, 9:38pm
4
I think yours may be simple… try changing ‘battery’ to ‘battery_level’ in the value template.
1 Like
That helped! Now its working again!
MandM78
(Greg)
June 19, 2019, 8:48pm
6
Cool! Glad it was that easy!
yes this is happening to me as well.
To reproduce it-- change from not_home back to home.
I’m on 0.95.4 and the battery level pops in and out.
Also when I am away if you look at HA it shows me as away for about 5 seconds and then home for 5 seconds and this repeats in a loop.
Not sure when it started, but something is wrong.
Any thoughts?
MarkR
July 6, 2019, 1:19pm
9
I don’t have the issue with home/not home but my battery is sometimes there other times not… no idea why
fiftys
July 7, 2019, 3:54pm
10
I solved this by switching from http to mqtt in owntracks.
Always shows battery now, never cuts out anymore.
MarkR
July 8, 2019, 6:17am
11
strange as mine has always been mqtt and still does this
fiftys
August 14, 2019, 1:10am
12
Mark I did notice IF you have regions set in owntracks it can cause in an issue when it stops calculating the proximity. Mainly with Home. Use HA zone.home to solve it.
MarkR
August 14, 2019, 7:28am
13
where do you mean Jim? I do have 3 regions, but in HA I use zone. ?
Mine is getting worse… Particularly when I am not home
MandM78
(Greg)
August 14, 2019, 1:47pm
14
And I don’t use any regions within OwnTracks… all my zones are in HA…
MarkR
August 14, 2019, 2:20pm
15
I’ve removed all my regions and it still says unknown… I am outside of my home zone at work
fiftys
August 27, 2019, 5:41pm
16
wierd. mine is working 100% of the time. no drops. on 3 phones.
ill post my configs, maybe the answer lies in them
owntracks:
max_gps_accuracy: 80
mqtt_topic: "owntracks/#"
events_only: false
waypoints: false
- platform: template
sensors:
jim_battery_level:
friendly_name: Jim Battery Level
unit_of_measurement: '%'
value_template: '{{ states.device_tracker.jim_mys9.attributes.battery_level|int }}'
icon_template: >-
{% set battery_level = states.device_tracker.jim_mys9.attributes.battery_level | default(0) | int %}
{% set battery_round = (battery_level|int / 10)|int * 10 %}
{% if battery_round >= 100 %}
mdi:battery
{% elif battery_round > 0 %}
mdi:battery-{{ battery_round }}
{% else %}
mdi:battery-alert
{% endif %}
jim_battery_state:
friendly_name: Jim Battery State
value_template: >-
{% set battery_level = states.device_tracker.jim_mys9.attributes.battery_level | default(0) | int %}
{% set battery_round = (battery_level|int / 10)|int * 10 %}
{% set charging = is_state("binary_sensor.jim_battery_increase","on") %}
{% set discharging = is_state("binary_sensor.jim_battery_decrease","on") %}
{% if charging %}
Charging
{% else %}
{% if battery_round >= 100 %}
Full
{% elif battery_round > 0 %}
In Use
{% else %}
Low
{% endif %}
{% endif %}
icon_template: >-
{% set battery_level = states.device_tracker.jim_mys9.attributes.battery_level|default(0)|int %}
{% set battery_round = (battery_level|int / 10)|int * 10 %}
{% set charging = is_state("binary_sensor.jim_battery_increase","on") %}
{% set discharging = is_state("binary_sensor.jim_battery_decrease","on") %}
{% if charging %}
mdi:power-plug
{% else %}
mdi:power-plug-off
{% endif %}
- platform: trend
sensors:
jim_battery_increase:
entity_id: sensor.jim_battery_level
jim_battery_decrease:
entity_id: sensor.jim_battery_level
invert: true
the card -->
entities:
- label: Jimmie
type: section
- entity: sensor.jim_battery_level
name: Jim Battery Level
secondary_info: last-changed
- entity: sensor.jim_battery_state
name: Jim Battery State
secondary_info: last-changed
- entity: device_tracker.tile_p_7882b5ce93eb7a0b
secondary_info: last-changed
- entity: device_tracker.tile_7342d4
name: Keys
secondary_info: last-changed
- entity: proximity.kidsschool
name: Proximity to Santa Fe school..
1 Like
MarkR
August 27, 2019, 10:05pm
17
Thank you… i have just it up the same as yours… fingers crossed
1 Like
MarkR
August 28, 2019, 6:21am
18
and dammit… I woke up and it was exactly the same problem. So cannot be a HA issue. Will turn on debug logging and see and reinstall OT on my phone.
Thank you for helping…
edit, I rebooted ha and it started working again… odd
MandM78
(Greg)
August 28, 2019, 1:30pm
19
Mine always works on a reboot… for a while. Then it starts to get weird and says “unknown” after I leave the home zone and then come back. If I leave the zone again… it works fine.
MarkR
August 28, 2019, 2:02pm
20
I’ll test that tonight… I rebooted this morning and it started working… I am now at work and it is still working… let’s see when I get home tonight.