Battery prediction sensor

I wanted a way to predict how long until the Ring ran out of battery. After some research, I found you can find the slope of the battery using a Statistics sensor, and predict it using a template. Here’s the code.

sensor:
  - platform: statistics
    entity_id: sensor.front_door_battery
    name: "Ring battery rate"
    state_characteristic: change_second
    precision: 6
    max_age:
      hours: 48

template:
  - sensor:
    - name: "Time Until Ring 0%"
      unit_of_measurement: "days"
      icon: mdi:battery-clock
      state: "{{ (states('sensor.front_door_battery') | int / -(states('sensor.ring_battery_rate') | float) / (60 * 60 * 24)) | round(1) }}"

And then I integrated it into my dashboard:

4 Likes

Nice.

My Ring went offline when the battery read 21%. I get notified when any batteries are less than 35% but I have a set of door sensors that go off line when less than 85% (I have a separate notification for these). I would probably adapt your solution to account for a target different than zero.

Have you tested actual days to zero battery vs estimated?

I just set it up today, so I haven’t tested it. But remember, the math is just battery / battery loss per day. You could use a fixed value instead if you want.

I’ve been using something similar for a few of my batteries. How has this been working out for you?

I’m looking to try to determine a more general solution. It seems like the right value for the max_age (or sampling_size) can vary a lot between devices. For example, a slowly discharging battery with a max_age of 48 hours might be too small of a value.

I ended up hardcoding the value since it was relatively constant. You might find something that works better though.

1 Like