Integration helper method

This is a sensor that tracks electric power usage during off peak hours:

I then use an integration helper to generate electic consumption based on the above:

Now I used the GUI helper to create the integration sensor, and I can not find which method I used (trapezoidal, left or right), I think left? But I cant see that any method ought to result in this staircase graph.

So, how can I find out which method I used, how do I change it without losing all my data?

You can find the entity in /config/.storage/core.config_entries, which will show you the method.

If you delete and recreate with the same name, I don’t believe you will lose your data. For example, create a button helper, and ‘press’ it a few times. See the history updates. Now delete it and recreate with the same name. Go into the history and see it’s all still there. If you delete an entry, the state history will stick around until purge_keep_days in the recorder causes it to be deleted.

Thanks, seems like I used trapezoidal. Ill test with another helper using “left”.

As for replacing one with the other; Im reluctant. I tried it recently when I changed out a smart socket, and hoping I wouldnt lose long term stats, I deleted the old one, and just gave the new one the same entity names as the old one, but it messed everything up badly. The long term stats seem to use the device_id not the entity name.

These helpers dont have a device_id but from core.config_entries they do seem to have a similar looking unique “entry_id”, and I dont think I want to mess with that.

Would it be possible to change the method for the existing sensor instead by editing that file?

I have edited that file before, when my deCONZ integration lost the plot, so it can be done. But I have no idea what the ramifications would be for specific integrations. And if you stuff it up, HA may not start properly.

It may not have worked with your socket because the entity may still have been there with restored=true, in which case readding it would create a new “_2” entity. You would have to delete the restored entity first in HA. This doesn’t happen with the helpers.

I would do a HA backup, then do the delete/re-add and see if the history is still there. If it’s not, do a restore. I had re-added things to external apps before (like deCONZ), and they always line up correctly with the HA entity. To me this sounds safer than editing internal HA files.