Skip to content

Conversation

@bdraco
Copy link
Member

@bdraco bdraco commented Nov 7, 2025

Summary

Adds blog post documenting breaking changes in Light entity class (esphome/esphome#11487, esphome/esphome#11348).

Breaking changes:

  • Effect name storage changed from std::string to const char* (saves string allocation overhead per effect) - External components likely affected
  • Color mode storage changed from std::set<ColorMode> to ColorModeMask (~586 bytes for red-black tree overhead) - Mostly backward compatible (ColorModeMask provides .count(), .insert(), .erase() for std::set compatibility; no core components needed changes; breaking edge case: explicitly passing std::set to set_supported_color_modes() will fail)
  • External components with custom effects must update constructors

Blog post includes complete migration guide covering both changes, lifetime safety patterns for effect names, ColorModeMask usage details, and grep commands. Includes:

  • Effect constructor migration (std::string → const char*)
  • ColorModeMask backward compatibility (.count(), .insert(), .erase() still work)
  • Capability check improvements (manual loop → supports_color_capability())
  • Iterator support for ColorModeMask
  • Motivation about limited heap for ESP8266 devices

@netlify
Copy link

netlify bot commented Nov 7, 2025

Deploy Preview for esphome-dev-docs ready!

Name Link
🔨 Latest commit 060dc7b
🔍 Latest deploy log https://app.netlify.com/projects/esphome-dev-docs/deploys/6912892c7234ca00096c4e2e
😎 Deploy Preview https://deploy-preview-70--esphome-dev-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@bdraco bdraco marked this pull request as ready for review November 7, 2025 17:11
Copilot AI review requested due to automatic review settings November 7, 2025 17:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive documentation for memory optimizations introduced in ESPHome 2025.11.0 for the Light entity class, focusing on two key changes: storing effect names in flash memory instead of heap, and using bitmasks instead of red-black trees for color mode storage.

  • Documents breaking changes for effect name storage (std::string to const char*)
  • Documents backward-compatible changes for color mode storage (std::set to ColorModeMask)
  • Provides migration guide and examples for external component developers

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
docs/blog/posts/2025-11-07-light-entity-optimizations.md New blog post documenting Light entity memory optimizations with detailed migration guide
docs/blog/.authors.yml Adds bdraco as a blog post author with maintainer credentials

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

auto effect = new MyEffect(EFFECT_NAME);

// 3. C arrays
static constexpr const char *const EFFECT_NAMES[] = {"Rainbow", "Pulse"};
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

The declaration uses both 'static constexpr' and 'const' keywords redundantly. For a constexpr array of string literals, 'static constexpr const char* const EFFECT_NAMES[]' is correct, but the outer 'const' after the asterisk is unnecessary since 'constexpr' already implies 'const'. Consider simplifying to 'static constexpr const char* EFFECT_NAMES[]'.

Suggested change
static constexpr const char *const EFFECT_NAMES[] = {"Rainbow", "Pulse"};
static constexpr const char *EFFECT_NAMES[] = {"Rainbow", "Pulse"};

Copilot uses AI. Check for mistakes.
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.

3 participants