i’m using a youless energie meter to measure my energy used. this gives me sensor.youless_meter that will tell me total power consumed (12345w. i want to record the output of that sensor on 00:00 and subtract that any time with the current usage. so it will tell me how much i’ve used that day.
Similar to the approach of storing the value in an input_number field, you could use MQTT to store values and template sensors to show the cumulative values. I’ve got hourly, daily and monthly usage being show this way. This was my inspiration…
There are two components with open pull requests that seem to meet your need exactly. Hopefully they are accepted and merged for the next release:
https://github.com/home-assistant/home-assistant/pull/19703 -
Sometimes a device only provides power information (measured in W or kW).
This sensor does an integration of Power and time in order to measure energy consumed in kWh (standard energy measurement unit)
and
https://github.com/home-assistant/home-assistant/pull/19718 -
A utility meter sensor provides functionality to track consumptions of various utilities (e.g. energy, gaz, water, heating). From a User perspective utility meters operate in cycles (usually monthly) for billing purposes, this sensor will automatically reset the counter based on the configured cycle. On a reset an attribute will store the previous counter, providing the means for comparison operations (“did I spend more or less this month?”)
If you are feeling adventurous, you could pull the code from either (or both) of these and use them as custom components probably; until they get merged.