Food quantity sensor

Hello,
i have a custome made cat-feeder integrated through mqtt.
The device has scheduled feeding with specific quantity, so i thought i could publish data also on food quantity delivered for every feeding activity (so to see for example how much food is given every day… something like that).
But i can’t setup this in a working way.
I created a mqtt sensor with

      state_class: "total"

since it’s not a simple “measurement” and its not a “total increasing”, but in this way i can get only a flat sensor since in this case all feeding has the same amount configured

what am i missing? should i configure something more than the sensor? i was thinking about something like the energy dashboard, where i can see by day, week and so on the amount of food given…

Thanks

The easiest way is probably with the Utility Meter helper:

sadly i need some more help, since i can’t get this to work :slight_smile:
i already had a similar helper for daily power usage (that works), this is obviously different but i can’t make this work.
I set up the “delta” config, since my feeder for each feed event reports the food quantity that must be added.

The base used is a mqtt sensor that publishes the food quantity:

    - name: "Cats food quantity"
      state_class: "measurement"
      state_topic: "devices/data/catfeeder/qty"
      value_template: "{{ value_json.qty }}"
      suggested_display_precision: 0

The feeder correctly publishes values, my point is that the helper is not summing values at all. It seems values from the sensor are totally ignored, at least when the value published is the same of the previous one (in this use case this is quite common), what am i missing?
i also tried adding the “expire_after” parameter for the sensor, now the utility meter counts the values, but obviously is almast always “not available”
Should i force the sensor to publish the quantity and then 0 every time?
Are equal sensor values discarded for any reason?
Thanks

Edit: ok, sorry, i had to think to the sensor more than to the utility meter. Probably the

force_update boolean (optional, default: false)

set to true fixed my problem