Ciquattro
(Ciquattro)
December 30, 2016, 10:15am
1
Hello Guys,
I need your help… I’m not able to extract battery info from GPS Logger entities.
this is my sensor config, what’s wrong?
- platform: template
sensors:
Nico_SGS6_Battery:
battery:
value_template: '{{ states.device_tracker.05157df5109bbb23.battery }}'
friendly_name: 'Nico Battery'
unit_of_measurement: '%'
entity_id: device_tracker.05157df5109bbb23
Juergen
(Juergen)
December 30, 2016, 1:13pm
2
Have you tried to use
states.device_tracker.05157df5109bbb23.battery.state
instead of
states.device_tracker.05157df5109bbb23.battery
or a
'{{ states("device_tracker.05157df5109bbb23.battery") | int }}'
Sorry, I know this is an old topic here.
I run into the same error and found that template sensors don’t work on entities where the name starts with a number.
(there is a post about it somewhere here, but I can’t find it anymore)
I fixed this by prefixing the entity name with logger.
To do this I copied the gpslogger.py from github to
custom_components/device_tracker/gpslogger.py
change line 57 from
device = data['device'].replace('-', '')
to
device = 'logger_'+data['device'].replace('-', '')
This now names the device device_tracker.logger_< some number > and now my templates work.
Hope this helps someone.
I should work out how to do a pull request and add it there…
2 Likes
Hi,
Just helping out here. You needed an “attributes” added to your object to get the value. Like this:
- platform: template
sensors:
Nico_SGS6_Battery:
battery:
value_template: '{{ states.device_tracker.05157df5109bbb23.attributes.battery }}'
friendly_name: 'Nico Battery'
unit_of_measurement: '%'
entity_id: device_tracker.05157df5109bbb23
Notice the attributes in
{{ states.device_tracker.05157df5109bbb23.attributes.battery }}
1 Like