Counter increment/decrement by *

Hiya All,

Is there a way to call the counters increment/decrement service and give it a by how many it should increase/decrease?
I’m trying to create something to help motivate me do my household tasks.
So I have a counter setup called chorepoints. Now I want chorepoints to be earned on completion of tasks. The smart washer reporting a completed washing cycle for example. Or a manual button card for non smart tasks.
However, the counter only increments by either 1 or a fixed value with the step config option and that’s not really what i’m after because loading the washing machine should not be the same amount of points as cleaning the kitchen. Also the rewards i have planned for redemption with the points, like getting take-out or a netflix binging day, should also have differing costs.

You could try using input numbers. It seems as though the use of data templates in an automation would work from the docs. Its not as clear if this would work from the counter docs.

You could have one input number to keep the tally, another to increase when a chore is completed and another to reduce the tally when redeeming points.

Inputting a number into the increase input number would then trigger an automation to take the current value of the tally input number and add the value entered. The same could be done for the redemption input number but removing from the tally.

You could also setup input_booleans for common tasks and assign fixed values for them. If input_boolean 1 is turned on (cleaning the kitchen) use a template to detect that trigger and then add a set amount of points.

The only thing I can think to watch out for is restarts. If no initial value is set, the value of each item will be retained across restarts. However, I am not sure if it would trigger on start thus adding/removing from the tally. I think this could be avoided by having the initial state as false and then turning the automation on after homeassistant is fully started and all entities are established.

you could use a input_number with template like this:
the template saves the current input_number value and add (or take)
whatever you want

    service: input_number.set_value
      entity_id: input_number.chorepoints 
      value: >
        {% set input_num = states('input_number.chorepoints ') | int %}
        {% if some_entity_id == 'something that give 50 Points ' %}
        {{ input_num + 50 }}
        {% elif some_entity_id == 'something that take 20 Points ' %}
        {{ input_num - 20 }}
        {% endif %}

Starting in version 0.113 you can do:

- repeat:
    count: 5
    - service: counter.increment
      entity_id: counter.COUNTER

The count parameter also accepts a template if you want to pass in a value to a script.

How templating works still eludes me so thanks for the suggestions on using input numbers but if the easier -repeat option is only one version away I’ll wait for that! :slight_smile: