set_color
Change Nanoleaf smart light colors by specifying hue and saturation values to customize lighting ambiance in any space.
Instructions
Set the color of the Nanoleaf lights
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hue | Yes | Hue value (0-360) | |
| saturation | Yes | Saturation value (0-100) |
Implementation Reference
- src/index.ts:345-356 (handler)MCP server handler for 'set_color' tool: extracts hue and saturation arguments and calls NanoleafClient.setColor method
case 'set_color': const hue = request.params.arguments?.hue as number; const saturation = request.params.arguments?.saturation as number; await primaryDevice.setColor(hue, saturation); return { content: [ { type: 'text', text: `Color set to hue: ${hue}, saturation: ${saturation}`, }, ], }; - src/index.ts:100-117 (schema)Input schema defining required hue (0-360) and saturation (0-100) parameters for the set_color tool
inputSchema: { type: 'object', properties: { hue: { type: 'number', description: 'Hue value (0-360)', minimum: 0, maximum: 360, }, saturation: { type: 'number', description: 'Saturation value (0-100)', minimum: 0, maximum: 100, }, }, required: ['hue', 'saturation'], }, - src/index.ts:97-118 (registration)Registration of the 'set_color' tool in the ListTools response, including name, description, and schema
{ name: 'set_color', description: 'Set the color of the Nanoleaf lights', inputSchema: { type: 'object', properties: { hue: { type: 'number', description: 'Hue value (0-360)', minimum: 0, maximum: 360, }, saturation: { type: 'number', description: 'Saturation value (0-100)', minimum: 0, maximum: 100, }, }, required: ['hue', 'saturation'], }, }, - src/nanoleaf-client.ts:177-188 (helper)NanoleafClient helper method implementing the actual HTTP API call to set hue and saturation on the device state
async setColor(hue: number, saturation: number): Promise<void> { if (hue < 0 || hue > 360) { throw new Error('Hue must be between 0 and 360'); } if (saturation < 0 || saturation > 100) { throw new Error('Saturation must be between 0 and 100'); } await this.httpClient.put(this.getAuthUrl('/state'), { hue: { value: hue }, sat: { value: saturation } }); }