Skip to content

feat: Add effects_v2 schema for custom effect color and speed#47

Merged
thibauult merged 3 commits into
openhue:mainfrom
Roach:feat/effects-v2-schema
Apr 15, 2026
Merged

feat: Add effects_v2 schema for custom effect color and speed#47
thibauult merged 3 commits into
openhue:mainfrom
Roach:feat/effects-v2-schema

Conversation

@Roach

@Roach Roach commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

Summary

The Hue bridge exposes an undocumented effects_v2 property on the Light resource that allows setting custom color, color temperature, and speed parameters on firmware-level effects (candle, fire, prism, sparkle, opal, glisten, underwater, cosmos, sunbeam, enchant).

This is distinct from the existing effects property which only accepts an effect enum with no additional parameters.

Payload format

PUT /resource/light/{id}
{
  "effects_v2": {
    "action": {
      "effect": "fire",
      "parameters": {
        "color": { "xy": { "x": 0.35, "y": 0.15 } },
        "speed": 0.8
      }
    }
  }
}

Read response

When an effect is active, effects_v2.status returns the resolved parameters:

{
  "effects_v2": {
    "action": {
      "effect_values": ["no_effect", "candle", "fire", "prism", ...]
    },
    "status": {
      "effect": "fire",
      "effect_values": ["no_effect", "candle", "fire", "prism", ...],
      "parameters": {
        "color": { "xy": { "x": 0.35, "y": 0.15 } },
        "color_temperature": { "mirek": 153, "mirek_valid": false },
        "speed": 0.8016
      }
    }
  }
}

Key behaviors observed

  • When effects_v2 is used with custom color, the effect animation runs in the specified color instead of its default
  • Without parameters, effects use their default colors (e.g., warm amber for fire, rainbow for prism)
  • speed defaults to 0.5; range is 0.0 (slowest) to 1.0 (fastest)
  • The color_temperature.mirek_valid field indicates whether the effect is operating in the CT color space
  • Setting color via the basic color property while an effect is active cancels the effect; effects_v2 avoids this by bundling color with the effect activation

Changes

  • New EffectsV2.yaml — schema for the effects_v2 property with action and status objects
  • New EffectsV2Parameters.yaml — shared schema for effect parameters (color, color_temperature, speed)
  • Updated LightGet.yaml — added effects_v2 to the GET response
  • Updated LightPut.yaml — added effects_v2 to the PUT request

Testing

Verified against a Hue bridge with Gen 3+ color-capable lights (Gamut C). All 11 supported effects tested with custom color parameters.

Summary by CodeRabbit

New Features

  • Introduced a new effects control system for lights with enhanced customization capabilities
  • Added comprehensive parameter controls for light effects including color adjustment, color temperature tuning, and animation speed modification
  • Improved effect management and state reporting infrastructure to support more sophisticated lighting control scenarios

The Hue bridge exposes an undocumented `effects_v2` property on the
Light resource that enables custom color, color temperature, and speed
parameters for firmware-level effects (candle, fire, prism, etc.).

Unlike the basic `effects` property which only accepts an effect enum,
`effects_v2` accepts an `action` object with a `parameters` field:

  PUT /resource/light/{id}
  {
    "effects_v2": {
      "action": {
        "effect": "fire",
        "parameters": {
          "color": { "xy": { "x": 0.35, "y": 0.15 } },
          "speed": 0.8
        }
      }
    }
  }

Tested against bridge firmware with color-capable lights. The status
object mirrors the action structure and reports the active effect's
parameters including the resolved color, color_temperature, and speed.
@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Roach has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 44 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 44 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a885061d-68f4-45e9-ac20-28d9375466d7

📥 Commits

Reviewing files that changed from the base of the PR and between c76e22c and 87cac4e.

📒 Files selected for processing (3)
  • src/light/schemas/EffectsV2.yaml
  • src/light/schemas/EffectsV2Parameters.yaml
  • src/light/schemas/LightGet.yaml
📝 Walkthrough

Walkthrough

The pull request introduces a new effects control system (V2) by adding two schema files that define effect configuration and parameters, then integrating them into the existing light get/put endpoints through schema references.

Changes

Cohort / File(s) Summary
Effects V2 Schema Definitions
src/light/schemas/EffectsV2.yaml, src/light/schemas/EffectsV2Parameters.yaml
New schema files defining the extended effect control structure with action (write-only) and status (read-only) properties, plus parameters for effect appearance control including color, color temperature, and speed.
Light Endpoint Integration
src/light/schemas/LightGet.yaml, src/light/schemas/LightPut.yaml
Added effects_v2 property references to integrate the new EffectsV2 schema into light get and put endpoints.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • thibauult

Poem

🐰 Hops with delight at effects so bright,
V2 schemas shimmer in digital light,
Colors and speeds dance in harmony true,
Action and status—the old made anew!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding a new effects_v2 schema that supports custom effect color and speed parameters, which aligns with the core focus of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Fix dynamics.speed maximum: 0 → 1 (was incorrectly constrained)
- Replace alert TODO stub with actual schema (action_values array)
- Add product_data object (light function: functional/decorative/mixed/unknown)
- Add geometry object (pixel_positions for gradient strip pixel mapping)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/light/schemas/EffectsV2.yaml`:
- Around line 7-30: Add machine-enforceable read/write semantics: mark the
action object and its writable properties as writeOnly and the status object and
its readable properties as readOnly. Specifically, set writeOnly: true for the
action object and for action.effect and action.parameters (but remove
action.effect_values entirely since capability metadata must not be writable),
and set readOnly: true for the status object and for status.effect and
status.effect_values so capability metadata remains read-only there. Ensure the
$ref entries (effect, effect_values, parameters) remain but with the appropriate
writeOnly/readOnly flags applied to the surrounding schema nodes (action,
status, action.parameters, status.effect_values).

In `@src/light/schemas/EffectsV2Parameters.yaml`:
- Around line 11-13: The field mirek_valid in the shared schema
EffectsV2Parameters.yaml is server-derived and must be response-only; update the
mirek_valid property to include readOnly: true so it is omitted from request
payloads (action.parameters) but still present in responses (status.parameters),
preserving the existing type and description.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 353de1bb-4868-4219-ba6d-6a42b72e01fd

📥 Commits

Reviewing files that changed from the base of the PR and between 5548942 and c76e22c.

📒 Files selected for processing (4)
  • src/light/schemas/EffectsV2.yaml
  • src/light/schemas/EffectsV2Parameters.yaml
  • src/light/schemas/LightGet.yaml
  • src/light/schemas/LightPut.yaml

Comment on lines +7 to +30
action:
type: object
description: Write-only. Set effect with optional parameters.
properties:
effect:
$ref: '../../common/SupportedEffects.yaml'
effect_values:
type: array
description: Possible effect values supported by this light.
items:
$ref: '../../common/SupportedEffects.yaml'
parameters:
$ref: './EffectsV2Parameters.yaml'
status:
type: object
description: Read-only. Current effect status and active parameters.
properties:
effect:
$ref: '../../common/SupportedEffects.yaml'
effect_values:
type: array
description: Possible effect values supported by this light.
items:
$ref: '../../common/SupportedEffects.yaml'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "EffectsV2.yaml" -type f

Repository: openhue/openhue-api

Length of output: 97


🏁 Script executed:

cat -n ./src/light/schemas/EffectsV2.yaml

Repository: openhue/openhue-api

Length of output: 1440


🏁 Script executed:

rg "EffectsV2.yaml" --type yaml

Repository: openhue/openhue-api

Length of output: 188


🏁 Script executed:

cat -n ./src/light/schemas/LightGet.yaml

Repository: openhue/openhue-api

Length of output: 12327


🏁 Script executed:

cat -n ./src/light/schemas/LightPut.yaml

Repository: openhue/openhue-api

Length of output: 1783


🏁 Script executed:

rg "readOnly|writeOnly" --type yaml

Repository: openhue/openhue-api

Length of output: 45


🏁 Script executed:

find . -name "openapi.yaml" -o -name "openapi.yml" -o -name "swagger.yaml" | head -5

Repository: openhue/openhue-api

Length of output: 45


🏁 Script executed:

find . -name "*.yaml" -path "*/src/*" | head -20

Repository: openhue/openhue-api

Length of output: 941


🏁 Script executed:

cat -n ./src/light/light_{lightId}.yaml

Repository: openhue/openhue-api

Length of output: 4102


🏁 Script executed:

find ./src -name "*.yaml" -type f | xargs grep -l "status_values\|effect_values" | head -10

Repository: openhue/openhue-api

Length of output: 131


🏁 Script executed:

cat -n ./src/light/schemas/Effects.yaml

Repository: openhue/openhue-api

Length of output: 236


🏁 Script executed:

cat -n ./src/light/schemas/LightDynamics.yaml

Repository: openhue/openhue-api

Length of output: 587


🏁 Script executed:

cat -n ./src/light/schemas/SupportedTimedEffects.yaml

Repository: openhue/openhue-api

Length of output: 235


🏁 Script executed:

cat -n ./src/light/schemas/Powerup.yaml

Repository: openhue/openhue-api

Length of output: 2909


🏁 Script executed:

ls -la ./src/light/schemas/ | grep -i "get\|put"

Repository: openhue/openhue-api

Length of output: 190


🏁 Script executed:

cat -n ./src/common/On.yaml

Repository: openhue/openhue-api

Length of output: 239


Add machine-enforceable read/write semantics to action and status properties.

Line 9 and 22 describe mutability only in prose. Without writeOnly and readOnly flags, OpenAPI tooling and code generators cannot enforce access semantics. Additionally, action.effect_values (lines 13-17) represents capability metadata and should not appear in the writable action object.

Proposed fix
 properties:
   action:
     type: object
+    writeOnly: true
     description: Write-only. Set effect with optional parameters.
     properties:
       effect:
         $ref: '../../common/SupportedEffects.yaml'
-      effect_values:
-        type: array
-        description: Possible effect values supported by this light.
-        items:
-          $ref: '../../common/SupportedEffects.yaml'
       parameters:
         $ref: './EffectsV2Parameters.yaml'
   status:
     type: object
+    readOnly: true
     description: Read-only. Current effect status and active parameters.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
action:
type: object
description: Write-only. Set effect with optional parameters.
properties:
effect:
$ref: '../../common/SupportedEffects.yaml'
effect_values:
type: array
description: Possible effect values supported by this light.
items:
$ref: '../../common/SupportedEffects.yaml'
parameters:
$ref: './EffectsV2Parameters.yaml'
status:
type: object
description: Read-only. Current effect status and active parameters.
properties:
effect:
$ref: '../../common/SupportedEffects.yaml'
effect_values:
type: array
description: Possible effect values supported by this light.
items:
$ref: '../../common/SupportedEffects.yaml'
action:
type: object
writeOnly: true
description: Write-only. Set effect with optional parameters.
properties:
effect:
$ref: '../../common/SupportedEffects.yaml'
parameters:
$ref: './EffectsV2Parameters.yaml'
status:
type: object
readOnly: true
description: Read-only. Current effect status and active parameters.
properties:
effect:
$ref: '../../common/SupportedEffects.yaml'
effect_values:
type: array
description: Possible effect values supported by this light.
items:
$ref: '../../common/SupportedEffects.yaml'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/light/schemas/EffectsV2.yaml` around lines 7 - 30, Add
machine-enforceable read/write semantics: mark the action object and its
writable properties as writeOnly and the status object and its readable
properties as readOnly. Specifically, set writeOnly: true for the action object
and for action.effect and action.parameters (but remove action.effect_values
entirely since capability metadata must not be writable), and set readOnly: true
for the status object and for status.effect and status.effect_values so
capability metadata remains read-only there. Ensure the $ref entries (effect,
effect_values, parameters) remain but with the appropriate writeOnly/readOnly
flags applied to the surrounding schema nodes (action, status,
action.parameters, status.effect_values).

Comment thread src/light/schemas/EffectsV2Parameters.yaml
- Add writeOnly: true to action object (request-only)
- Add readOnly: true to status object and its properties (response-only)
- Remove effect_values from action (capability metadata, not writable)
- Add readOnly: true to mirek_valid (server-derived field)
@thibauult thibauult self-assigned this Apr 15, 2026
@thibauult thibauult self-requested a review April 15, 2026 08:23
@thibauult thibauult removed their assignment Apr 15, 2026

@thibauult thibauult left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍🏻 Thanks for you first contribution!

@thibauult thibauult merged commit 1ffc817 into openhue:main Apr 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants