Closed hemingfei closed 3 years ago
Describe the bug A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
Configuration Share your YAML here
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Platform:
Additional context Add any other context about the problem here.
Logs Please share your Home Assistant logs here. Make sure to remove any personal/secret information.
I have 5 gree ACs, 4 is OK. the last one cannot connect HA, it is the bought this year and maybe is a very new version. Reproduces are the same as the 4 ok ACs. It can be controlled by the Gree's APP.
Bug: the new Gree AC cannot connect HA
Configuration:
Logs:
2020-11-02 21:19:49 INFO (MainThread) [custom_components.gree.climate] Setting up Gree climate platform 2020-11-02 21:19:49 INFO (MainThread) [custom_components.gree.climate] Adding Gree climate device to hass 2020-11-02 21:19:49 INFO (MainThread) [custom_components.gree.climate] Initialize the GREE climate device 2020-11-02 21:19:49 INFO (MainThread) [custom_components.gree.climate] Retrieving HVAC encryption key 2020-11-02 21:19:49 INFO (MainThread) [custom_components.gree.climate] Fetching(192.168.0.111, 7000, 10, {"cid": "app","i": 1,"pack": "Ngztd3UiCxS0TOyZHHoafd3HVI7WK1cUkQckpAg3vJLY3P8CoZEzBtiDYPezngUo","t":"pack","tcid":"f4-91-1e-f8-f0-f0","uid": 0}) 2020-11-02 21:19:59 ERROR (MainThread) [homeassistant.components.climate] Error while setting up gree platform for climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 197, in _async_setup_platform await asyncio.shield(task) File "/usr/local/lib/python3.8/asyncio/coroutines.py", line 124, in coro res = func(*args, **kw) File "/config/custom_components/gree/climate.py", line 118, in async_setup_platform GreeClimate(hass, name, ip_addr, port, mac_addr, timeout, target_temp_step, temp_sensor_entity_id, lights_entity_id, xfan_entity_id, health_entity_id, powersave_entity_id, sleep_entity_id, eightdegheat_entity_id, air_entity_id, hvac_modes, fan_modes, swing_modes, encryption_key, uid) File "/config/custom_components/gree/climate.py", line 165, in init self._encryption_key = self.GetDeviceKey().encode("utf8") File "/config/custom_components/gree/climate.py", line 248, in GetDeviceKey return self.FetchResult(cipher, self._ip_addr, self._port, self._timeout, jsonPayloadToSend)['key'] File "/config/custom_components/gree/climate.py", line 230, in FetchResult data, addr = clientSock.recvfrom(64000) socket.timeout: timed out 2020-11-02 21:19:59 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/local/lib/python3.8/site-packages/async_upnp_client/search.py", line 42, in on_data await async_callback(headers) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/profiles/profile.py", line 54, in on_response responses.add(data) File "/usr/local/lib/python3.8/site-packages/async_upnp_client/utils.py", line 66, in hash return hash(tuple(sorted(ci_dict.items()))) TypeError: unhashable type: 'Header'
I am trying to implement the encrypt and decode msg, and then see the details. the key and ways I can found in your script. but im not very familiar with python, so im trying to implement in window C# console to see the details of the json.
The AC times out. This usually means that either something on your network is blocking communication or the configuration is wrong (wrong IP or wrong port).
A few issues with the same error: https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/86 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/80 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/77 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/75 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/73 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/63 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/47 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/40 https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/30
In my situation, its a new problem , I tried discovery and bind. the new AC can be discovered but cannot bind. Maybe the key chagned. I test using windows console.
some part of the code after the log "Binding":
log.LogDebug(" Binding");
var bindRequestPack = new BindRequestPack() { MAC = deviceInfo.ClientId };
var request = Request.Create(deviceInfo.ClientId, Crypto.EncryptGenericData(JsonConvert.SerializeObject(bindRequestPack)), 1);
var requestJson = JsonConvert.SerializeObject(request);
var datagram = Encoding.ASCII.GetBytes(requestJson);
using (var udp = new UdpClient())
{
var sent = await udp.SendAsync(datagram, datagram.Length, response.Address, 7000);
if (sent != datagram.Length)
{
log.LogWarning(" Binding request cannot be sent");
continue;
}
for (int i = 0; i < 50; ++i)
{
if (udp.Available > 0)
{
var result = await udp.ReceiveAsync();
if (result.RemoteEndPoint.Address.ToString() != response.Address)
{
log.LogWarning($" Got binding response from the wrong device: {result.RemoteEndPoint.Address.ToString()}");
continue;
}
var responseJson = Encoding.ASCII.GetString(result.Buffer);
responsePackInfo = JsonConvert.DeserializeObject<ResponsePackInfo>(responseJson);
if (responsePackInfo.Type != "pack")
{
continue;
}
var bindResponse = JsonConvert.DeserializeObject<BindResponsePack>(Crypto.DecryptGenericData(responsePackInfo.Pack));
log.LogDebug($" Success. Key: {bindResponse.Key}");
foundUnits.Add(new GreeBlynkBridge.Database.AirConditionerModel()
{
ID = deviceInfo.ClientId,
Name = deviceInfo.FriendlyName,
Address = result.RemoteEndPoint.Address.ToString(),
PrivateKey = bindResponse.Key
});
break;
}
await Task.Delay(100);
}
}
}
log.LogInformation("Scan finished");
return foundUnits;
}
the other four old gree AC can be discoverd and bind success.
do you have the ways to get the GenericKey? (old: "a3K8Bx%2r8Y7#xDh")
There are several ways to extract the key. NOTE: I dont use this myself, but other people have done this. One of the methods is in the readme: https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/blob/master/README.md
Another way: https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/64#issuecomment-646510604
https://github.com/RobHofmann/HomeAssistant-GreeClimateComponent/issues/86#issuecomment-702689445
Found another comment about retrieving the key.
Closing this for now. Let me know if you still have questions.
My old four gree AC (https://detail.tmall.com/item.htm?id=600728625205&skuId=4369182830517) is now OK to link with HA,
I bought a new version of gree ( https://detail.tmall.com/item.htm?id=626652028213 ) this year, and it is ok to connect to the gree's APP, now using the HA and this component, it cannot link.
I saw some relevant git, is that help to improve? https://github.com/cmroche/greeclimate and https://github.com/home-assistant/core/pull/42616