How to get MQTT sensor monthly difference?

Have MQTT sensor which reports some numerical value continuously e.g. kWh instantaneous value.

How to get monthly total consumption relative to current day?

Sorry if missed similar topics … or my question is stupid. Havent found solution.

Thank you.

I have never used it, but I think the History Statistics Sensor will do what you want.

Also, Jupyter notebooks could help for advanced stats.

Thank You for suggestions.

Jupyter is not what I actually need.
Had a look on history statistics sensor already.
Problem is that it sorts values based on STATE value e.g. On, Off, Unknown etc.
But I have numeric value there and increasing as it is kWh counter.

sensor sensor.wmbus_electricity 27594.11
sensor sensor.wmbus_electricity 27596.23
sensor sensor.wmbus_electricity 27610.78

STATE value is REQUIRED for that sensor or maybe wildcard is available for that field ?

Any other ideas ?