Skip to content

ESPHome 2026.5.0 compatibility #164

Description

@KrzysztofHajdamowicz

Follow-up from #158
Looks like ESPHome continues to evolve its codebase and we need to adapt: https://esphome.io/changelog/2026.5.0/
I'm not a C developer, I can read it but can't write and I'm using Claude in this area.
What Claude found is:

I have a clear picture. Let me summarize before making fixes:

What's already done in your working tree (looks correct against 2026.5.0):

  • set_supports_*add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE)
  • std::set<ClimateMode>climate::ClimateModeMask with .insert()
  • LgSelect::control already uses current_option() instead of deprecated Select::state
  • Pipe-temp sensors switched from runtime set_internal() toggling to publishing NAN ✓

What's broken in your working tree (won't compile on 2026.5.0):
EntityBase::internal_ no longer exists. In 2026.5.0 it's flags_.internal (a 1-bit field in a protected EntityFlags bit-packed struct). So both:

  • LgSwitch/LgSelect/LgNumber::mark_internal() referencing this->internal_
  • EntityInternalAccess taking &EntityInternalAccess::internal_

…will fail to compile. The set_internal() deprecation note also says the runtime call is "undefined behavior at runtime — components and Home Assistant are NOT notified", but the existing component already relies on that pattern, so the minimal upstream-friendly fix is to swap internal_flags_.internal.

Other 2026.5.0 changes that don't apply here: RingBuffer relocation, alloc_helpers split (you use format_hex_pretty which stays), OneWireBus, PollingComponent constructor, ComponentIterator media-player, OTA port consolidation — none touch this component.

and

The fix is in place. Here's a summary of the proposed upstream patch for esphome/components/lg_controller/lg-controller.h to support ESPHome 2026.5.0:

Two categories of change

  1. set_internal() deprecation (the only true 2026.5.0 blocker)
  • EntityBase::set_internal() is [[deprecated]] in 2026.3.0, slated for removal in 2027.3.0.
  • The underlying internal_ field was replaced by a 1-bit internal field inside a protected, bit-packed EntityFlags flags_ struct.
  • For LgSwitch/LgSelect/LgNumber (custom subclasses) we add a mark_internal() helper that writes this->flags_.internal directly.
  • For entities the component doesn't subclass (e.g. the plain binary_sensor::BinarySensor* auto_dry_active), we use a small EntityInternalAccess : EntityBase shim that takes a pointer-to-member to the protected flags_ field, so we can poke flags_.internal from outside the class hierarchy.
  • pipe_temp_* sensors stopped using runtime internal-toggling entirely and now publish NAN when no value is available — semantically cleaner.
  1. Carry-over fixes already in your tree from earlier ESPHome releases (not 2026.5.0):
  • ClimateTraits::set_supports_*add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE).
  • set_supported_modes/fan_modes/swing_modes now take ClimateModeMask/ClimateFanModeMask/ClimateSwingModeMask (a FiniteSetMask) instead of std::set; switched to .insert().
  • Select::state (deprecated)current_option() in LgSelect::control.

Caveats worth calling out in your PR description

  • The 2026.5.0 deprecation message states runtime set_internal() is "undefined behavior" because Home Assistant and other consumers aren't notified after setup. Our mark_internal() shim has the same caveat — we're only suppressing the deprecation warning, not the underlying semantic issue. Upstream's recommended path is the internal: YAML key, but that's static; this component decides which entities to hide based on capabilities reported by the LG unit at runtime, so a pure YAML approach isn't viable without a larger refactor.
  • Number::state is not deprecated in 2026.5.0 (only Select::state was), so LgNumber::control is left as-is.
  • Nothing else in 2026.5.0's breaking-changes list applies: no RingBuffer, OneWireBus, PollingComponent, ComponentIterator::on_media_player, OTA-port, or alloc_helpers usage in this component (format_hex_pretty
    lives elsewhere).

I've started testing the fix at: https://github.com/KrzysztofHajdamowicz/esphome-lg-controller/tree/fix/esphome-2026.5.0
So far- it compiles.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions