Skip to content

Add ventilation preset modes to Duco fan entity#169685

Open
ronaldvdmeer wants to merge 6 commits intohome-assistant:devfrom
ronaldvdmeer:feat/duco-fan-ventilation-presets
Open

Add ventilation preset modes to Duco fan entity#169685
ronaldvdmeer wants to merge 6 commits intohome-assistant:devfrom
ronaldvdmeer:feat/duco-fan-ventilation-presets

Conversation

@ronaldvdmeer
Copy link
Copy Markdown
Contributor

@ronaldvdmeer ronaldvdmeer commented May 3, 2026

Proposed change

Extends the Duco fan entity with ventilation preset modes so users can set named ventilation levels from the UI and automations.

Previously the fan entity only exposed the speed slider (CNT1/CNT2/CNT3 → 33 %/66 %/100 %). This PR adds preset mode support:

Preset key Label API state (write)
auto Auto AUTO
man1 Timed low speed MAN1
man2 Timed medium speed MAN2
man3 Timed high speed MAN3
empt Empty house EMPT

Reading state back:

  • The MAN1x2/MAN1x3, MAN2x2/MAN2x3, and MAN3x2/MAN3x3 timed-variant states are mapped back to their base preset (man1, man2, man3).
  • AUT1/AUT2/AUT3 (automatic boost states triggered by sensor modules) are mapped back to the auto preset. They cannot be set from Home Assistant.

Speed slider vs. presets:
The percentage slider and presets are intentionally separate control paths. The slider always issues a continuous override (CNT), while presets issue a timed override (MAN). MAN states do not expose a percentage value — using the slider from a MAN preset transitions to a CNT state.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

Add MAN1, MAN2, MAN3 and EMPT as fan preset modes alongside the
existing AUTO preset. The speed slider (CNT1/2/3) remains unchanged.
Timed MAN variants (MAN1x2 etc.) map to their base preset when read.
Copy link
Copy Markdown
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 extends the Duco integration’s fan entity to expose named ventilation presets in addition to the existing percentage-based speed control, so Home Assistant users can select Duco-specific ventilation modes from the UI and automations.

Changes:

  • Added Duco fan preset constants and state mappings for auto, man1, man2, man3, and empt.
  • Updated the fan entity to report/set preset modes and kept percentage control for continuous speed states.
  • Added user-facing preset labels and updated Duco fan tests/snapshots for the new preset list.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
homeassistant/components/duco/fan.py Adds preset-mode support and updates Duco ventilation state mapping logic for the fan entity.
homeassistant/components/duco/strings.json Adds translated labels for the new fan preset modes.
tests/components/duco/test_fan.py Expands fan service tests for the new preset commands and adjusts rate-limit logging assertions.
tests/components/duco/snapshots/test_fan.ambr Updates the expected entity snapshot to include the new preset modes.

Comment thread homeassistant/components/duco/fan.py
Comment thread homeassistant/components/duco/fan.py
Comment thread tests/components/duco/test_fan.py
- Add MAN1/MAN2/MAN3 (and timed variants) to _STATE_TO_PERCENTAGE so
  async_increase_speed steps from the current level instead of 0%
- Add AUT1/AUT2/AUT3 to _STATE_TO_PRESET so automatic boost states
  report correctly instead of showing an unknown state
- Add read-path parametrized test covering all VentilationState variants
MAN (timed) states only map to a preset, not to a percentage.
Adjusting the slider always issues a CNT (continuous) command.
These are distinct control modes on the Duco device and should
not share the same percentage representation.
Copilot AI review requested due to automatic review settings May 3, 2026 12:59
Copy link
Copy Markdown
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

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

Comment thread homeassistant/components/duco/fan.py
@ronaldvdmeer
Copy link
Copy Markdown
Contributor Author

Important

The percentage slider and presets are intentionally separate control paths on the Duco device. Adjusting the slider always issues a CNT (continuous) command, while presets always issue a MAN (timed) command. Showing a percentage value for a MAN state would imply they were set via the slider, which is misleading. The increase_speed edge case (starting from 0% when in a MAN preset) is acceptable: if a user calls increase_speed from a timed preset, transitioning to CNT1 is reasonable behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants