Skip to content

Raise NotImplementedError in the fan preset guard instead of returning it - #989

Closed
dlxmax wants to merge 1 commit into
ollo69:masterfrom
dlxmax:fan-preset-guard
Closed

Raise NotImplementedError in the fan preset guard instead of returning it#989
dlxmax wants to merge 1 commit into
ollo69:masterfrom
dlxmax:fan-preset-guard

Conversation

@dlxmax

@dlxmax dlxmax commented Aug 3, 2026

Copy link
Copy Markdown

LGEFanWrapper.async_set_preset builds the exception and returns it:

async def async_set_preset(self, preset: str) -> None:
    """Set fan preset."""
    if self._description.set_fanpreset_fn is None:
        return NotImplementedError()
    await self._description.set_fanpreset_fn(self._api, preset)

so a missing set_fanpreset_fn silently does nothing instead of signalling that the control is unsupported. The caller discards the return value. The two sibling guards in this same file (async_set_percentage, async_set_preset_mode) both raise.

No behaviour change today. None of the four wrapper descriptions defines fanpresets_fn without also defining set_fanpreset_fn, so _attr_preset_modes is only set when the setter exists. preset_modes is therefore None whenever the setter is missing, and LGEFan.async_set_preset_mode already raises before the wrapper is reached. This just keeps the guard correct if that ever stops holding.

Split out of #988 as an unrelated one-line fix.

…g it

LGEFanWrapper.async_set_preset built the exception and returned it, so a
missing set_fanpreset_fn silently did nothing rather than signalling that the
control is unsupported. The two sibling guards in this file raise.

No behaviour change today: no wrapper description defines fanpresets_fn
without set_fanpreset_fn, so preset_modes is None whenever the setter is
missing and LGEFan.async_set_preset_mode already raises before the wrapper is
reached. This keeps the branch correct if that ever stops holding.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01C3rSu8SZWhxN5VkDc415jp
@dlxmax

dlxmax commented Aug 12, 2026

Copy link
Copy Markdown
Author

Closing to reopen with a clean single-commit history.

@dlxmax dlxmax closed this Aug 12, 2026
@dlxmax
dlxmax deleted the fan-preset-guard branch August 12, 2026 01:43
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