Skip to main content
Glama
TheWhykiki

hass-mcp

by TheWhykiki

ha_area_lights_off

Turn off all lights in an area by providing the area ID. Optionally set a transition duration for a smooth fade.

Instructions

Turn off all lights in an area (by area_id).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
area_idYes
transitionNo

Implementation Reference

  • The actual handler logic for turning off all lights in an area. It fetches entity registry entries, filters by area_id and light domain, then calls light.turn_off service.
    async turnOffAreaLights(params: { area_id: string, transition?: number }) {
      const entries = await this.listEntityRegistry()
      const entityIds = entries
        .filter(e => e.area_id === params.area_id)
        .map(e => e.entity_id)
        .filter(eid => eid.startsWith('light.'))
    
      if (entityIds.length === 0)
        return { ok: true, changed: 0 }
    
      await this.callService('light', 'turn_off', {
        entity_id: entityIds,
        ...(typeof params.transition === 'number' ? { transition: params.transition } : {}),
      })
    
      return { ok: true, changed: entityIds.length }
    }
  • src/index.ts:157-167 (registration)
    The tool registration on the MCP server using server.tool() with name 'ha_area_lights_off'.
    server.tool(
      'ha_area_lights_off',
      'Turn off all lights in an area (by area_id).',
      AreaLightsOffInput.shape,
      async (input) => {
        const res = await ha.turnOffAreaLights(input)
        return {
          content: [{ type: 'text', text: JSON.stringify(res, null, 2) }],
        }
      },
    )
  • Zod schema for the tool's input: area_id (required string) and transition (optional number).
    export const AreaLightsOffInput = z.object({
      area_id: z.string().min(1),
      transition: z.number().optional(),
    })
Behavior3/5

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

With no annotations provided, the description carries the full burden of disclosure. It accurately states the action ('turn off'), implying a mutation operation. However, it does not mention potential side effects, error handling (e.g., invalid area_id), or any non-obvious behavior beyond what the name suggests.

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?

The description is a single, focused sentence with no wasted words. It is front-loaded with the main action and parameter. This is an ideal length for a simple tool.

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

Completeness2/5

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

Given the tool has two parameters (one undocumented) and no output schema, the description is incomplete. It lacks details on the transition parameter, return values (presumably none), and edge cases. For a mutation tool with no annotations, more context is needed.

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate. It explains that area_id identifies the area, but does not describe the optional transition parameter (a number, likely for fade time). This leaves a significant gap in understanding how to use the tool effectively.

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 clearly states the tool's purpose: 'Turn off all lights in an area (by area_id).' The verb 'Turn off' and resource 'all lights in an area' are specific and unambiguous. It effectively distinguishes from sibling tools like ha_area_lights_on and ha_light_turn_off.

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

Usage Guidelines3/5

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

The description implicitly suggests use for turning off all lights in a given area, but it does not explicitly specify when to use this tool versus alternatives like ha_light_turn_off for individual lights. No guidance on prerequisites or context is provided.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TheWhykiki/hass-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server