The AI only knows how to turn a light on or off
I would like to add brightness control, for example « set the brightness of the living room bulb to 30 % »
and also color temperature adjustment, for example « set the color temperature of the office light to « cool white » (6500 °K) or « neutral white » (4000°K) or « warm white » (2700 °K) »
color setting: for example « bedroom lamp in blue »
Thanks for the request!
It’s developed in this PR:
master ← cursor/ai-light-brightness-color-temperature-d88c
ouvert 09:44AM - 20 Jul 26 UTC
## Description
Implements the feature request from the community forum: [Concer… nant l'IA : luminosité/température/couleur d'une ampoule](https://community.gladysassistant.com/t/concernant-lia-luminosite-temperature-couleur-dune-ampoule/10352).
Until now the AI assistant could only turn lights on or off (`device_turn_on_off` on `light:binary` features). This PR adds a new `device.set-light` MCP tool (exposed to the AI chat as `device_set_light`) so the assistant can handle requests like:
- "Set the brightness of the living room bulb to 30%"
- "Set the office light to cool white (6500K) / neutral white (4000K) / warm white (2700K)"
- "Bedroom lamp in blue"
## Changes
- **`server/services/mcp/lib/selectFeature.js`**: new `isLightControlFeature` helper matching `light:brightness`, `light:color` and `light:temperature` features.
- **`server/services/mcp/lib/buildSchemas.js`**: new `device.set-light` tool (registered only when at least one light control feature exists):
- `brightness` as a percentage (0-100), normalized to the feature `min`/`max` range;
- `color` as a hex RGB string (with or without `#`), converted to the integer color value;
- `temperature` in Kelvin, converted to mired and clamped to the feature `min`/`max` range (same convention as the Google Actions ColorSetting trait);
- target selection by device name or by room (all lights of the room), mirroring `device.set-shutter`.
- Light control features are now also exposed in the `schema://home` resource and in `device.get-state`, so the AI can read the current brightness/color/temperature.
- **`server/services/mcp/lib/formatValue.js`**: `light:color` states are reported as hex colors (e.g. `#0000ff`) instead of a raw integer, which the model can interpret.
- **`server/config/prompts/aiChat.prompt.txt`**: prompt rule directing the model to `device_set_light` for brightness/color/temperature requests.
## Tests
- New tests in `server/test/services/mcp/lib/buildSchemas.test.js` covering the home schema exposure, the happy paths (brightness normalization, hex color conversion, Kelvin→mired conversion with clamping on both ends), room/device targeting, and every error branch (missing values, missing target, unknown device, empty room, missing features, partial dispatch).
- New tests in `server/test/services/mcp/lib/formatValue.test.js` for the hex color formatting (including `null` last value).
<div><a href="https://cursor.com/agents/bc-b30f67e3-6144-40c3-95c2-70888b4cd88c"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/background-agent?bcId=bc-b30f67e3-6144-40c3-95c2-70888b4cd88c"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
## Summary by CodeRabbit
* **New Features**
* Added light-control support for brightness, color, and color temperature.
* Added controls for setting light properties by device or room.
* Light colors are displayed in hexadecimal format.
* Light-control devices and capabilities now appear in available device information.
* **Bug Fixes**
* Improved handling and validation of brightness, color, and temperature values, including supported device limits.
* Clarified that on/off controls toggle lights, while property changes use dedicated light settings.
It will be included in the next version of Gladys
It’s available in Gladys Assistant 4.84:
Hello everyone !
I’m really excited to release tonight a version that, I think, will really change the pace of the project’s evolution.
External integrations are finally coming to Gladys! They will allow us to enrich the list of compatible devices and services much faster, while allowing everyone to develop and share their own integrations.
I explain everything in this article