I’ve created a simple automation where each time my coffee maker brews, it reduces the the counter ‘counter.coffee_filters’ by 1, so that I’ll know when I’m running low on coffee filters and need to buy more. The idea is when I open a new box, I’ll just reset the counter back to 40 (the number of filters in the box).
The issue is, that in the situation above I’ve waited until there are 0 left to hit reset so it will be 40 again. But if I purchased more filters when there were 5 filters left, I now have total 45 filters, so really the counter should be at 40+5 = 45.
Does anyone know of how I can increase a counter as current counter value + 40?
Create an automation or script (probably a script in this case) that grabs the current value of the counter, adds 40 and uses the service.set_value to set that value into the counter.
In your dashboard add a button card then use a service call from that button card (or your favorite card) to trigger the script and label the button ‘restock filters’.
Thanks! I was overthinking it. The solution is a script just like you said
service: counter.set_value
data_template:
entity_id: counter.coffee_filters
value: “{{ states(‘counter.coffee_filters’) | float + 40}}”