Increment counter based on another counter

I’m having a points system for chores in the family. I want to introduce a weekly total sum, so I created a new “weekly points” counter helper for each family member. I want to create an automation that adds the value of the daily counter “daily points” to the “weekly points” counter.

Does anyone have an idea how this could be done?

1 Like

Use a Utility Meter helper.

Could you explain more how this would work? I haven’t used a utility helper before, but looking at it now, I can’t see how that would help? The Input sensor has to be of domain sensor, so it can’t be a counter.

I had forgotten that fact… :slight_smile:

You haven’t stated whether the weekly total’s value needs to increment immediately when you add to the daily value or whether there will be a need to decrement the weekly value. For a basic version that updates the weekly total at the end of the day, you can use an automation with a template in the counter.configure service call:

trigger:
  - platform: time
    at: "23:59:00"
condition: []
action:
  - choose:
    - conditions:
        - "{{ now().isoweekday() == 7 }}"
      sequence: 
        - service: counter.configure
          data:
            value: 0
          target:
            entity_id: counter.weekly_points
    default: 
        - service: counter.configure
          data:
            value: >-
              {{ states('counter.weekly_points') | int(0) 
              + states('counter.daily_points') | int(0) }}
          target:
            entity_id: counter.weekly_points

Depending on your use case, you may still want to use a Utility Meter. For that you would first create a Template sensor that mirrors the value of your counter.

template:
  - sensor:
    - name: Chore Points Counter Mirror
      state: "{{ states('counter.daily_points') }}"

Then, in the UI, you would create your utility meter sensor(s).

1 Like

That seems to have made the trick! Thanks!