Coffee counter sensor - suggested approach

Hi Folks,

It’s my first post here however I’ve been following the forum for some time, so I guess it’s the best opportunity to say “Hello” and “Thank You All for the help!”

I have a question about suggested approach building a Coffee counter sensor.
I’d love to see some stats:

  • number of coffees per day
  • total number of coffees weekly/montly

With a power socket metering and Node-red rules I’m able to detect moment where coffee is brewing.

I see two approaches:

1. incrementing coffee counter every time fresh coffee is done + reset counter on 00:00 every day (current approach I’ve made)
sample:

Pros:

  • can use just badge to receive today status
  • can use e.g custom:mini-graph-card to create daily graphs
    Cons:
  • cannot get the “weekly stats”
  • limitations of custom:mini-graph-card does not allow aggregate by week interval

2. Simulate a binary_sensor logic, create a state “high” when coffee is done and immediately after send low state
Pros:

  • might be easy to just count per day/week/months? (I don’t know which module? history_stats?)
  • not necessary to be reset every day
    Cons:
  • cannot create continous graphs?
  • basic entity/badge usage require having a sum/count per day prior

So far I’ve implemented #1 but I have some doubts which one is better?

Thanks