Skip to content

add DehumidifierDriver#168

Merged
iprak merged 1 commit into
iprak:mainfrom
1saac-k:support-dehumidifier-driver
Apr 24, 2026
Merged

add DehumidifierDriver#168
iprak merged 1 commit into
iprak:mainfrom
1saac-k:support-dehumidifier-driver

Conversation

@1saac-k
Copy link
Copy Markdown
Contributor

@1saac-k 1saac-k commented Apr 23, 2026

Related Issue, PR: #151, #154

This PR is the third split from PR #154. It contains only the DehumidifierDriver and its related unit tests. Since the device wrapper and the HA entity implementation for the dehumidifier are not yet included, there should be no impact on the air purifier.

29 unit tests have been added, for a total of 109 passing tests.

$ uv run --python 3.13 --with pytest-homeassistant-custom-component --with winix --with pycryptodome   pytest tests/ -p asyncio --asyncio-mode=auto
Test session starts (platform: linux, Python 3.13.7, pytest 9.0.0, pytest-sugar 1.0.0)
rootdir: /home/kyet/ws/winix
plugins: asyncio-1.3.0, pytest_freezer-0.4.9, github-actions-annotate-failures-0.3.0, aiohttp-1.1.0, syrupy-5.0.0, xdist-3.8.0, timeout-2.4.0, cov-7.0.0, sugar-1.0.0, respx-0.22.0, requests-mock-1.12.1, unordered-0.7.0, anyio-4.13.0, homeassistant-custom-component-0.13.316, picked-0.5.1, socket-0.7.0
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 109 items

 tests/test_config_flow.py ✓✓✓✓                                      4% ▍
 tests/test_device_wrapper.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓             27% ██▋
 tests/test_driver.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓  67% ██████▊
 tests/test_fan.py ✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓✓                  95% █████████▋
 tests/test_sensor.py ✓✓✓✓✓                                        100% ██████████

Results (0.69s):
     109 passed

The dehumidifier uses a completely different API code namespace (`D*`) from the
air purifier (`A*`/`S*`). Modelling it as a separate `WinixDriver` subclass
keeps each device's wire-level mapping self-contained and avoids polluting
`AirPurifierDriver` with unrelated codes.

Note 1: Auto-Dry State

Some dehumidifier models automatically run an auto-dry cycle (~30 min fan) on
power-off to evaporate residual moisture. The hardware exposes this only as a
state (AUTO_DRY_VALUE, "auto-dry") — there is no explicit action to trigger it.

Note 2: Water Tank Status Ambiguity

A Water Tank value of 1 indicates either that the tank is missing or that it
is full. The hardware/API does not provide a way to distinguish between these
two specific conditions.

- Add `DehumidifierDriver` in `driver.py` covering the `D02`–`D15` code mapping
  and the control methods the dehumidifier exposes.
- Add driver tests and fixtures covering control, RPC, and state parsing.
@iprak
Copy link
Copy Markdown
Owner

iprak commented Apr 24, 2026

Just a FYI: I found this decompiled function which confirms the category_keysn for humidifier. Perhaps some humidifiers support more features and hence the other keys.

public final String toString() {
	return super.toString() + " DeviceStatus{deviceId='" + this.f6026a + "', alias='" + this.f6027b + "', roomName='" + this.f6028c + "', isConnected=" + this.f6029d + ", isPower=" + this.f6030e + ", isPlasma=" + this.f6031f + ", isChildLock=" + this.f6032g + ", isUvplus=" + this.f6033h + ", isLed=" + this.f6034i + ", isLight=false, timer=" + this.f6035j + ", displayBrightness=" + this.f6036k + ", isModeAuto=" + this.f6037l + ", airFlow=" + this.f6038m + ", airQuality=" + this.f6039n + ", dustValueStr='" + this.f6040o + "', filterTime=" + this.f6041p + ", filter2Time=" + this.f6042q + ", filter3Time=" + this.f6043r + ", filterMaxTime=" + this.f6044s + ", filter2MaxTime=" + this.f6045t + ", filter3MaxTime=" + this.f6046u 
	
	+ ", ST_D01_WORK_TIME=" + this.f6047v + ", ST_D02_POWER=" + this.f6048w + ", ST_D03_MODE=" + this.f6049x + ", ST_D04_AIR_FLOW=" + this.f6050y + ", ST_D05_HUMIDITY_HOPE=" + this.f6051z + ", ST_D06_SENSOR=" + this.f6002A + ", ST_D07_PLASMA=" + this.f6003B + ", ST_D08_CHILD_LOCK=" + this.f6004C + ", ST_D09_LIGHT=" + this.f6005D 
+ ", ST_D10_HUMIDITY=" + this.f6006E + ", ST_D11_BUCKET_FULL=" + this.f6007F + ", ST_D12_3D=" + this.f6008G + ", ST_D13_UV=" + this.f6009H + ", ST_D15_TIMER=" + this.f6010I + ", ST_D16_DISPLAY_BRIGHTNESS=0, ST_D17_PLASMA_AIR_PURIFIER=" + this.f6011J + ", ST_C01_WORK_TIME=" + this.f6012K + ", ST_C02_POWER=" + this.f6013L + ", ST_C03_MODE=" + this.f6014M + ", ST_C04_AIR_FLOW=" + this.f6015N + ", ST_C05_TURBO=" + this.f6016O 
+ ", ST_C06_SLEEP=" + this.f6017P + ", ST_C07_SET_TEMPERATURE=" + this.f6018Q + ", ST_C08_CHILD_LOCK=" + this.f6019R + ", ST_C09_TIMER=" + this.f6020S + ", ST_C10_WIND_DIRECTION=" + this.f6021T + ", ST_C11_OPERATING_TIME=" + this.f6022U + ", ST_E01_MALFUNCTION=" + this.f6023V + ", S01_INDOOR_TEMPERATURE=" + this.f6024W + ", S06_POWER_CONSUMPTION=" + this.f6025X + '}';
}

@iprak iprak self-requested a review April 24, 2026 01:38
Copy link
Copy Markdown
Owner

@iprak iprak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one actionable comment.

Comment thread tests/test_driver.py
@iprak iprak merged commit 97ea023 into iprak:main Apr 24, 2026
1 check passed
@1saac-k
Copy link
Copy Markdown
Contributor Author

1saac-k commented Apr 24, 2026

Just a FYI: I found this decompiled function which confirms the category_keysn for humidifier. Perhaps some humidifiers support more features and hence the other keys.

Thank you for sharing. It's interesting to see D codes for plasma and brightness level, which are supported in the air purifier driver. Below is the list of D codes that are not supported — i.e., excluding what I've added in this PR. It might be worth documenting these in an issue or in the docs (docs/~.md) for future reference.

Code Category
D01 WORK_TIME
D06 SENSOR
D07 PLASMA
D09 LIGHT
D12 3D
D16 DISPLAY_BRIGHTNESS
D17 PLASMA_AIR_PURIFIER

@1saac-k
Copy link
Copy Markdown
Contributor Author

1saac-k commented Apr 24, 2026

My next PR will focus on updating device_wrapper to support dehumidifiers. Since I'm refactoring the existing implementation, it'll likely take a few days.

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.

2 participants