greeclimate icon indicating copy to clipboard operation
greeclimate copied to clipboard

Binding does not work with Gree Clivia

Open gliter opened this issue 1 year ago • 5 comments

Binding does not work with Gree Clivia. The AC does respond to scan package but then does not respond to bind package. Wireshark shows no response.

gliter avatar Jun 22 '24 17:06 gliter

Could you show the full debug logs please. @gliter .

cmroche avatar Jun 26 '24 22:06 cmroche

This may be solved in #92

cmroche avatar Jul 06 '24 21:07 cmroche

@cmroche sorry for late response. There is really nothing to share. It does respond to scan package with:

{"t":"dev","cid":"","bc":"00000000000000000000000000000000","brand":"gree","catalog":"gree","mac":"<Redacted MAC>","mid":"10001","model":"gree","name":"","lock":0,"series":"gree","vender":"1","ver":"V3.2.M","hid":"362001068254+U-4MWB65VRV2.08.bin","ModelType":"16752730"}

but when you send the bind package there is no data received back on socket.

Thats great about #92 personally I am using OpenHab with Java binding but if this is work I hope you dont mind me or someone porting it there.

gliter avatar Jul 06 '24 22:07 gliter

@cmroche Hi!, i have tested PR https://github.com/cmroche/greeclimate/pull/92, but discovery is not working there. in the datagram_received() is a type Error, self._cipher can "None" => it do not have method decrypt. Also updating this method:

def datagram_received(self, data: bytes, addr: IPAddr) -> None:
        """Handle an incoming datagram."""
        if len(data) == 0:
            return

        obj = json.loads(data)

        if obj.get("pack"):
            if self._cipher is None:
                _LOGGER.error("Cipher object not set, cannot decrypt data")
                return

            obj["pack"] = self._cipher.decrypt(obj["pack"])

        _LOGGER.debug("Received packet from %s:\n<- %s", addr[0], json.dumps(obj))
        self.packet_received(obj, addr)

Throws greeclimate.network - ERROR - Cipher object not set, cannot decrypt data.

During testing i discovered that the discovery process should be processed as before. But using bind() method when we have a discovered device/devices we should use another GCM encryption to communicate with.

We can simply provide cipher in search_on_interface() method: await self.send({"t": "scan"}, (str(bcast_iface), 7000), cipher=CipherV1(b'a3K8Bx%2r8Y7#xDh'))

also we need to declare him in send() method:

if obj.get("t") == "scan":
            self._cipher = cipher

this way on the first case -> discovery we will always use CipherV1 for discover devices

scharfi49 avatar Jul 11 '24 14:07 scharfi49

@scharfi49 There was a bug, as you found :) Would you please test again and report any other issue over here https://github.com/cmroche/greeclimate/pull/92#issuecomment-2227112679

cmroche avatar Jul 13 '24 21:07 cmroche