nathanvdh / homeassistant-airtouch2

Custom component integration for Polyaire Airtouch 2
MIT License
6 stars 5 forks source link

Detect and adapt to different supported fan speeds #2

Closed gogreenpower closed 1 year ago

gogreenpower commented 1 year ago

Hi mate, great work. Just been playing around and noticed the fan level set in the integration is one level higher than the unit. Low is medium, medium is high, high is diffuse (which I don't have on my unit) and diffuse is low. Auto is good.

nathanvdh commented 1 year ago

What brand is your ac unit?

gogreenpower commented 1 year ago

Fujitsu

nathanvdh commented 1 year ago

Hm so is mine - will have to investigate, likely with some help from you.

gogreenpower commented 1 year ago

No worries, just let me know what your need

gogreenpower commented 1 year ago

I forked the repo and have found a working combination.

ACFanSpeed.AUTO: FAN_AUTO,

ACFanSpeed.QUIET: FAN_LOW,

ACFanSpeed.LOW: FAN_MEDIUM,

ACFanSpeed.HIGH: FAN_HIGH,

This updates my AT2 unit correctly.

The original setup was doing this:

AUTO and HIGH combos worked correctly. Not sure if its my Fujitsu unit, I'll try and find the docs and check model numbers and if I can't, I'll climb into the roof

edit: code tags

nathanvdh commented 1 year ago

The problem seems to be that you don't have a 'quiet' fan speed. The values sent to the airtouch for fan speed are:

AUTO = 0
QUIET = 1
LOW = 2
MEDIUM = 3
HIGH = 4

And it seems that with 'quiet' missing, your values are offset by 1 i.e.

AUTO = 0
LOW = 1
MEDIUM = 2
HIGH = 3

so you can see where the problem is.

I'll have to see if there's a way to determine what modes a particular airtouch system supports. It must be there if everything displays and works correctly in the airtouch2 app but it hasn't been documented for airtouch2 or 3. It has for airtouch4, see here: https://github.com/LonePurpleWolf/airtouch4pyapi/blob/main/airtouch4pyapi/packetmap.py

But yeah I'm probably going to need to get a dump of the response message your airtouch unit is sending to work it out. If you have an android phone can you please force close the airtouch2 app then install 'PCAPdroid' and set it to dump to a PCAP file, set the target app to the airtouch2 app. Then just open up the app. Upload the file for me. Alternatively I can probably update my airtouch2 python client to save the response somewhere for you.

nathanvdh commented 1 year ago

Before doing that can you confirm that the quiet speed is missing/greyed out in the app for you? Screenshot_20220927-192129

gogreenpower commented 1 year ago

I'm happy to roll with what you have done. No need to do all this for just me. I'll grab those dumps anyway just in case others find the same issue.

Screenshot_20220927-175526_AirTouch2

nathanvdh commented 1 year ago

I'm happy to roll with what you have done. No need to do all this for just me. I'll grab those dumps anyway just in case others find the same issue.

Screenshot_20220927-175526_AirTouch2

Yes please do it anyway. There is likely a bunch of information about things that supported or not so it will help solve similar issues in future

gogreenpower commented 1 year ago

Here is the capture. I cycled though the fan speeds

PCAP

nathanvdh commented 1 year ago

The file is not public, I cannot access it.

gogreenpower commented 1 year ago

The file is not public, I cannot access it.

Try now

nathanvdh commented 1 year ago

All good thanks

domalab commented 1 year ago

I'm experiencing the same issue on AirTouch2 controller connected to Mitsubishi Electric Ducted Aircon unit

nathanvdh commented 1 year ago

I'm experiencing the same issue on AirTouch2 controller connected to Mitsubishi Electric Ducted Aircon unit

Would you be able to produce the same dump for me, as I described above? The more I have from different people/units, the easier it is to reverse engineer.

domalab commented 1 year ago

Sure, Im iPhone user. How can I create a dump for you?

TETZUO commented 1 year ago

Same issue with my Dakin unit. I only have low medium and high speeds

nathanvdh commented 1 year ago

Sure, Im iPhone user. How can I create a dump for you?

I've now added a way to dump the response from my python client. So you'll need to:

  1. Go to a computer
  2. Install python3
  3. Run pip3 install airtouch2 in a terminal/command window
  4. Download test.py from here (right click 'Raw' -> save link as test.py)
  5. Open a terminal/command window and run python3 test.py (probably py test.py on windows)
  6. Just type q and press return to quit the test program. It should have created 2 files: airtouch2.log and last_response.dump.
  7. Check the airtouch2.log contains something like:
    2022-09-28 21:38:47,892 Thread-1 (_handle_incoming) DEBUG: Received new valid response
    2022-09-28 21:38:47,893 Thread-2 (_main_loop) DEBUG: 
        System Name:    NATHANVDH
        AC Name:    Fujitsu
        On:     True
        Status:     8
        Mode:       HEAT
        Fan Speed:  AUTO
        Ambient Temp:   19
        Set Temp:   19
        Manufacturer:   FUJITSU
  8. Tell me what it says your 'manufacturer' is and what your manufacturer really is (I know these are totally wrong at the moment apart from a couple)
  9. Send me both airtouch2.log and last_response.dump (you can email them to me at nathanmvdh@gmail.com if you don't want to post it publicly here - it will contain all your zone names and system name and stuff).
nathanvdh commented 1 year ago

Same issue with my Dakin unit. I only have low medium and high speeds

Could you also produce a log and dump as I described above, the more data I have the easier it will be to support more systems.

TETZUO commented 1 year ago

Same issue with my Dakin unit. I only have low medium and high speeds

Could you also produce a log and dump as I described above, the more data I have the easier it will be to support more systems.

Just sent mate.

Manufacture is detected as “none” sent you the logs with a photo of the AirTouch unit showing Daikin

domalab commented 1 year ago

Sure, Im iPhone user. How can I create a dump for you?

I've now added a way to dump the response from my python client. So you'll need to:

  1. Go to a computer
  2. Install python3
  3. Run pip3 install airtouch2 in a terminal/command window
  4. Download test.py from here (right click 'Raw' -> save link as test.py)
  5. Open a terminal/command window and run python3 test.py (probably py test.py on windows)
  6. Just type q and press return to quit the test program. It should have created 2 files: airtouch2.log and last_response.dump.
  7. Check the airtouch2.log contains something like:
2022-09-28 21:38:47,892 Thread-1 (_handle_incoming) DEBUG: Received new valid response
2022-09-28 21:38:47,893 Thread-2 (_main_loop) DEBUG: 
        System Name:  NATHANVDH
        AC Name:  Fujitsu
        On:       True
        Status:       8
        Mode:     HEAT
        Fan Speed:    AUTO
        Ambient Temp: 19
        Set Temp: 19
        Manufacturer: FUJITSU
  1. Tell me what it says your 'manufacturer' is and what your manufacturer really is (I know these are totally wrong at the moment apart from a couple)
    1. Send me both airtouch2.log and last_response.dump (you can email them to me at nathanmvdh@gmail.com if you don't want to post it publicly here - it will contain all your zone names and system name and stuff).

Sent you the log and dump file.

nathanvdh commented 1 year ago

Just an update: I've assumed I am looking for a single 'bit' (1 or 0) in the airtouch 2 response message that indicates if the aircon supports the quiet fan speed or not (I could be wrong). Looking at the difference between my dumps and the ones I've received so far there are 3 possible bits (that are 1 for me and 0 for all of you) - 2 of them are in the 2 bytes immediately after the constant header, I don't know what these bytes are but it seems unlikely to me this fan speed information would be stored so soon in the message (I could be wrong). This leaves 1 remaining bit - the 5th bit after 0x124 so for now I'm just going to implement checking that. It will fix the issue for all of you and if I'm wrong then someone in the future will find out :) and hopefully let me know.

NoirElec commented 1 year ago

Also do not have quiet setting PCAP

nathanvdh commented 1 year ago

I've been very busy with uni but done now. NoirElec's dump disagrees with the rest of them and the 2 bytes after the header actually seem to change (my most recent dump from my own unit doesn't match the last one much at all), so I've got no idea now. I might just add a config entry that makes you specify if the unit supports Quiet mode or not.

nathanvdh commented 1 year ago

Okay I've been looking in the wrong places and can't believe it's taken me this long, but I'm pretty sure I've found it now. The only issue is that your dump, @ruaandeysel, seems to indicate your AC has 4 fan speeds (like mine) whereas everyone else's only has 3 (low, med, high). Are you sure you don't have a 4th fan speed? Likely either Quiet/diffuse like mine is or perhaps a turbo mode?

domalab commented 1 year ago

Okay I've been looking in the wrong places and can't believe it's taken me this long, but I'm pretty sure I've found it now. The only issue is that your dump, @ruaandeysel, seems to indicate your AC has 4 fan speeds (like mine) whereas everyone else's only has 3 (low, med, high). Are you sure you don't have a 4th fan speed? Likely either Quiet/diffuse like mine is or perhaps a turbo mode?

Here's screenshot

image

domalab commented 1 year ago

Okay I've been looking in the wrong places and can't believe it's taken me this long, but I'm pretty sure I've found it now. The only issue is that your dump, @ruaandeysel, seems to indicate your AC has 4 fan speeds (like mine) whereas everyone else's only has 3 (low, med, high). Are you sure you don't have a 4th fan speed? Likely either Quiet/diffuse like mine is or perhaps a turbo mode?

Screenshot of the AirTouch app.

image

nathanvdh commented 1 year ago

Okay thanks, so you have an extra 'powerful' mode. Can you tell me exactly how my current integration sets the fan speeds for you? Go through and use home assistant to set it to auto, diffuse, low, medium, high and tell me what each one actually sets on your AC. Thanks.

nathanvdh commented 1 year ago

@ruaandeysel ^

domalab commented 1 year ago

Okay thanks, so you have an extra 'powerful' mode. Can you tell me exactly how my current integration sets the fan speeds for you? Go through and use home assistant to set it to auto, diffuse, low, medium, high and tell me what each one actually sets on your AC. Thanks.

Here you go:

HA AC Auto = Auto Diffuse = Low Low = Medium Medium = High High = Power

nathanvdh commented 1 year ago

Also do not have quiet setting PCAP

Hi Noir, would you be able to give me some more info? What brand is your unit and what fan speeds does it support?

nathanvdh commented 1 year ago

@gogreenpower @ruaandeysel @TETZUO @NoirElec @DmitryNefedov

Can you all please enable betas for the repo and download the new 0.3.beta1 version of the integration. Can you test if your fan speeds are correct now and let me know if you experience any warnings/errors in the logs or other issues.

domalab commented 1 year ago

@gogreenpower @ruaandeysel @TETZUO @NoirElec @DmitryNefedov

Can you all please enable betas for the repo and download the new 0.3.beta1 version of the integration. Can you test if your fan speeds are correct now and let me know if you experience any warnings/errors in the logs or other issues.

@nathanvdh Thank you for releasing this beta version. I installed it and all the fan speeds are working fine now for me.

TETZUO commented 1 year ago

@gogreenpower @ruaandeysel @TETZUO @NoirElec @DmitryNefedov @nathanvdh Can you all please enable betas for the repo and download the new 0.3.beta1 version of the integration. Can you test if your fan speeds are correct now and let me know if you experience any warnings/errors in the logs or other issues.

@nathanvdh Thank you for releasing this beta version. I installed it and all the fan speeds are working fine now for me.

Tested and the only issue I found is with my unit I only have low, med and high.

If I am in a mode like low then select auto, any option I select after that will always revert to the option I selected before auto mode which is this case was low.

Out side of that the mappings are working correctly

gogreenpower commented 1 year ago

@gogreenpower @ruaandeysel @TETZUO @NoirElec @DmitryNefedov

Can you all please enable betas for the repo and download the new 0.3.beta1 version of the integration. Can you test if your fan speeds are correct now and let me know if you experience any warnings/errors in the logs or other issues.

Working for me too, great job.

nathanvdh commented 1 year ago

Tested and the only issue I found is with my unit I only have low, med and high.

If I am in a mode like low then select auto, any option I select after that will always revert to the option I selected before auto mode which is this case was low.

Out side of that the mappings are working correctly

Are you saying you don't have an auto fan speed at all on your airtouch?

When you say it 'will always revert' do you mean just on the home assistant display or truly on your airtouch - e.g. you are watching it on the touch panel or in the app.

Can you please cycle through modes and describe what happens both in home assistant, and also what actually happens to your airtouch. Also are there any errors or warnings in the log, thanks.

TETZUO commented 1 year ago

Tested and the only issue I found is with my unit I only have low, med and high. If I am in a mode like low then select auto, any option I select after that will always revert to the option I selected before auto mode which is this case was low. Out side of that the mappings are working correctly

Are you saying you don't have an auto fan speed at all on your airtouch?

When you say it 'will always revert' do you mean just on the home assistant display or truly on your airtouch - e.g. you are watching it on the touch panel or in the app.

Can you please cycle through modes and describe what happens both in home assistant, and also what actually happens to your airtouch. Also are there any errors or warnings in the log, thanks.

Yes only 3 speed as per the photo.

And yes it reverts on both HA and the panel(so the fan speed physically changes) but it only happens after I select auto.

I also have no errors reported.

Here is a video showing everything working fine until I select auto.

https://youtube.com/shorts/3FuxNCbT1mw?feature=share panel

nathanvdh commented 1 year ago

Thanks. I thought there was always an auto mode, I guess not. Seems like I'm not done with this just yet...

nathanvdh commented 1 year ago

Yes only 3 speed as per the photo.

And yes it reverts on both HA and the panel(so the fan speed physically changes) but it only happens after I select auto.

I also have no errors reported.

Here is a video showing everything working fine until I select auto.

https://youtube.com/shorts/3FuxNCbT1mw?feature=share panel

When you do medium->auto->low->(automatic back to) medium Do both those final ones actually change on your aircon? Do you see on the panel/app that it quickly goes from low to medium? Or does it just get stuck on medium (in this scenario) once you've tried to set auto?

TETZUO commented 1 year ago

Yes only 3 speed as per the photo. And yes it reverts on both HA and the panel(so the fan speed physically changes) but it only happens after I select auto. I also have no errors reported. Here is a video showing everything working fine until I select auto. https://youtube.com/shorts/3FuxNCbT1mw?feature=share panel

When you do medium->auto->low->(automatic back to) medium Do both those final ones actually change on your aircon? Do you see on the panel/app that it quickly goes from low to medium? Or does it just get stuck on medium (in this scenario) once you've tried to set auto?

Yes they actually do change on the aircon.

The panel and app all change

nathanvdh commented 1 year ago

Okay thanks for that. I really have no idea why that would happen, does changing it from the panel/app after you've tried setting auto in home assistant yield the same behaviour?

It doesn't really matter, though. All I'm going to do now is identify if units actually support auto mode or not, so the fix will be just to not give you the auto button.

nathanvdh commented 1 year ago

Ok sorry to ping you all again but: @gogreenpower @ruaandeysel @TETZUO @NoirElec @DmitryNefedov

I've put out a beta2 update that (at least tries to) detect support of an auto fan speed mode, can you all test again to make sure I haven't broken anything (and Pete/tetzuo make sure you no longer have the auto option).

It's been very painful because this information is not conveyed in the airtouch2 communications - auto and fan speed support is literally hard coded in the airtouch app based on the ac brand, gateway and number of speeds. I'm trying to reverse engineer all the rules by decompiling the app and reading through the Smali bytecode but it's not fun. Hopefully this fixes everything for you guys and if someone else discovers problems, I'll cross that bridge when I come to it.

domalab commented 1 year ago

Ok sorry to ping you all again but:

@gogreenpower @ruaandeysel @TETZUO @NoirElec @DmitryNefedov

I've put out a beta2 update that (at least tries to) detect support of an auto fan speed mode, can you all test again to make sure I haven't broken anything (and Pete/tetzuo make sure you no longer have the auto option).

It's been very painful because this information is not conveyed in the airtouch2 communications - auto and fan speed support is literally hard coded in the airtouch app based on the ac brand, gateway and number of speeds. I'm trying to reverse engineer all the rules by decompiling the app and reading through the Smali bytecode but it's not fun. Hopefully this fixes everything for you guys and if someone else discovers problems, I'll cross that bridge when I come to it.

Updated and still working fine 🙂

TETZUO commented 1 year ago

Hey mate the fan speeds are correct but if I change the speeds the speed automatically goes back to the first speed HA saw after the update.

Also the unit operation keeps turning off the AC in HA which is replicated to the panel.

Video for reference

https://youtube.com/shorts/3FuxNCbT1mw?feature=share

nathanvdh commented 1 year ago

Hey mate the fan speeds are correct but if I change the speeds the speed automatically goes back to the first speed HA saw after the update.

Also the unit operation keeps turning off the AC in HA which is replicated to the panel.

Video for reference

https://youtube.com/shorts/3FuxNCbT1mw?feature=share

Did you update to beta2? Is the auto fan speed still visible for you in HA?

What do you mean by the second part? HA is turning off the AC when it shouldn't be?

TETZUO commented 1 year ago

Yes it’s updated.

The auto fan speed is no longer present.

The issue I see is similar to before which the fan speeds changing after selecting auto. But now it happens when changing the mode of the AC and still happens to the fan speed but if any speed selected.

nathanvdh commented 1 year ago

Yes it’s updated.

The auto fan speed is no longer present.

The issue I see is similar to before which the fan speeds changing after selecting auto. But now it happens when changing the mode of the AC and still happens to the fan speed but if any speed selected.

Peculiar. Does your AC not support all the operation modes? (Heat, Cool, Fan, Dry, Auto?). Would you be able to do the following so I can try and work out what is different about your unit:

pip install airtouch2==0.3b2

Then redownload the test.py file from the same place as before, run it, and (on your actual touchpad/airtouch app) cycle through all the fan speeds and operation modes? Then compress and zip all the .dump files and .log file and email it to me? Hopefully that'll be enough info for me to work out what's going on.

TETZUO commented 1 year ago

tried to run it but I am getting this error

C:\Users\Peter\Downloads\AC>python test.py Traceback (most recent call last): File "C:\Users\Peter\Downloads\AC\test.py", line 2, in from airtouch2 import ACFanSpeed, ACMode ImportError: cannot import name 'ACFanSpeed' from 'airtouch2' (C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\site-packages\airtouch2__init__.py)

nathanvdh commented 1 year ago

tried to run it but I am getting this error

C:\Users\Peter\Downloads\AC>python test.py Traceback (most recent call last): File "C:\Users\Peter\Downloads\AC\test.py", line 2, in from airtouch2 import ACFanSpeed, ACMode ImportError: cannot import name 'ACFanSpeed' from 'airtouch2' (C:\Users\Peter\AppData\Local\Programs\Python\Python311\Lib\site-packages\airtouch2init.py)

Sorry, you should use the test.py from here: https://github.com/nathanvdh/airtouch2-python/blob/detect-fan-speeds/tests/test.py

I forgot I was pushing to a new branch called 'detect-fan-speeds'.

nathanvdh commented 1 year ago

I've discovered a small oversight...try beta3 now @TETZUO ?