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
| Name | Required | Description | Default |
|---|---|---|---|
| area_id | Yes | ||
| transition | No |
Implementation Reference
- src/ha.ts:172-188 (handler)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) }], } }, ) - src/tools.ts:27-30 (schema)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(), })