Skip to content

Add brightness, color, and scenes to ESPHome lights#58

Merged
derek-miller merged 1 commit into
mainfrom
feat/light-brightness
May 12, 2026
Merged

Add brightness, color, and scenes to ESPHome lights#58
derek-miller merged 1 commit into
mainfrom
feat/light-brightness

Conversation

@derek-miller
Copy link
Copy Markdown
Contributor

Summary

ESPHome lights are no longer treated as on/off only. The driver now
detects each entity's capabilities at runtime and exposes the appropriate
controls in Composer and Navigator.

  • Brightness / dimming with smooth ramps, preset and "Default On"
    mode handling, click and hold ramp rates, and hold-to-dim button
    control on virtual buttons and the On/Off/Toggle button-link bindings
  • Color and color-temperature for every ESPHome color mode (white,
    color-temperature, cold/warm white, RGB, RGBW, RGB+white,
    RGB+color-temperature, RGB+cold/warm white)
  • Advanced Lighting Scenes: lights can be scene members with
    brightness and color steps, ramp/stop, and flash mode

The parent ESPHome driver also notifies entity sub-drivers when the
device disconnects so they reset state correctly on reconnect.

Test plan

  • Eight dummy ESPHome lights covering every color mode (test/dummy_lights.yaml)
  • C4 → ESPHome: on/off, set level, brightness target with rate, color target (XY and CCT/Kelvin), button events, button-link DO_PUSH/DO_RELEASE/DO_CLICK
  • ESPHome → C4: brightness and color state propagation via aioesphomeapi
  • Disconnect / reconnect cycle (entity sub-drivers reset and re-discover)
  • Real Advanced Lighting Scenes agent → driver chain: scene created with member and element through the agent, activated, ESPHome state matches the configured brightness + color
  • Verified against a real ESPHome bulb

@derek-miller
Copy link
Copy Markdown
Contributor Author

@svc-finitelabs please review

Copy link
Copy Markdown
Contributor

@svc-finitelabs svc-finitelabs Bot left a comment

Choose a reason for hiding this comment

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

Nice piece of work overall. I pulled this locally and make init && make build passed.

I did find one behavior gap that I think should be fixed before merge:

  • UPDATE_COLOR_RATE_DEFAULT persists the user's default color ramp rate, but SET_COLOR_TARGET never reads it. Right now color changes fall back to 0 unless the caller explicitly sends a rate, so the Composer default color-rate setting has no effect.

Concretely, this is the path around drivers/esphome_light/driver.lua where SET_COLOR_TARGET uses:
tointeger(Select(tParams, "LIGHT_COLOR_TARGET_RATE") or Select(tParams, "RATE")) or 0

I think this should mirror the brightness path and fall back to the persisted default color rate when no per-command rate is provided.

@derek-miller
Copy link
Copy Markdown
Contributor Author

Thanks for the catch — fixed in dfe5812. SET_COLOR_TARGET now falls back to the persisted default color rate (set via UPDATE_COLOR_RATE_DEFAULT) when no per-command rate is provided, matching the brightness path.

Copy link
Copy Markdown
Contributor

@svc-finitelabs svc-finitelabs Bot left a comment

Choose a reason for hiding this comment

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

Thanks, this resolves the gap I called out. now mirrors the brightness path and falls back to the persisted default color rate when no per-command rate is supplied. I’m good with this pending CI.

svc-finitelabs[bot]
svc-finitelabs Bot previously approved these changes Apr 29, 2026
Copy link
Copy Markdown
Contributor

@svc-finitelabs svc-finitelabs Bot left a comment

Choose a reason for hiding this comment

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

Thanks, this resolves the gap I called out. SET_COLOR_TARGET now mirrors the brightness path and falls back to the persisted default color rate when no per-command rate is supplied. I am good with this pending CI.

svc-finitelabs[bot]
svc-finitelabs Bot previously approved these changes Apr 29, 2026
Copy link
Copy Markdown
Contributor

@svc-finitelabs svc-finitelabs Bot left a comment

Choose a reason for hiding this comment

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

Reviewed the latest synchronize commit. The SET_COLOR_TARGET path now falls back to the persisted default color rate via getDefaultColorRate(), which fixes the gap I called out earlier. CI is green on the updated branch.

@derek-miller derek-miller force-pushed the feat/light-brightness branch 2 times, most recently from 05c81cf to c128137 Compare May 1, 2026 15:18
Reimplement esphome_light against the LIGHT_V2 proxy spec so ESPHome
bulbs reach feature parity with Control4 dimmers:

- Brightness and dimming with smooth ramping (single ESPHome
  transition cmd plus local interpolation for STOP-mid-ramp), hold-to
  -dim button control, and preset management
- Color and color-temperature support for every ESPHome color mode
  (white, color-temperature, cold/warm white, RGB, RGBW, and combined
  RGB + white), including merged off-to-on color cmds for the
  color_on_mode fade/preset/previous behaviors
- Advanced Lighting Scenes so ESPHome bulbs participate alongside
  other Control4 dimmers
- Honor the persisted default color rate in SET_COLOR_TARGET
- Daylight-Agent integration: track and echo
  LIGHT_BRIGHTNESS_CURRENT_PRESET_ID and LIGHT_COLOR_CURRENT_PRESET_ID

Propagate disconnection state from the ESPHome parent driver to all
sub-drivers: the parent watches the connection and notifies entity
handlers on drop, light/fan/lock entities forward UPDATE_DISCONNECT
to their bindings, and fan/lock/climate/yale drivers emit
ONLINE_CHANGED with a proper boolean STATE.
@derek-miller derek-miller force-pushed the feat/light-brightness branch from c128137 to aff5681 Compare May 1, 2026 22:24
@derek-miller
Copy link
Copy Markdown
Contributor Author

@svc-finitelabs your approval is required

Copy link
Copy Markdown
Contributor

@svc-finitelabs svc-finitelabs Bot left a comment

Choose a reason for hiding this comment

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

Approved. CI green, test plan thoroughly exercised (8 dummy lights covering every color mode, real bulb verified, Advanced Lighting Scenes agent chain confirmed). Disconnect-notification pattern extends cleanly to climate/fan drivers, and the ONLINE_CHANGED state-type fix (string → bool) is a nice quiet correctness win along the way.

@derek-miller derek-miller merged commit eeb8fcb into main May 12, 2026
1 check passed
@derek-miller derek-miller deleted the feat/light-brightness branch May 12, 2026 01:31
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.

1 participant