I did a bit of digging after writing this (also after testing my own PR to add an inverted power sensor) and found that there is a frontend PR to add an option in HA to address this:
dev ← TCWORLD:power-invert-opt
opened 11:37PM - 06 Dec 25 UTC
In #27373 the option to track power as well as energy was added. In the case of … the Grid and Battery power sources, these are added as a single bi-directional sensor which requires a specific polarity to be meaningful. However not all integrations or hardware use the expected polarity meaning additional template sensors would need to be created to negate these values before they could be used with the energy dashboard.
## Proposed change
In this PR, and the associated core PR, we add the option to invert the polarity of a power sensor used for grid/battery/solar power data. This is saved in the preferences as stat_rate_negate alongside with the stat_rate entity id.
In the dialog entries, a check-box is added to select whether to invert the polarity.
<img width="300" alt="Battery power with checked invert option" src="https://github.com/user-attachments/assets/589d53e9-0177-4d23-947d-ccb1fbb2e390" />
<img width="300" alt="Solar power with unchecked invert option" src="https://github.com/user-attachments/assets/47a6f185-5d99-451e-89a7-01469cd30b69" />
<img width="300" alt="Grid power with unchecked invert option" src="https://github.com/user-attachments/assets/e9140c13-544c-4b5a-8cdc-41c7cd890f12" />
The scope was limited to these two sources as they are likely to be bidirectional. Solar and individual loads are unlikely to need inverting, though that could be added at a later date.
## Type of change
- [ ] Dependency upgrade
- [ ] Bugfix (non-breaking change which fixes an issue)
- [x] New feature (thank you!)
- [ ] Breaking change (fix/feature causing existing functionality to break)
- [ ] Code quality improvements to existing code or addition of tests
## Additional information
- Core pull request: https://github.com/home-assistant/core/pull/158142
- This PR fixes or closes issue: fixes #
- This PR is related to issue or discussion: https://github.com/orgs/home-assistant/discussions/1915
- Link to documentation pull request:
There was a similar proposal to add a direction toggle in the comments of the original PR: https://github.com/home-assistant/core/pull/153809#issuecomment-3401538017
## Checklist
- [x] The code change is tested and works locally.
- [x] There is no commented out code in this PR.
- [ ] Tests have been added to verify that the new code works.
If user exposed functionality or configuration variables are added/changed:
- [ ] Documentation added/updated for [www.home-assistant.io][docs-repository]
[docs-repository]: https://github.com/home-assistant/home-assistant.io