greeclimate icon indicating copy to clipboard operation
greeclimate copied to clipboard

Device binding fails because of camel case in bind response

Open hindenbyte opened this issue 1 year ago • 3 comments

I have an AC unit that apparently has firmware version 3.0.0


{
    "t": "pack",
    "i": 1,
    "uid": 0,
    "cid": "XXX",
    "tcid": "",
    "pack": {
        "t": "dev",
        "cid": "",
        "bc": "gree",
        "catalog": "gree",
        "mid": "60",
        "model": "gree",
        "name": "GR-ACUnit_6400_02_XXX_EC",
        "series": "gree",
        "vender": "2",
        "ver": "V3.0.0",
        "brand": "gree",
        "mac": "XXX",
        "ModelType": "0",
        "lock": 0,
        "subCnt": 1
    }
}

When trying to bind to it I'm getting an warning and the binding fails, apparently because "bindOK" is not a valid response

greeclimate.network - DEBUG - Received packet from 192.168.1.36:
<- {"t": "pack", "i": 1, "uid": 0, "cid": "XXX", "tcid": "", "pack": {"t": "bindOk", "mac": "XXX", "r": 200, "key": "XXX"}}
greeclimate.network - WARNING - Received unknown packet from 192.168.1.36:
{"t": "pack", "i": 1, "uid": 0, "cid": "XXX", "tcid": "", "pack": {"t": "bindOk", "mac": "XXX", "r": 200, "key": "XXX"}}

in network.py it seems you're only checking for "bindok" as a valid response

class Response(Enum):
    BIND_OK = "bindok"
    DATA = "dat"
    RESULT = "res"

To work around it I changed line 233 to this:

resp = str.lower(obj.get("pack", {}).get("t"))

But there's probably a more elegant way to fix this

hindenbyte avatar Nov 30 '24 11:11 hindenbyte

I also encountered this problem

CiyLei avatar Dec 18 '24 00:12 CiyLei

Hi, I was having the same issue. I edited the line, as outlined above, but now the units sporadically go "Unavailable". The logs generate this error:

2025-04-28 08:28:29.197 ERROR (MainThread) [greeclimate.network] Error while handling packet Traceback (most recent call last): File "/usr/local/lib/python3.13/site-packages/greeclimate/network.py", line 235, in packet_received param = params.get(resp, lambda o, a: (o, a))(obj, addr) File "/usr/local/lib/python3.13/site-packages/greeclimate/network.py", line 225, in Response.RESULT.value: lambda o, a: [dict(zip(o["pack"]["opt"], o["pack"]["val"]))], ~~~~~~~~~^^^^^^^

dsaw703 avatar Apr 28 '25 08:04 dsaw703

@dsaw703 that error is not reason why device is unavalible you can fix that error and test it https://github.com/cmroche/greeclimate/pull/110 try it then post some logs when device become unavalible

filipagh avatar May 03 '25 09:05 filipagh