3.1 KiB · text History 04ed4f9

XY Color Space Implementation Summary

Changes Made to EntityControl.qml

1. Added XY Color Space Properties

  • supportsXy: Detects XY color mode support
  • currentXyColor: Current XY coordinates from entity state
  • currentHue: Converted hue value (0-360°)
  • currentSaturation: Converted saturation value (0-1)

2. Updated Advanced Controls Detection

  • Modified hasAdvancedControls to include supportsXy

3. New XY Color Control UI Section

// XY Color Control (CIE 1931) with HUE Slider
ColumnLayout {
    visible: supportsXy && isOn
    // Hue slider with rainbow gradient
    // Saturation slider with dynamic gradient
    // XY color preset buttons (6 colors)
    // Current XY color indicator
}

4. Added Entity Information Display

  • Shows current XY coordinates in format “(x.xxxx, y.yyyy)”
  • Only visible when XY color data is available

5. Implemented Color Conversion Functions

  • xyToRgb(x, y): XY to RGB conversion with proper sRGB transformation
  • xyToRgbColor(x, y): XY to Qt color object
  • xyToHue(x, y): XY to HSV hue conversion
  • xyToSaturation(x, y): XY to HSV saturation conversion
  • hueToXy(hue, saturation): HSV to XY conversion
  • hueToRgbColor(hue): Hue to RGB color for gradients

6. Updated Import Statements

  • Fixed missing version numbers in Qt/KDE imports

Key Features

Hue Slider

  • Range: 0-360 degrees
  • Rainbow gradient background showing color spectrum
  • Real-time XY coordinate updates on change

Saturation Slider

  • Range: 0-100%
  • Gradient from white to current hue at full saturation
  • Dynamic gradient updates based on current hue

Color Presets

  • 6 carefully chosen XY coordinates for common colors
  • Visual highlight when current color matches preset
  • Tooltips showing color name and XY coordinates

Current Color Display

  • Shows current XY coordinates with 4-decimal precision
  • Color preview rectangle with proper text contrast
  • Automatically calculates best text color (black/white)

Technical Implementation

Color Space Accuracy

  • Uses proper CIE 1931 XY chromaticity coordinates
  • sRGB transformation matrices for accurate conversion
  • Gamma correction for proper color representation
  • D65 white point as fallback ([0.3127, 0.3290])

Performance Optimizations

  • Color conversions only calculated when needed
  • Slider value clamping to valid ranges
  • Efficient gradient generation for smooth UI

Home Assistant Integration

  • Sends xy_color parameter to light.turn_on service
  • Compatible with Philips Hue, LIFX, and other XY-capable lights
  • Maintains compatibility with existing RGB/CCT modes

Files Created

  1. XY_COLOR_DOCUMENTATION.md - Comprehensive documentation
  2. XY_COLOR_EXAMPLES.js - Usage examples and test code

Compatibility

  • Works with existing EntityControl configurations
  • Automatically shows/hides based on light capabilities
  • No breaking changes to existing functionality
  • Supports lights with multiple color modes (RGB + XY + CCT)

Testing

  • Mock entity state examples provided
  • Color conversion test functions included
  • Common XY coordinates reference table
  • Gamut validation foundation for future enhancements