mill1000 / midea-ac-py

Home Assistant custom integration to control Midea (and associated brands) air conditioners via LAN.
MIT License
157 stars 17 forks source link

Enabling a swing mode does not set coresponding swing angle selector to "Off" #122

Closed mill1000 closed 6 months ago

mill1000 commented 6 months ago

I think, what I'd expect if automatic swinging for a given direction is active, then the fixed position setting must be displayed as off, instead of the last selected fixed position. The issue that I can imagine, is that if that is set, it might stop the automatic swinging.

Revised:

  1. Set swing mode to both: swing mode setting.
  2. Check swing angle setting: both must be off.

Originally posted by @parautenbach in https://github.com/mill1000/midea-ac-py/issues/109#issuecomment-2064862676

mill1000 commented 6 months ago

Similarly, I guess I need to test:

  1. Set fixed positions.
  2. Turn on automatic swinging for one or both directions.
  3. Check the fixed setting: Does it still display the previously fixed position, or does it show as off?

@parautenbach, I think this is a good test for the OEM application. I would modify the sequence to be:

  1. Set fixed positions.
  2. Set automatic swinging for one or both directions.
  3. Check fixed position settings. Does it show original setting or off?
  4. Set automatic swinging to "Off"
  5. Does fan return to original fixed position?

I would also test the reverse.

  1. Set automatic swinging for one or both directions.
  2. Set fixed positions.
  3. Check automatic swinging. Does it show original setting or off?
  4. Set fixed position to "Off" if possible.
  5. Does it resume automatic swinging?
v1k70rk4 commented 6 months ago

In SmartHome app, I set fixed positions in both directions. The Horizontal swing turned off the horizontal fixed position. The Vertical swing turned off the vertical fixed position. The same is true vice versa, the fixed position turns off the corresponding swing.

mill1000 commented 6 months ago

Thanks for the input.

What happens when you set a fixed position with this integration, wait 15 seconds, then set horizontal/vertical swing and wait 15 seconds?

v1k70rk4 commented 6 months ago

Hello,

the blade angle adjustment turns off the associated (vertical or horizontal) swing (immediately, no need to wait). However, adjusting the swing does not turn the blade angle off (even after 1 minute).

mill1000 commented 6 months ago

Thanks, one more question.

If you set an angle, then toggle the corresponding swing on then off, does it return to the previously programmed angle?

v1k70rk4 commented 6 months ago

When the swing is turned off, the blades stop where I turned off the swing.

v1k70rk4 commented 6 months ago

Interesting what's happening. If I adjust the blade angles from the app, it updates in Home Assistant and vice versa. However, the OFF state is an exception:

  1. When set from the app, it does not show up in Home Assistant.
  2. When set from Home Assistant, nothing happens in the app.

I should add that the blade angle direction cannot be set to OFF from the app (there is no button for it). It just indicates that nothing is set. The AC starts in OFF state every time and the Swing can also turn it off.

image image

mill1000 commented 6 months ago

Interesting what's happening. If I adjust the blade angles from the app, it updates in Home Assistant and vice versa. However, the OFF state is an exception:

Oh that's very interesting info. Thanks again.

  1. When set from the app, it does not show up in Home Assistant.

I should add that the blade angle direction cannot be set to OFF from the app (there is no button for it). It just indicates that nothing is set. The AC starts in OFF state every time and the Swing can also turn it off.

Could you grab a debug log when making the changes from the app? You might need to wait ≈20 seconds after making the change.

v1k70rk4 commented 6 months ago

Hello, in the attached debug log this happens:

  1. I set the direction to UP.
  2. I set the direction to LEFT.
  3. Setting the LEFT-RIGHT swing.
  4. Setting the UP-DOWN swing.
  5. I set the direction to UP.
  6. I set the direction to LEFT.

I waited each time until it was visible in HA. midea_msmart.debug_3.log

mill1000 commented 6 months ago

Thanks again.

Ok, so there's what I see in this log.

   64: 2024-05-04 15:11:29.367 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 00 00000062710c0050000000000000000100000000c1
   74: 2024-05-04 15:11:29.480 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000100 0a00000100

No swing, and no fan position set.

  104: 2024-05-04 15:11:44.385 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 00 00000062710c0050000000000000000100000000c3
  116: 2024-05-04 15:11:44.494 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000101 0a00000100

No swing, UP-DOWN (UD) angle set to position 1, LEFT_RIGHT (LR) no angle set.

  137: 2024-05-04 15:11:59.381 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 00 00000062710c0050000000000000000100000000c5
  162: 2024-05-04 15:12:14.373 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000101 0a00000101

No swing, UP-DOWN (UD) angle set to position 1, LEFT_RIGHT (LR) angle set to position 1.

  163: 2024-05-04 15:12:14.373 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 00 00000062710c0050000000000000000100000000c7
  171: 2024-05-04 15:12:14.485 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000101 0a00000101

Same as above.

  189: 2024-05-04 15:12:29.377 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 33 00000062710c0052000000000000000100000000c9
  200: 2024-05-04 15:12:29.490 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000101 0a00000100

LR swing on, UP-DOWN (UD) angle set to position 1, LEFT_RIGHT (LR) no angle set.

This is expected. Enabling LR swing turns off LR angle. But sounds like HA is not reflecting this change?

  221: 2024-05-04 15:12:44.372 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 3f 00000062710c0052000000000000000100000000cb
  233: 2024-05-04 15:12:44.486 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000100 0a00000100

LRswing on, UP-DOWN (UD) no angle set, LEFT_RIGHT (LR) no angle set.

Again, expected.

  254: 2024-05-04 15:12:59.367 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 33 00000062700c0042000000000000000100000000cd
  266: 2024-05-04 15:12:59.481 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000101 0a00000100

LR swing on, UP-DOWN (UD) angle set to position 1, LEFT_RIGHT (LR) no angle set.

  287: 2024-05-04 15:13:14.383 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158507f7f00 00 00000062700c0042000000000000000100000000cf
  299: 2024-05-04 15:13:14.495 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b1020900000101 0a00000101

No swing, UP-DOWN (UD) angle set to position 1, LEFT_RIGHT (LR) angle set to position 1.

v1k70rk4 commented 6 months ago

This is expected. Enabling LR swing turns off LR angle. But sounds like HA is not reflecting this change?

Yes, the OFF state of the blade angles is not visible in the HA.

mill1000 commented 6 months ago

Ok. I might need you to install a debug version of the integration to try get to the bottom of this.

v1k70rk4 commented 6 months ago

Sure, I'm happy to help :)

mill1000 commented 6 months ago

I appreciate your consistent help!

I've got a branch here with extra debug logging: https://github.com/mill1000/midea-ac-py/tree/issue/swing_angle_mode_interaction

You'll have to manually install it since HACS can't install from a specific branch.

Run with debug logs and try changing the swing modes & fan angles from HA.

v1k70rk4 commented 6 months ago

Hello,

I (we) thank you for spending so much time on this ;) I'm attaching two log files. In the _2 file, I toggled the vane positions and swing mode back and forth, while in the _4 file, I adjusted the OFF vane position that was missing from the second file. midea_msmart.debug_bladepos_240509_2.log midea_msmart.debug_bladepos_240509_4.log

mill1000 commented 6 months ago

Ok I think I found the culprit in your _2 log.

2024-05-09 19:53:55.336 DEBUG (MainThread) [custom_components.midea_ac.climate] Setting swing mode 'horizontal'.
2024-05-09 19:53:55.336 DEBUG (MainThread) [custom_components.midea_ac.coordinator] Updating device. Pre-update swing mode '3', swing angle LR '1', UD '1'.
2024-05-09 19:53:55.339 DEBUG (MainThread) [msmart.base_device] Sending command to 192.168.1.60:6444: aa24ac00000000000002400358667f7f0033002000000000000000000000000000005a4c36
...
2024-05-09 19:53:55.491 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158667f7f003300200062610c70740000000000000001000000005a
2024-05-09 19:53:55.491 DEBUG (MainThread) [custom_components.midea_ac.coordinator] Updated device. Post-update swing mode '3', swing angle LR '1', UD '1'.
2024-05-09 19:53:55.491 DEBUG (MainThread) [custom_components.midea_ac.coordinator] Refreshing device. Current swing mode '3', swing angle LR '1', UD '1'.
2024-05-09 19:53:55.491 DEBUG (MainThread) [msmart.base_device] Sending command to 192.168.1.60:6444: aa21ac00000000000003418100ff03ff0002000000000000000000000000035bcc41
...
2024-05-09 19:53:55.640 DEBUG (MainThread) [msmart.device.AC.command] State response payload: c00158667f7f003300200062610c70740000000000000001000000005b
2024-05-09 19:53:55.641 DEBUG (MainThread) [msmart.base_device] Sending command to 192.168.1.60:6444: aa12ac00000000000003b10209000a005c31ec
...
2024-05-09 19:53:55.753 DEBUG (MainThread) [msmart.device.AC.command] Properties response payload: b10209000001010a0000010000
2024-05-09 19:53:55.753 DEBUG (MainThread) [custom_components.midea_ac.coordinator] Device refreshed. New swing mode '3', swing angle LR '1', UD '1'.
2024-05-09 19:53:55.753 DEBUG (MainThread) [custom_components.midea_ac.coordinator] Finished fetching midea_ac data in 0.262 seconds (success: True)
2024-05-09 19:53:55.753 DEBUG (MainThread) [custom_components.midea_ac.climate] Current swing mode '3'.
2024-05-09 19:53:55.755 DEBUG (MainThread) [custom_components.midea_ac.select] Current select vertical_swing_angle '1'.
2024-05-09 19:53:55.755 DEBUG (MainThread) [custom_components.midea_ac.select] Current select horizontal_swing_angle '1'.

The final properties response b10209000001010a0000010000 is actually indicating that LR_ANGLE is 0 (Off), but the device doesn't reflect that.

It's because here, I use the walrus operator to determine if the property exists in the response...but a value of 0 (Off) causes the condition to evaluate to false and the attribute is never updated.

            if angle := res.get_property(PropertyId.SWING_LR_ANGLE):
                self._horizontal_swing_angle = cast(
                    AirConditioner.SwingAngle,
                    AirConditioner.SwingAngle.get_from_value(angle))

            if angle := res.get_property(PropertyId.SWING_UD_ANGLE):
                self._vertical_swing_angle = cast(
                    AirConditioner.SwingAngle,
                    AirConditioner.SwingAngle.get_from_value(angle))

https://github.com/mill1000/midea-msmart/blob/a4dfe528f34aeda5db6f2cd7752551e4af31fed7/msmart/device/AC/device.py#L157-L165

mill1000 commented 6 months ago

Got a fix here: https://github.com/mill1000/midea-msmart/pull/128

If you can update to this branch to test that'd be great.

pip install git+https://github.com/mill1000/midea-msmart.git@issue/device_property_update
v1k70rk4 commented 6 months ago

Hi, I installed it like this: ➜ git clone -b issue/device_property_update https://github.com/mill1000/midea-msmart.git (the other way doesn't work under HAOS.) ➜ python3 setup.py install ➜ msmart-ng -v msmart version: 0.0.0

And here's the debug log: midea_msmart.debug_swing_1.log

mill1000 commented 6 months ago

I don't think the update took.

Make sure you're installing it within the HA container (even within HAOS), and then maybe restart HA

v1k70rk4 commented 6 months ago

Hello,

I'm not sure what the problem was with the previous run, but it worked this time :) msmart version: 2024.5.4.dev1+g94a0b0f

It works perfectly as expected. When switching to swing mode, the blade positions nicely switch to off.

mill1000 commented 6 months ago

Excellent. I'll get this into a release ASAP