fix(uartex): wire fan preset modes into FanTraits so Home Assistant sees them - #278
Merged
Merged
Conversation
…ees them UARTExFan::set_preset_modes() registers modes on the entity, but get_traits() returned a fresh FanTraits with speed only and never wired the presets in, so Home Assistant never saw PRESET_MODE support (preset_modes stayed empty). Since ESPHome 2026.4, Fan::get_traits() overrides must call wire_preset_modes_() explicitly (the base class no longer auto-injects them, unlike Climate). This is a regression from eigger#226, which removed trait-side registration without adding the required call. Add this->wire_preset_modes_(traits); it no-ops when no presets are configured, so speed-only fans are unaffected.
Owner
|
감사합니다! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What follows is described here.
Problem
A
uartexfan configured withpreset_modesnever exposes preset-mode support to Home Assistant. The fan entity reportssupported_featureswithout thePRESET_MODEflag andpreset_modes: [], sofan.set_preset_modeis unavailable — even after a clean build. Speed control works; only presets are missing.Root cause
Since ESPHome 2026.4 the fan preset-mode vectors moved onto the
Fanentity base class, andFan::get_traits()is virtual with no base-class hook to inject them. Eachget_traits()override must callthis->wire_preset_modes_(traits)explicitly (unlikeClimate, whose base class wires custom modes automatically) — see the migration note.UARTExFan::set_preset_modes()already registers the modes on the entity viaset_supported_preset_modes(), butUARTExFan::get_traits()returns a freshFanTraitspopulated only with speed info and never wires the preset modes in. The modes are stored on the entity but never reach the traits sent to HA.This is a regression from #226, which removed the trait-side mode registration from
uartex_fan.cppwithout adding thewire_preset_modes_()call the new API requires.Fix
Call
this->wire_preset_modes_(traits)inget_traits(). It copies the registered preset modes into the returnedFanTraits, and no-ops when none are configured (speed-only fans unchanged). No header change needed.Testing
Tested on a real Kocom ventilator (device
0x48) withpreset_modes: ["자동", "수동"]:supported_features: 49,preset_modes: [];fan.set_preset_modefails.supported_features: 57(PRESET_MODE bit set),preset_modespopulated, andfan.set_preset_modesendscommand_presetand reflectsstate_preset. Switching between the two presets works.