I decided to share this snippet based on seeing what others were doing in this thread: https://www.reddit.com/r/homeassistant/comments/emvk9y/how_do_you_monitor_sensor_battery_levels_looking/
Basically dome device types of battery report the state in different locations and with different string
values that the change node or conditional logic just doesn't work nicely. Using the conditional logic on
this string state value might not be working fully how we think it is or at least didn't for me. When I was
debugging it and getting 10
outputted in a 100
bucket via the gt condition. The best way I've found to
handle these conditions is with a function node.
It might be worth seeing if we can normalize this in Home Assistant. It would be nice if devices that can charge have their charging state normalized, battery level state in the same spot with a last changed in attribute. Additionally it would be nice to see something for dead batteries or if the device just hasn't reported in a long time. I say this because I've have many devices I know are charged and on, but they are being reported as "off".
off, clearly the battery has a level and it lasts 10 years and it's reported in the nest app as OK
{"entity_id":"binary_sensor.nest_protect_battery_health","state":"off","attributes":{"friendly_name":"Nest Battery","device_class":"battery"},"last_changed":"2020-01-11T11:42:50.976581+00:00","last_updated":"2020-01-11T11:42:50.976581+00:00","context":{"id":"2a2f5c1503cd44c7bb3ebd9be69a4144","parent_id":null,"user_id":null},"timeSinceChangedMs":2731510}
Charging - battery level stored in attributes.
{"entity_id":"sensor.battery_state_2","state":"Charging","attributes":{"Battery Level":52,"friendly_name":"Battery State","icon":"mdi:battery-charging-40","device_class":"battery"},"last_changed":"2020-01-11T11:43:06.616903+00:00","last_updated":"2020-01-11T11:43:06.616903+00:00","context":{"id":"a9cc54cd33cf4cf1954c4cd2f2f633a8","parent_id":null,"user_id":null},"timeSinceChangedMs":2715885}
Same device as Charging example above but duplicate battery device sensor with state in the correct location.
{"entity_id":"sensor.battery_level_2","state":"52","attributes":{"Battery State":"Charging","unit_of_measurement":"%","friendly_name":"Battery Level","icon":"mdi:battery-charging-40","device_class":"battery"},"last_changed":"2020-01-11T11:43:06.599389+00:00","last_updated":"2020-01-11T11:43:06.599389+00:00","context":{"id":"60469c2964504dc4bb11cbf5a307ceb9","parent_id":null,"user_id":null},"timeSinceChangedMs":3766731}
August lock reported from august integration missing information
{"entity_id":"binary_sensor.august_door_locked_battery_level","state":"off","attributes":{"friendly_name":"August Door Lock Battery Level","device_class":"battery"},"last_changed":"2020-01-11T11:42:50.892228+00:00","last_updated":"2020-01-11T11:42:50.892228+00:00","context":{"id":"567d9c771c91440c826ed26d14187513","parent_id":null,"user_id":null},"timeSinceChangedMs":2731591}
August lock reported from zwave
{"entity_id":"sensor.august_asl_03_smart_lock_battery_level","state":"100","attributes":{"node_id":2,"value_index":0,"value_instance":1,"value_id":"72057594077773825","unit_of_measurement":"%","friendly_name":"August ASL-03 Smart Lock Battery Level","device_class":"battery"},"last_changed":"2020-01-11T11:47:39.195031+00:00","last_updated":"2020-01-11T11:47:39.195031+00:00","context":{"id":"406c8c33527a4daf8d9b23531953d54f","parent_id":null,"user_id":null},"timeSinceChangedMs":2443740}