Add grid return flow
energy_add_grid_returnAdd a grid return (export) flow to Home Assistant's Energy Dashboard. Links a solar-export sensor to the grid source, creating that source if none exists yet.
Instructions
Add a grid return (export) flow to the Energy Dashboard's grid source.
Reads the current preferences via ha._ws_call("energy/get_prefs"),
appends stat_energy_to (and stat_compensation if given) as a new
flow_to entry on the existing grid source, creating that grid source
first if none exists yet, then saves via WS energy/save_prefs. Calling
it twice with the same stat_energy_to adds a second, duplicate entry.
Use when: registering a solar-export or other grid-return sensor, e.g.
solar sold back to the grid.
Not for: grid import — use energy_add_grid_consumption; for a full
source-list replacement use energy_save_energy_prefs.
Returns: {"status": "added", "stat_energy_to": ..., "result": ...}.
Errors: {"error": str(e), "stat_energy_to": ...} when either WS call
raises.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stat_energy_to | Yes | Statistic/entity ID of the grid-export energy sensor to add, e.g. 'sensor.solar_export'. Discover candidates with `statistics_list_statistic_ids`. | |
| stat_compensation | No | Optional statistic/entity ID of the matching compensation/cost sensor for this export flow. Omit if no compensation sensor should be linked. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||