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