I’m a bit stumped, reading from other examples this should work:
{% for object in states.binary_sensor %}
{% set battery = state_attr(object , 'battery_level') %}
{{object.name}}:{{battery}}
{% endfor %}
however it gives this strange error in the log:
File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/template.py", line 284, in __getattribute__
return getattr(object.__getattribute__(self, '_state'), name)
AttributeError: 'State' object has no attribute 'lower'
for reference, this works:
{% for object in states.binary_sensor %}
{{object}}
{% endfor %}
And gives output, including the asked battery level (shortend):
<template state binary_sensor.motion_sensor_158d0002b8586b=off; No motion since=1800, device_class=motion, battery_level=49.0, friendly_name=motion_trap @ 2019-02-02T09:09:19.440280+01:00>
<template state binary_sensor.ring_front_door_ding=off; friendly_name=Front Door Ding, expires_at=2019-02-02T12:08:21.668320+01:00, firmware=Up to Date, device_class=occupancy, state=ringing, device_id=341513c2b0af, attribution=Data provided by Ring.com, timezone=Europe/Amsterdam @ 2019-01-31T11:41:46.618673+01:00>