Skip to content

Add quirk for A-OK AM45 Plus Wi-Fi tubular motor#108

Merged
epenet merged 17 commits into
home-assistant-libs:mainfrom
jl1990:add-am45-plus-cover-quirk
May 11, 2026
Merged

Add quirk for A-OK AM45 Plus Wi-Fi tubular motor#108
epenet merged 17 commits into
home-assistant-libs:mainfrom
jl1990:add-am45-plus-cover-quirk

Conversation

@jl1990
Copy link
Copy Markdown
Contributor

@jl1990 jl1990 commented Apr 18, 2026

The AM45 Plus (product_id b9oa3zocv4qq47iy, category cl) advertises percent_state in its status_range but never pushes updates for that DP over MQTT, so the default CL mapping (which prefers percent_state) leaves current_position stuck at its startup value while the blind physically moves. Bind current_position to percent_control, which this device does push.

See home-assistant/core#168493.

@epenet
Copy link
Copy Markdown
Collaborator

epenet commented Apr 22, 2026

Hi @jl1990

Can you please send attach a full diagnostic dump from Home Assistant?

@jl1990
Copy link
Copy Markdown
Contributor Author

jl1990 commented Apr 22, 2026

@epenet
Copy link
Copy Markdown
Collaborator

epenet commented Apr 22, 2026

So we have a problem with "add_cover" in that at this stage it seems Home Assistant will not accept that functionnality.
See the comment from Martin in home-assistant/core#166952

Going forward I think the quirk usage should be redesigned so that the entity definition is moved back to Home Assistant. I think that work should be done before we continue working on moving more things to use quirks.

What we could do instead is "suppress" the percent_state datapoint.
I'm working on that functionnality via #110

In the meantime, could you update the test fixture to include "local_strategy"?

The AM45 Plus (product_id b9oa3zocv4qq47iy, category cl) advertises
percent_state in its status_range but never pushes updates for that DP
over MQTT, so the default CL mapping (which prefers percent_state)
leaves current_position stuck at its startup value while the blind
physically moves. Suppress percent_state at device initialisation so
the default mapping falls back to percent_control, which this device
does push.

Include a fixture modelled on a real diagnostic dump (with
local_strategy populated) and a regression test that exercises
initialise_device_quirk and confirms percent_state is dropped from
status_range, status, and local_strategy.

tests/__init__.py: create_device now coerces local_strategy JSON keys
to int, matching the CustomerDevice type in the Tuya SDK.

See home-assistant/core#168493.
@jl1990 jl1990 force-pushed the add-am45-plus-cover-quirk branch from 6ec5bd2 to 6b1ec1a Compare April 22, 2026 16:40
@jl1990
Copy link
Copy Markdown
Contributor Author

jl1990 commented Apr 22, 2026

So we have a problem with "add_cover" in that at this stage it seems Home Assistant will not accept that functionnality. See the comment from Martin in home-assistant/core#166952

Going forward I think the quirk usage should be redesigned so that the entity definition is moved back to Home Assistant. I think that work should be done before we continue working on moving more things to use quirks.

What we could do instead is "suppress" the percent_state datapoint. I'm working on that functionnality via #110

In the meantime, could you update the test fixture to include "local_strategy"?

Ok, I rebased and included local_strategy. I am not sure if my changes are correct (although tests are passing), I am not familiar at all with the codebase here. If any change is needed feel free to do it or let me know what's wrong and I'll change it

@epenet epenet added the device-quirk Provides a device quirk label Apr 23, 2026
epenet and others added 5 commits April 23, 2026 15:18
Co-authored-by: Copilot <copilot@github.com>
@epenet
Copy link
Copy Markdown
Collaborator

epenet commented Apr 23, 2026

@jl1990 as you are the first to provide a quirk not everything is properly documented, and the test framework is not fully settled

I hope that home-assistant/core#168897 will be merged before wednesday (cutoff for 2026.5 beta), then you will be able to test the quirk properly by copying the file to your local HA configuration directory (tuya_quirk sub-directory)

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.15%. Comparing base (2a981b8) to head (629f84c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #108      +/-   ##
==========================================
+ Coverage   96.48%   97.15%   +0.66%     
==========================================
  Files          46       47       +1     
  Lines        1709     1825     +116     
  Branches      170      165       -5     
==========================================
+ Hits         1649     1773     +124     
+ Misses         46       40       -6     
+ Partials       14       12       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

epenet and others added 4 commits April 24, 2026 09:56
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@epenet
Copy link
Copy Markdown
Collaborator

epenet commented Apr 27, 2026

@jl1990
home-assistant/core#168897 has been accepted and will be inside 2026.5 (including beta available on Wednesday)

@epenet epenet changed the title Add cover quirk for A-OK AM45 Plus Wi-Fi tubular motor Add quirk for A-OK AM45 Plus Wi-Fi tubular motor May 4, 2026
@epenet epenet marked this pull request as draft May 5, 2026 05:42
@epenet epenet marked this pull request as ready for review May 11, 2026 06:32
@epenet
Copy link
Copy Markdown
Collaborator

epenet commented May 11, 2026

@jl1990 do you think this is ready to merge?

@jl1990
Copy link
Copy Markdown
Contributor Author

jl1990 commented May 11, 2026

@jl1990 do you think this is ready to merge?

I just tested the quirk in my HA with the new changes and it seems to be working. I would say it's ready to merge.

Thanks!

@epenet epenet merged commit ff024c7 into home-assistant-libs:main May 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

device-quirk Provides a device quirk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants