Skip to content

Add select platform for the oscillation angle (fixes #293) - #345

Open
juanpebalsa wants to merge 2 commits into
syssi:developfrom
juanpebalsa:add-oscillation-angle-select
Open

Add select platform for the oscillation angle (fixes #293)#345
juanpebalsa wants to merge 2 commits into
syssi:developfrom
juanpebalsa:add-oscillation-angle-select

Conversation

@juanpebalsa

Copy link
Copy Markdown

Summary

Fixes #293.

Adds a select platform to the integration that exposes the fan's horizontal oscillation angle (30/60/90/120/140) as a dropdown entity, so it can be set from the UI again.

Why

The oscillation angle is not a native attribute of Home Assistant fan entities. Until now it could only be changed via the xiaomi_miio_fan.fan_set_oscillation_angle service. After the fan more-info card redesign in Home Assistant, the old angle buttons disappeared, leaving no UI control for the angle (see #293). This restores a first-class control.

What

  • New select.py with async_setup_platform mirroring the fan platform config (host, token, optional model).
  • XiaomiFanAngleSelect(SelectEntity): options are the angles supported by the model, current_option is read from the device (status().angle), and select_option calls set_angle.
  • Model → device mapping mirrors fan.py (e.g. P18/P30 → P10, P15 → P11), and per-model angle lists (P5 = 30/60/90/120; P9/P10/P11/P15/P18/P30 = 30/60/90/120/140).

Config example

select:
  - platform: xiaomi_miio_fan
    name: Ventilador Dormitorio - Angulo Oscilacion
    host: 192.168.1.50
    token: !secret fan_token
    model: dmaker.fan.p18

Testing

Tested on a real dmaker.fan.p18 (Mi Smart Standing Fan 2 P18):

  • Entity created with options ['30','60','90','120','140'] and correctly read the current angle.
  • Selecting 90 → 120 → 30 changed the angle on the device and read back correctly each time.

🤖 Generated with Claude Code

Adds a `select` entity exposing the horizontal oscillation angle
(30/60/90/120/140) for the dmaker MIOT fans (P5/P9/P10/P11/P15/P18/P30).

The oscillation angle is not a native attribute of Home Assistant `fan`
entities, so until now it could only be changed through the
`xiaomi_miio_fan.fan_set_oscillation_angle` service. After HA's fan card
redesign removed the old angle buttons, there was no UI control left for
it. This select restores a first-class UI control (a dropdown) that reads
the current angle from the device and calls `set_angle`.

Config mirrors the `fan` platform (host, token, optional model):

    select:
      - platform: xiaomi_miio_fan
        name: Ventilador Dormitorio - Angulo Oscilacion
        host: 192.168.1.50
        token: !secret fan_token
        model: dmaker.fan.p18

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Does not allow you to choose the oscillation angle (p18)

1 participant