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
here the
still work out how to added to hacs