Converting a Bidirectional Energy Meter to Import/Export Meters

Hello everyone,

I’m currently working on optimizing my energy monitoring setup and have encountered an interesting challenge. I have a bidirectional energy meter that measures both import and export of electricity. While it provides accurate readings, I need to split these into two separate cumulative meters—one for energy imported from the grid and another for energy exported back to it. This would allow me to track my consumption and generation more effectively, especially with the addition of solar panels.

I’ve tried using template sensors to achieve this, but I’ve run into some issues with negative values and accuracy. My current setup involves using the state_attr function to extract the energy values, but I’m struggling to find a reliable way to split these into positive import and export figures without introducing errors. I’ve also looked into using the Home Assistant integration helper, but the results don’t align perfectly with the meter’s built-in statistics, and sometimes there are discrepancies that require manual correction.

I’m wondering if there’s a more straightforward method to achieve this without relying on the integration helper. Perhaps there’s a way to use the existing meter’s data more effectively or a different approach to scripting that could provide a more accurate split. I’d love to hear from anyone who has successfully tackled a similar project or has suggestions on how to improve my current setup.

Any advice or examples would be greatly appreciated! Thanks in advance for your help.

Best regards,
[Your Name]