syssi / xiaomi_fan

Xiaomi Mi Smart Fan integration for Home Assistant
Apache License 2.0
426 stars 117 forks source link

dmaker.fan.p33 can only be set to 25, 50, 75 and 100% #276

Open broekhuijsen opened 2 weeks ago

broekhuijsen commented 2 weeks ago

I have both a dmaker.fan.p33 and a dmaker.fan.p18.

The dmaker.fan.p18 I can set from 1 to 100 %

The dmaker.fan.p33 can only be set to 25, 50, 75 and 100%

I have used the model: dmaker.fan.p18 option in the configuration to force it to think it is a dmaker.fan.p18 (the only difference should be the battery). But that does not seem to work either.

syssi commented 2 weeks ago

It looks like the implementation of the dmaker.fan.p33 is incomplete here:

    """
    TODO:
    - fan.turn_on works, but doesn't go to the declared percentage. This is
      not an issue when using set_percentage()
    - setting child lock works, but HA always reads the value as null
    """

https://github.com/syssi/xiaomi_fan/blob/develop/custom_components/xiaomi_miio_fan/fan.py#L1877-L1882

You could use the set_percentage service as workaround but I guess you want to control the fan using the UI (lovelace) and the control element of the fan speed doesn't work?

broekhuijsen commented 2 weeks ago

Hi there, thanks for your response. Yes that is exactly the case. I want to use the slider in love lace. I don't know if it would be possible to create a number input and link that to a script that uses the set_percentage() to mimic this behaviour. But if the implementation is going to be finished in the near future I might as well just have some patience :D It is good to know that at least the problem as already known :D

syssi commented 2 weeks ago

Do you know how to put a custom_component into the custom_components folder to poke around a bit? :-)

broekhuijsen commented 2 weeks ago

Barely. I mean I can create a folder and copy files to that folder. But I have little knowledge about how to change code. If, it is usually google - copy - paste, rinse and repeat until I either accidentally do it correct (10%) or give up and feel frustrated (90%) :D

syssi commented 2 weeks ago

Do you use HACS to install custom components? I'm looking for a simple solution to provide a test version of this integration which fixes the issue.

broekhuijsen commented 2 weeks ago

I do use HACS yes. You want me to test anything? I have installed custom components before.

syssi commented 2 weeks ago

Yes. I've an idea what's going on here and will provide a fixed version later the day for testing.

broekhuijsen commented 2 weeks ago

Ok I'm happy to test it for you

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Sebastian Muszynski @.> Sent: Saturday, August 31, 2024 11:11:14 AM To: syssi/xiaomi_fan @.> Cc: broekhuijsen @.>; Author @.> Subject: Re: [syssi/xiaomi_fan] dmaker.fan.p33 can only be set to 25, 50, 75 and 100% (Issue #276)

Yes. I've an idea what's going on here and will provide a fixed version later the day for testing.

β€” Reply to this email directly, view it on GitHubhttps://github.com/syssi/xiaomi_fan/issues/276#issuecomment-2322851126, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP7ITSTIEJSH42NGTQJLGK3ZUGJEFAVCNFSM6AAAAABNNBNBGSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRSHA2TCMJSGY. You are receiving this because you authored the thread.Message ID: @.***>

syssi commented 2 weeks ago

I've pushed a feature branch containing some fixes. Please use HACS to install the version of the feature branch:

p33-update

  1. Go to http:///developer-tools/action
  2. Select "Chosse entity" and select the "Xiaomi Mi Smart Pedestal Fan Integration update" entity
  3. Tick the version checkbox and set fix-p33-speed
  4. Perform action
  5. Restart Home Assistant
broekhuijsen commented 2 weeks ago

Ok, I followed your instructions but I get an error Failed to perform the action fan/set_percentage. 'speed

After that I deinstalled everything through HACS, reinstalled it, followed your instructions again, but still the same error.

I don't know if the log is of any use.

(I removed the log because it was showing a lot, but nothing more about the fan than what I posted below)

broekhuijsen commented 2 weeks ago

2024-08-31 15:04:07.844 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration xiaomi_miio_fan which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed File "/config/custom_components/xiaomi_miio_fan/fan.py", line 1034, in async_set_percentage File "/config/custom_components/xiaomi_miio_fan/fan.py", line 619, in _try_command File "/config/custom_components/xiaomi_miio_fan/fan.py", line 2090, in set_speed

syssi commented 2 weeks ago

Could you enable the debug logging and provide another log capture?

Settings -> Devices & services -> Xiaomi Miio -> Enable debug logging (last item of the left tile)
syssi commented 2 weeks ago

I've pushed another fix. Please call the install update service another time, restart HA and give it another try.

broekhuijsen commented 2 weeks ago

Ok the log before the update

home-assistant_xiaomi_miio_fan_2024-08-31T14-29-15.682Z.log

The log after the update

home-assistant_xiaomi_miio_fan_2024-08-31T14-35-00.013Z.log

Unfortunately now it is back to the old behaviour of 25, 50, 75 and 100%

syssi commented 2 weeks ago

Interesting. I have to think about it. :-)

broekhuijsen commented 2 weeks ago

Take you time, while I enjoy the sunshine outside. πŸ˜€

syssi commented 2 weeks ago

It's confusing the p18 behaves different to the p33. Could you provide another debug log of the p18? Could you provide some screenshots too? Which lovelace card do you use exactly?

broekhuijsen commented 2 weeks ago

Here is the log for the P18

home-assistant_xiaomi_miio_fan_2024-08-31T15-04-03.817Z.log

I would expect the P33 and P18 to be equal, because the only difference seemed to be the battery. But apparently they are different.

2024-08-31 16_04_26-Settings – Home Assistant

For the testing I am not using any card. I just click on the entity in the integration and use the slider that pops up.

The living room fan is the P33

broekhuijsen commented 2 weeks ago

The strange thing is, all the other features are working fine, like setting the angle, the timer etc etc.

broekhuijsen commented 2 weeks ago

image What is strange, is that the mode shows up as Normal with a Capital N for the P33, but a small N for the P18

`type: vertical-stack cards:

syssi commented 2 weeks ago

Note for myself:

speed-vs-presets

Migrate away from speed parameter to percentage vs. preset_mode.