Log of How Many Times Door Sensor Opened Weekly

Hey all,

I am wanting to have a history graph of how many times a door sensor was opened per week.

I have a counter helper for this, and an automation that increments that each time the door sensor is opened.
I also have another automation that resets this counter to 0 every Monday 00.00.00.

I really want a graph in my dashboard that shows the amount of times the door was opened each week. It only needs to show the total count for each week.

I have been playing around with the history stats sensor but I don’t know if that’s what I actually need.

Seems like a good use-case for a utility meter helper to me.

  - platform: history_stats
    name: "Weekly Door Opening Mon-Sun"
    unique_id: front_door_opening_weekly_0001
    entity_id: binary_sensor.fr_door
    state: "on"
    type: count
    start: '{{ today_at() - timedelta(days= now().weekday())}}'
      hours: 168


  - trigger:
      - platform: state
        entity_id: binary_sensor.fr_door
        to: "on"
        not_from: unavailable
      - platform: template
        value_template: "{{ now().hour == 0 and now().strftime('%a') == 'Mon'}}"
        id: reset
      - name: times_opened
        state: |
          {% set current = this.state | int(0) if this is defined else 0 %}
          {% if trigger.id == 'reset' %}
          {% else %}          
            {{ current + 1 }}
          {% endif %}