ha_area_lights_on
Turn on all lights in a specified area with optional brightness percentage and transition time.
Instructions
Turn on all lights in an area (by area_id).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| area_id | Yes | ||
| brightness_pct | No | ||
| transition | No |
Implementation Reference
- src/ha.ts:190-212 (handler)The actual handler logic: turnOnAreaLights method that filters light entities by area_id and calls the Home Assistant 'light.turn_on' service with optional brightness_pct and transition params.
async turnOnAreaLights(params: { area_id: string, brightness_pct?: number, 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 } const data: Record<string, unknown> = { entity_id: entityIds, } if (typeof params.brightness_pct === 'number') data.brightness_pct = params.brightness_pct if (typeof params.transition === 'number') data.transition = params.transition await this.callService('light', 'turn_on', data) return { ok: true, changed: entityIds.length } - src/tools.ts:32-36 (schema)Zod schema for the tool input: area_id (required), brightness_pct (optional, 0-100), transition (optional number).
export const AreaLightsOnInput = z.object({ area_id: z.string().min(1), brightness_pct: z.number().min(0).max(100).optional(), transition: z.number().optional(), }) - src/index.ts:169-179 (registration)Registration of the 'ha_area_lights_on' tool on the MCP server instance with name, description, input schema, and handler callback.
server.tool( 'ha_area_lights_on', 'Turn on all lights in an area (by area_id).', AreaLightsOnInput.shape, async (input) => { const res = await ha.turnOnAreaLights(input) return { content: [{ type: 'text', text: JSON.stringify(res, null, 2) }], } }, ) - src/index.ts:8-8 (helper)Import of AreaLightsOnInput schema from './tools.js' into the registration file.
import {