Skip to main content
Glama

Add grid return flow

energy_add_grid_return

Add 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

NameRequiredDescriptionDefault
stat_energy_toYesStatistic/entity ID of the grid-export energy sensor to add, e.g. 'sensor.solar_export'. Discover candidates with `statistics_list_statistic_ids`.
stat_compensationNoOptional statistic/entity ID of the matching compensation/cost sensor for this export flow. Omit if no compensation sensor should be linked.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.25.1
    • addedInput schema / properties / stat_compensation / description
      Added value: +"Optional statistic/entity ID of the matching compensation/cost sensor for this export flow. Omit if no compensation sensor should be linked."
    • addedInput schema / properties / stat_energy_to / description
      Added value: +"Statistic/entity ID of the grid-export energy sensor to add, e.g. 'sensor.solar_export'. Discover candidates with `statistics_list_statistic_ids`."
  2. First observedv0.3.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Beyond the annotations (which only declare non-read-only, non-idempotent, non-destructive), it discloses the internal WS sequence (energy/get_prefs then energy/save_prefs), auto-creation of a grid source when none exists, and the duplicate-entry caveat on repeated calls with the same stat_energy_to. It also gives return and error shapes. This is rich behavioral context the annotations cannot convey.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the action, then clearly labeled Use when / Not for / Returns / Errors sections. Every sentence carries distinct information; there is no filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a mutation tool with an output schema and annotations present, the definition is complete: mechanism, prerequisites, duplicate risk, alternatives, and both success and error response shapes are covered. Nothing needed to call it safely is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already defines both parameters fully. The description adds the mapping into the prefs structure ('appends stat_energy_to (and stat_compensation if given) as a new flow_to entry'), but that is marginal beyond the schema. Baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb+resource ('Add a grid return (export) flow to the Energy Dashboard's grid source') and explicitly names the sibling it is not ('Not for: grid import — use energy_add_grid_consumption'). An agent can route correctly without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Contains explicit 'Use when' (registering a solar-export/grid-return sensor) and 'Not for' sections that name two alternative tools (energy_add_grid_consumption for import, energy_save_energy_prefs for full source-list replacement). Both selection conditions are spelled out.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools