Skip to main content
Glama

Add grid consumption flow

energy_add_grid_consumption

Register 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

TableJSON Schema
NameRequiredDescriptionDefault
stat_costNoOptional 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_fromYesStatistic/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

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.25.1
    • addedInput schema / properties / stat_cost / description
      Added value: +"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."
    • addedInput schema / properties / stat_energy_from / description
      Added value: +"Statistic/entity ID of the grid-import energy sensor to add, e.g. 'sensor.grid_energy_import'. Discover candidates with `statistics_list_statistic_ids`."
  2. First observedv0.3.0

TDQS

A4.8/5.0
Behavior5/5

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

Annotations cover the safety profile (readOnlyHint=false, destructiveHint=false), but the description adds material context beyond them: the read-modify-write sequence via energy/get_prefs and energy/save_prefs, the fact that the grid source is auto-created if absent, the duplicate-entry behavior of re-calling with the same ID, and the error shape.

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

Conciseness4/5

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

Well front-loaded with labeled Use when / Not for / Returns / Errors sections, so an agent can scan it quickly. Slightly long because it narrates internal WS call mechanics, but every sentence still carries usable information.

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?

Despite an output schema existing, the description still documents the success payload and the error object, and it fully covers the prerequisite state (existing or absent grid source) plus the duplicate-call caveat, leaving nothing an agent needs missing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds meaning beyond the schema by explaining that stat_energy_from (and stat_cost if supplied) become a new flow_from entry appended to the existing grid source, clarifying the role each parameter plays in the mutation.

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?

The description states a specific verb and resource ('Add a grid consumption flow to the Energy Dashboard's grid source') and precisely distinguishes it from the two nearest siblings: energy_add_grid_return for export, and energy_save_energy_prefs for full list replacement.

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?

It gives explicit 'Use when' (registering a grid-import sensor as a consumption flow) and 'Not for' guidance that names the exact alternative tool for each excluded case, leaving no routing ambiguity.

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