Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Tornado 16X SQ air conditioner (0x4E2A) #520

Merged
merged 15 commits into from
Apr 17, 2024

Conversation

felipediel
Copy link
Collaborator

@felipediel felipediel commented Jan 22, 2021

This PR is based on @enosh's work: #430. I was helping with the review and the PR ended up getting lost in the midst of so many changes and updates. He was being very cooperative, so I think now is the time for me to do my part. I rebased and cleaned up the code a little bit to have it merged soon.

This is a work in progress.

Todo

  • Make tornado a generic HVAC class
  • Better names
  • Clean up IntEnums
  • Clean up encoders
  • Create a better interface for the state
  • Change _decode() return value to payload[10:p_len]
  • Fix CRC: cannot return negative values
  • Decode UNK0, UNK1 and UNK2.
  • Clean up
  • Tests

@felipediel
Copy link
Collaborator Author

felipediel commented Jan 23, 2021

Hi @enosh. I rebased so it doesn't get lost in time. Still work? I wish we could have this in v0.17.0, because I don't know how many chances we will have after that.

@enosh
Copy link

enosh commented May 2, 2021

Hey, been away for a while, this looks very neat.
I did some testing, and found out some packet length issues but other than that everything works well.

As for the interface, I think the only remaining question is whether to add a function that sets only part of the state and retrieves the rest. The user can do this on their own but it's a nice to have.

Also isolated the "ifeel" option.

Since I can't push to your branch I put the commit here.

s = sum([v if i % 2 == 0 else v << 8 for i, v in enumerate(data)])
# trim the overflow and add it to smallest bit
s = (s & 0xffff) + (s >> 16)
return (0xffff - s) # TODO: fix: we can't return negative values
Copy link

Choose a reason for hiding this comment

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

I might be misunderstanding what you mean.
Screen Shot 2021-05-02 at 14 23 06
But if you mean be negative like in the screenshot, I think it'd be okay just to check that the packet is smaller than 2^18B.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, overflow is unlikely as we are not dealing with packets of this size. & 0xFFFF should be enough as a safeguard:

     return (0xffff - s) & 0xffff

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just found the polynomial, now we can do:

crc = CRC16.calculate(payload[0x02:p_len], polynomial=0x9BE4)

@danielchalmers
Copy link

I have AUX Mini Split Air Conditioners with the same type that also can be controlled by AC Freedom

>python broadlink_discovery
Discovering...
###########################################
Unknown
# broadlink_cli --type 0x4e2a --host 192.168.1.61 --mac c8f7____7d8b
Device file data (to be used with --device @filename in broadlink_cli) :
0x4e2a 192.168.1.61 c8f7____7d8b

###########################################
Unknown
# broadlink_cli --type 0x4e2a --host 192.168.1.29 --mac a043____4a0d
Device file data (to be used with --device @filename in broadlink_cli) :
0x4e2a 192.168.1.29 a043____4a0d

I'd be more than happy to help test this if you have the time to rebase it in the future. Would love to see support for these devices!

@manio
Copy link

manio commented Aug 24, 2023

Hi,
I own Ande unit. I am currently using it via AC Freedom app. It is 0x4e2a.
Every opensource software I was trying so far, to communicate with this device fails with authentication failure.

I was trying this PR, here is my testing snippset:

#!/usr/bin/python
import broadlink

devices = broadlink.discover(timeout=5)
print(devices)
devices[0].auth()

and as the result:

[<hvac: Licensed manufacturer HVAC (0x4e2a) at [REDACTED]:80 | [REDACTED] | 奥克斯空调 | Locked>]
Traceback (most recent call last):
  File "/usr/src/klima-testy/python-broadlink/./monitor.py", line 6, in <module>
    devices[0].auth()
  File "/usr/src/klima-testy/python-broadlink/broadlink/device.py", line 167, in auth
    check_error(response[0x22:0x24])
  File "/usr/src/klima-testy/python-broadlink/broadlink/exceptions.py", line 137, in check_error
    raise exception(error_code)
broadlink.exceptions.AuthenticationError: [Errno -1] Authentication failed

Do you have any clue why is that?

Edit/Update:

I had to remove the device from "AC Freedom" app (using method: liaan/broadlink_ac_mqtt#76 (comment)), then it is unlocked:

[<hvac: Licensed manufacturer HVAC (0x4e2a) at [REDACTED]:80 | [REDACTED] | 奥克斯空调 | Unlocked>]

manio added a commit to manio/rbroadlink that referenced this pull request Sep 6, 2023
This commits add a new type of supported devices, which is air
conditioners. I was testing this only on my specific device but I think
that the code should also work with other compatible air conditioners.

The device was controlled using `AC Freedom` app:
https://play.google.com/store/apps/details?id=com.broadlink.acfreedom

I was searching for opensource projects for controlling the device but
it is not as popular as the IR blasters or other components, so finally
I put the pieces together mainly from two projects:

https://github.com/liaan/broadlink_ac_mqtt
and this not-yet-merged PR:
mjg59/python-broadlink#520

so the credits goes to:
@liaan and @mjg59
manio added a commit to manio/rbroadlink that referenced this pull request Sep 6, 2023
This commits add a new type of supported devices, which is air
conditioners. I was testing this only on my specific device but I think
that the code should also work with other compatible air conditioners.

The device was controlled using `AC Freedom` app:
https://play.google.com/store/apps/details?id=com.broadlink.acfreedom

I was searching for opensource projects for controlling the device but
it is not as popular as the IR blasters or other components, so finally
I put the pieces together mainly from two projects:

https://github.com/liaan/broadlink_ac_mqtt
and this not-yet-merged PR:
mjg59/python-broadlink#520

so the credits goes to:
@liaan and @felipediel / @mjg59
manio added a commit to manio/rbroadlink that referenced this pull request Sep 15, 2023
This commits add a new type of supported devices, which is air
conditioners. I was testing this only on my specific device but I think
that the code should also work with other compatible air conditioners.

The device was controlled using `AC Freedom` app:
https://play.google.com/store/apps/details?id=com.broadlink.acfreedom

I was searching for opensource projects for controlling the device but
it is not as popular as the IR blasters or other components, so finally
I put the pieces together mainly from two projects:

https://github.com/liaan/broadlink_ac_mqtt
and this not-yet-merged PR:
mjg59/python-broadlink#520

so the credits goes to:
@liaan and @felipediel / @mjg59
manio added a commit to manio/rbroadlink that referenced this pull request Sep 16, 2023
This commits add a new type of supported devices, which is air
conditioners. I was testing this only on my specific device but I think
that the code should also work with other compatible air conditioners.

The device was controlled using `AC Freedom` app:
https://play.google.com/store/apps/details?id=com.broadlink.acfreedom

I was searching for opensource projects for controlling the device but
it is not as popular as the IR blasters or other components, so finally
I put the pieces together mainly from two projects:

https://github.com/liaan/broadlink_ac_mqtt
and this not-yet-merged PR:
mjg59/python-broadlink#520

so the credits goes to:
@liaan and @felipediel / @mjg59
@thewh1teagle
Copy link

Any update on this? does the library supports tornado ACs?

@felipediel felipediel marked this pull request as ready for review April 17, 2024 05:03
@felipediel
Copy link
Collaborator Author

Great, I believe we're all set now. Thank you very much, @enosh, and I apologize for the delay. You did a great job!

@felipediel felipediel merged commit 1e11558 into mjg59:dev Apr 17, 2024
4 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.

5 participants