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

Need new method to obtain the key #63

Open
Urusus2 opened this issue Apr 11, 2024 · 22 comments
Open

Need new method to obtain the key #63

Urusus2 opened this issue Apr 11, 2024 · 22 comments

Comments

@Urusus2
Copy link

Urusus2 commented Apr 11, 2024

I have two AC Gree Smart: on one the Wifi module firmware version is 1.16 and on the other it is 1.21
At the first with version 1.16, can get the key and send commands, but on the second with version 1.21 it no works.

Send:
{"t": "scan"}

Response:
First:
{"t":"pack","i":1,"uid":0,"cid":"","tcid":"","pack":{"t":"dev","cid":"","bc":"00000000000000000000000000000000","brand":"gree","catalog":"gree","mac":"9424b87c2d71","mid":"10001","model":"gree","name":"","lock":0,"series":"gree","vender":"1","ver":"V3.0.0","hid":"362001065279+U-WB05RT13V1.16.bin"}}

Second:
{"t":"pack","i":1,"uid":0,"cid":"","tcid":"","pack":{"t":"dev","cid":"9424b8a45120","bc":"00000000000000000000000000000000","brand":"gree","catalog":"gree","mac":"9424b8a45120","mid":"10001","model":"gree","name":"","lock":0,"series":"gree","vender":"1","ver":"V2.0.0","ModelType":"32792","hid":"362001065279+U-WB05RT13V1.21.bin"}}

Send: (first)
{"cid": "app", "i": 1, "t": "pack", "uid": 0, "tcid": "9424b87c2d71", "pack": {"mac": "9424b87c2d71", "t": "bind", "uid": 0}}

Response:
{"t":"pack","i":1,"uid":0,"cid":"9424b87c2d71","tcid":"app","pack":{"r":200,"t":"bindok","mac":"9424b87c2d71","key":"rY4ht8T7********"}}

Send: (second)
{"cid": "app", "i": 1, "t": "pack", "uid": 0, "tcid": "9424b8a45120", "pack": {"mac": "9424b8a45120", "t": "bind", "uid": 0}}

Response:
No response

I debugged some UDP messages from the application Gree+ and found:
App send:
{"cid":"app","i":0,"pack":"XrNPaNwaHsDor51nJ+jxj2dOuefc+nVZ406ID3vr8AgIGvgXjKqUpbJUmhOswaaBHw==","t":"pack","tag":"N+aNfYECr1Lxfj9vBixkNQ==","tcid":"9424b8a45120","uid":20004875}

Response:
{"t":"pack","tag":"7SEImdNY5dnFMRPa/crP7z==","i":0,"uid":20004875,"cid":"9424b8a45120","tcid":"app","pack":"XrNYJYpLWJvHr9MmcNy5jzAd6vXW7HRa5FbIWnu85wMYE+4JmryO/qQS30DolvmBAdYWtpkUXSzCnBA7B5/LB8225UjE3C24eMDa6XWaqoBAKpiAhw/dZO4OvS75c7DmuEaL2op9TN2s6YHUA0XwBl6fW74AWu0RtUqPiIt98+AxjU2dbw=="}

is a new parameter tag...

Can help to make it work on this firmware?

@KiralyCraft
Copy link

It seems I have the same 362001065279+U-WB05RT13V1.21.bin as you do, assuming we also have the same WiFi chip. Did you manage to find anything else regarding the communication between the app and the device? Mine also behaves exactly the same, but I didn't get to the MITM aspect of it just yet.

@Urusus2
Copy link
Author

Urusus2 commented May 13, 2024

With the new firmware version 1.53, the old method of obtaining the private key works...

@Urusus2
Copy link
Author

Urusus2 commented May 13, 2024

For info:
work with firmware versions (tested): 1.16, 1.17, 1.53
not work (tested): 1.20, 1.21, 1.22

@KiralyCraft
Copy link

It seems that 1.53 is available for my model as well. Testing now!

@Urusus2
Copy link
Author

Urusus2 commented May 13, 2024

I tested it. It works.

@KiralyCraft
Copy link

It seems my device doesn't see the update, despite it being available. Did you still use GREE+? I'm on EWPE Smart. Which URL did you use to fetch the firmware?

@Urusus2
Copy link
Author

Urusus2 commented May 13, 2024

It seems my device doesn't see the update, despite it being available. Did you still use GREE+? I'm on EWPE Smart. Which URL did you use to fetch the firmware?

In GREE+, debug mode
In debug mode apk work in test mode: region test, url test.grih.gree.com. Need new account...

@KiralyCraft
Copy link

KiralyCraft commented May 13, 2024

Hmm, thanks for the tip. I'm running GREE+ 1.18.6.8; I managed to start it with a debugger attached, but there is no region "rest", it still seems to function normally. Did you do anything else to it besides launching it in debug mode? I tried to launch both with am start -D and from Android Studio with "Profile or debug APK", but I can't get it to run with region "test" at all.

EDIT: Figured it out. It looks like all and any regions are mapped to "test.grih.gree.com", there is no explicit "test" region, but I also added an entry in my DNS server for "eugrih.gree.com" to point to "test.grih.gree.com" and it seems fine. I'm updating right now.

@Urusus2
Copy link
Author

Urusus2 commented May 13, 2024

I use edited apk, added only android:debuggable="true" in AndroidManifest.xml

@KiralyCraft
Copy link

KiralyCraft commented May 13, 2024

Oh my! It works with 1.53! It just works with Home Assistant now, but inside the app it's not controllable anymore. But it works locally! Wow! I wonder if will auto-update from this version.

EDIT: This seems to be stable, thank you for the tip!

@Tempmail1234-pass
Copy link

Tempmail1234-pass commented Jun 15, 2024

Oh my! It works with 1.53! It just works with Home Assistant now, but inside the app it's not controllable anymore. But it works locally! Wow! I wonder if will auto-update from this version.

EDIT: This seems to be stable, thank you for the tip!

Can you please help me? How to update to firmware 1.53? @KiralyCraft

@Tempmail1234-pass
Copy link

Tempmail1234-pass commented Jun 15, 2024

How to update to 1.53? @KiralyCraft
Please help.

@KiralyCraft
Copy link

Hi, it looks like the method was actually discovered, but not yet implemented in the official plugin. Can you look into this custom component meanwhile?

https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/tree/2.10.0

@Tempmail1234-pass
Copy link

Tempmail1234-pass commented Jun 18, 2024

@KiralyCraft I tired for countless hours, but without success. I get this message:
Setup failed for custom integration 'gree': No setup or config entry setup function defined
There is also an open issue on the custom component repo: RobHofmann/HomeAssistant-GreeClimateComponent#174
So maybe it's still not working?
I posted the issue on reddit and someone just commented that he have the same problem, can you help?
https://www.reddit.com/r/homeassistant/comments/1dhv7oa/comment/l9569i6/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

@KiralyCraft
Copy link

It looks like there could be something wrong with that integration. The best place for support about it might be it's issues tracker.

I've managed to update my devices to V1.53, and that seems to work with the old methods. They might've changed something indeed, since the post you linked seems to run V1.25 (the patch accounted for V1.2[0-2] only).

It looks like the efforts have dwindled, and unfortunately I do not have access to another unit for testing and debugging. Unless someone manages to "crack" this new version too (or at least fix the component), I'd think the best way to proceed here would be to attempt physical flashing with the right firmware.

Right now I'm out of ideas about how to do that. It would be advisable to see what's your unit's firmware code, using the "scan" of this PythonCLI snippet:

https://github.com/tomikaa87/gree-remote/tree/master/PythonCLI

It's still possible that it won't show, but it's worth a shot.

@Tempmail1234-pass
Copy link

@KiralyCraft This is what I got
{"t":"dev","cid":"9424b8b7cc08","bc":"00000000000000000000000000000000","brand":"gree","catalog":"gree","mac":"9424b8b7cc08","mid":"10001","model":"gree","name":"","lock":0,"series":"gree","vender":"1","ver":"V2.0.0","ModelType":"32776","hid":"362001065279+U-WB05RT13V1.21.bin"}
Can I get it to work?

@KiralyCraft
Copy link

KiralyCraft commented Jun 18, 2024

It looks like your firmware code is 362001065279, and your current version is V1.21

The version you seem to be running is 1.21; There is an available 1.22 version, although I have a feeling that's more nerfing from their side. Theoretically, it should work for you.

Can you try this integration instead? It's from a fork I've mentioned here: https://github.com/tomaszduda23/HomeAssistant-GreeClimateComponent/

This is not the original, but the forked variant which added support for the encryption. I'm not sure what version of HA this supports. I'd try to add it manually in custom_components

@Tempmail1234-pass
Copy link

@KiralyCraft I tried, I don't see any logs and it's not connecting.
It should be the same because this fork was merged into the original repo, am I right?

@KiralyCraft
Copy link

It should indeed, but what made me hopeful is that this fork was reported as being functional. Have you tried both encryption versions? I wonder if it's not just a firmware thing after all. Could it be your HA instance? Could it be the AC?

If you're comfortable, you could try to set up a VM with HA (see here) where you can play with the integrations without breaking your main install. Make sure it's set up as bridged with your network adapter for proper discovery.

I'll do some digging, but so far it looks quite strange indeed;

@Tempmail1234-pass
Copy link

@KiralyCraft My bad, I looked for the logs in the wrong place, this is my log:

2024-06-19 11:43:10.909 INFO (MainThread) [homeassistant.components.climate] Setting up gree.climate
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] Setting up Gree climate platform
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] Adding Gree climate device to hass
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] Initialize the GREE climate device
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] name(): ac
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] name(): ac
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] supported_features(): 441
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] temperature_unit(): °C
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] hvac_modes(): [<HVACMode.AUTO: 'auto'>, <HVACMode.COOL: 'cool'>, <HVACMode.DRY: 'dry'>, <HVACMode.FAN_ONLY: 'fan_only'>, <HVACMode.HEAT: 'heat'>, <HVACMode.OFF: 'off'>]
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] min_temp(): 16
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] max_temp(): 30
2024-06-19 11:43:10.909 INFO (MainThread) [custom_components.gree.climate] target_temperature_step(): 1.0
2024-06-19 11:43:10.910 INFO (MainThread) [custom_components.gree.climate] fan_list(): ['Auto', 'Low', 'Medium-Low', 'Medium', 'Medium-High', 'High', 'Turbo', 'Quiet']
2024-06-19 11:43:10.910 INFO (MainThread) [custom_components.gree.climate] swing_modes(): ['Default', 'Swing in full range', 'Fixed in the upmost position', 'Fixed in the middle-up position', 'Fixed in the middle position', 'Fixed in the middle-low position', 'Fixed in the lowest position', 'Swing in the downmost region', 'Swing in the middle-low region', 'Swing in the middle region', 'Swing in the middle-up region', 'Swing in the upmost region']
2024-06-19 11:43:10.910 INFO (MainThread) [custom_components.gree.climate] supported_features(): 441
2024-06-19 11:43:10.910 INFO (MainThread) [custom_components.gree.climate] Gree climate device added to hass()
2024-06-19 11:43:10.910 INFO (MainThread) [custom_components.gree.climate] Retrieving HVAC encryption key
2024-06-19 11:43:10.912 INFO (MainThread) [custom_components.gree.climate] Fetching(192.168.0.165, 7000, 10, {"cid": "app","i": 1,"pack": "Jtod3XIt89Lqss6DOHEXAMwiuNsAzgfkbQU3H+DJn/zDIm9Xj1Y9Kdit9aCGHseEwf35XMKtIPQDq97Iev6J","t":"pack","tcid":"9424b8b7cc08","uid": 0, "tag" : "0O6hIyG+4TwGey8NFvt5uQ=="})
2024-06-19 11:43:10.928 INFO (MainThread) [custom_components.gree.climate] Starting SyncState
2024-06-19 11:43:10.928 INFO (MainThread) [custom_components.gree.climate] Could not connect with device.

I have the "tag" which is good, but it

Could not connect with device

What should I try? This is what I tried

- platform: gree
  name: ac
  host: 192.168.0.165
  port: 7000
  mac: '9424b8b7cc08'
  target_temp_step: 1
  encryption_version: 2

@Tempmail1234-pass
Copy link

Tempmail1234-pass commented Jun 19, 2024

@KiralyCraft It finally worked, thank you so much for your help!
Also see this RobHofmann/HomeAssistant-GreeClimateComponent#174 (comment)

@NikolaSivkov
Copy link

Just passing by to say that with https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent v2.13, with the following config, it worked!
Gree AC firmware version 1.21

- platform: gree
  name: Bedroom AC
  host: 192.168.1.x
  port: 7000
  mac: '94:24:b8:xx:xx:xx'
  #encryption_key: 'a3K8Bx%2r8Y7GREE' < not needed
  encryption_version: 2 # < MUST BE V2
  target_temp_step: 1
  temp_sensor: sensor.bedroom_ac_temp
  lights: input_boolean.bedroom_ac_lights
  xfan: input_boolean.bedroom_ac_xfan
  health: input_boolean.bedroom_ac_health
  sleep: input_boolean.bedroom_ac_sleep
  powersave: input_boolean.bedroom_ac_powersave
  eightdegheat: input_boolean.bedroom_ac_eightdegheat
  air: input_boolean.bedroom_ac_air
  target_temp: input_number.bedroom_ac_target_temp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants