Battery replacement UPDATED

as I have a number of sensor that have battery in then and they send back the % level

got thinking

so as I know the date I replace the battery ( 01/07/2020 ) dd/mm/yy Dimmer Switch Battery Level

so my logic is If between 01/07/2020 and now 06/07/2020 it has used 50% of battery.

If for 5 day its used 50% then it will take other 5 days and it be flat. base of these 5 days been the same as the last 5 days

So all we need to do is tell a python script the entity_id of battery and the date we replace it and run it once a day and at startup of home assistant

remember: the maths is base on the % level at the battery the script was run and date it was given.

so we have the entity_id , replacement date dd/mm/yyy

- sensor.dryer_door_battery , 01/01/2020

so putting it all together

- alias: Do a percentage check on battery work replace days
    initial_state: on
    trigger:
      - platform: time
        at: '00:00:01'
      - platform: homeassistant
        event: start
    action:
      - data:
          replaced:
          - sensor.dryer_door_battery , 01/01/2020
          - sensor.dimmer_switch_battery_level , 01/02/2020
          - sensor.bathroom_battery_level , 08/06/2020
          - sensor.cupboard_battery_level , 08/06/2020
          - sensor.hall_battery , 05/05/2020
          - sensor.lounge_battery_level , 08/06/2020
          sensor_on_days: 30
          entity_id: status_battery
          friendly_name: Battery Status 
          icon: mdi:calendar-star
          display: days
        service: python_script.battery_replacement

which create this sensor with this popup

image

here the

still work out how to added to hacs

5 Likes

Great idea :slightly_smiling_face:

I’ll keep a look out for it on HACS. Thank you! I was looking for something like this.

Why not simply set an alert when the battery reaches, say, 15%?

1 Like

true bro that was the easy way

want to lean this python stuff and just me thinking out side the box

2 Likes

and by changing this

display: date

you get

image

2 Likes

****** BIG UPDATE *******

it can now create a replacement sensor
base on the

replace setting

screen shot

its config

card:
  type: entities
  title: Battery Replacement
filter:
  include:
    - entity_id: sensor.replacement*
type: 'custom:auto-entities'

its popup

image

if you have the

custom:fold-entity-row and custom:auto-entities

you can do this

image

to

image

entities:
  - head: script.python_script_battery
    items:
      - card:
          type: entities
        filter:
          include:
            - entity_id: sensor.replacement*
        type: 'custom:auto-entities'
    type: 'custom:fold-entity-row'
1 Like