Calculate Energy Consumption on an time incremental basis

  • Hi

    Pretty new to this forum so apologies if I am posting in the wrong place

    I am creating an app that shows energy consumption for a specific user, and in order to do so I need to find a way how to incrementally save data from the 1PM data in a database so I can use it to show back consumption to a user on a daily, monthly, weekly basis.

    Home Assistant already does that, but I need to create a custom version, and I am not able to understand what data Home Assistant is using to do those calculations.

    I am using MQTT to save data on the Database

    The data coming in the message only contains total energy usage since the device started, power in Watts and current, however, I am not able to understand how I can use this data to achieve my goal.

    To summarize the goal is to get the data from the MQTT message and save it into a database for later retrieval to be able to provide date-filtered data to end users about their energy consumption.

    Really appreciate your help on this one and please let me know if you need any further information

    Thank you