Skip to content

Conversation

flipper
Copy link
Contributor

@flipper flipper commented Aug 4, 2025

The xiaomi.fan.p76 works over generic miot.

This also fixes a weird bug where the device does not respond with a value that is in the "choices list".

For me. Vertical swing returned 1 when the options are 30, 60, 90 and 100.
Sounds like a bug in miot in general.
Unsure what the behavior should be.

The mihome app showed the value as "-" but it was still doing vertical swing

Hopefully this should resolve the issue #2032

Closes #2032

…c miot.

Also defaults the value to the first value when unable to find the choice
Copy link

codecov bot commented Aug 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.26%. Comparing base (0aa4df3) to head (25f8529).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2037   +/-   ##
=======================================
  Coverage   82.26%   82.26%           
=======================================
  Files         197      197           
  Lines       19144    19145    +1     
  Branches     1052     1052           
=======================================
+ Hits        15749    15750    +1     
  Misses       3218     3218           
  Partials      177      177           

☔ 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.

Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It would be nice to have a test for the source, and this behaviour. The logic might need to be verified, see my comment inline.

selected = next(c.description for c in self.choices if c.value == value)
selected = next(
(c.description for c in self.choices if c.value == value),
self.choices[0],
Copy link
Owner

Choose a reason for hiding this comment

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

Could it be that the reported 1 is for the index in the available choices?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could be. But the app didn't parse that 1 index as a value. So unsure what happened.
The miot protocol works in mysterious ways

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, if you want to test it with different values on your device to confirm the behavior, it could be interesting. Otherwise, I would avoid changing the behavior here now, as it feels like a firmware bug on your device.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, if you want to test it with different values on your device to confirm the behavior, it could be interesting. Otherwise, I would avoid changing the behavior here now, as it feels like a firmware bug on your device.

Yeah it does sound like a firmware bug. Would it be better if it returned None instead?

@rytilahti rytilahti changed the title Adds the source field to MiotProperty which is needed for xiaomi.fan.p76 to function Adds the source field to MiotProperty Aug 5, 2025
@rytilahti rytilahti changed the title Adds the source field to MiotProperty Add the source field to MiotProperty Aug 5, 2025
@flipper
Copy link
Contributor Author

flipper commented Aug 9, 2025

Thanks for the PR! It would be nice to have a test for the source, and this behaviour. The logic might need to be verified, see my comment inline.

I'm unsure what the source field actually does. That's why I marked it as optional. Do you have any idea what it's purpose is?

@rytilahti
Copy link
Owner

I'm unsure what the source field actually does. That's why I marked it as optional. Do you have any idea what it's purpose is?

No idea, but it's fine to have it as optional. I'm more worried about changing the behavior of choices, so if you exclude that change from this PR we can merge this immediately.

@rytilahti rytilahti added the bug label Aug 10, 2025
@rytilahti rytilahti merged commit c5cc0f2 into rytilahti:master Aug 19, 2025
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Xiaomi Smart Tower Fan 2 spec parsing throws errors
2 participants