tomikaa87 / gree-remote

Simple remote control utility for Gree Smart air conditioners
GNU General Public License v3.0
262 stars 62 forks source link

Add support Gree Versati III Heat Pump - GRS-CQ10Pd/NhH-E 10kw #56

Open peca2345 opened 1 year ago

marcinlubojanski commented 1 year ago

It works for me on Python3 with gree.py. I have Versati 3 8kW monoblock. f.e. python ./gree.py -c my_ip_address -i my_gree_id -k my_key --verbose get AllInWatTemHi AllInWatTemLo All OutWatTemHi AllOutWatTemLo WatBoxTemHi WatBoxTemLo RmoHomTemHi RmoHomTemLo RmoHomTemHi = 121 RmoHomTemLo = 9 AllOutWatTemLo = 0 AllInWatTemHi = 130 AllInWatTemLo = 7 WatBoxTemLo = 5 WatBoxTemHi = 140 AllOutWatTemHi = 131

However I wanted to run it on my mips router where only python2 cryptography modules are available. I have tried to port gree.py into python2 and all seems to work besides proper encoding of "pack", decoding works fine. I believe the problem is with different sting/bytes usage in python2 vs3. I have changed this line: #pack_encrypted = encryptor.update(bytes(pack_padded, encoding='utf-8')) + encryptor.finalize() pack_encrypted = encryptor.update(pack_padded.decode('utf8')) + encryptor.finalize() but still it doesn't work properly - the encripted string is wrong and as the result I'm not able to even propely connect (getting timeouts). If I paste there already encrypted string (encrypted on my laptop using python3), then it works. Any help how to properly encode this in python2 is greatly appreciated.

tomikaa87 commented 1 year ago

Hi @marcinlubojanski,

If you've setup the encryptor to use AES-128 ECB, it should produce the same result. If you think the byte encoding is wrong, you can try 'ascii' instead of 'utf-8' because most likely the packets won't contain any special characters. You can try printing the encoding result and see if there is any issue.