niceboygithub / AqaraGateway

Aqara Gateway/Hub integration for Home Assistant
493 stars 65 forks source link

G2H does not work #105

Closed Dimoon12 closed 2 years ago

Dimoon12 commented 2 years ago

HomeAssistant logs:

2022-05-19 16:51:31  DEBUG  main  SysInfo: {'installation_type': 'Home Assistant Core', 'version': '2022.5.4', 'dev': False, 'hassio': False, 'virtualenv': True, 'python_version': '3.9.2', 'docker': False, 'arch': 'x86_64', 'os_name': 'Linux', 'os_version': '5.10.0-10-amd64', 'user': 'homeassistant'}
 2022-05-19 16:51:31  ERROR  gateway  Failed to connect to MQTT server 10.0.1.3 due to exception: [Errno 111] Connection refused
 2022-05-19 16:51:32  DEBUG  gateway  10.0.1.3: Can't get devices: Expecting value: line 1 column 1 (char 0)
 2022-05-19 16:51:32  DEBUG  gateway  10.0.1.3: Unsupported model: {'coordinator': 'lumi.0', 'did': '408817227', 'model': 'lumi.camera.gwag03', 'mac': '0x54ef4410000bb1a5', 'manufacturer': 'NXP', 'channel': 11, 'cloudLink': 1, 'debugStatus': 0, 'type': 'gateway'}

Mosquitto logs on camera:

2723: mosquitto version 1.6.10 starting
2723: Using default config.
2723: Opening ipv4 listen socket on port 1883.
2723: Binding listener to interface "lo".
2723: New connection from 127.0.0.1 on port 1883.
2723: New client connected from 127.0.0.1 as ZigbeeClient (p2, c1, k30).

Снимок экрана_2022-05-19_23-02-59

jellejans commented 2 years ago

It’s solved in a closed issue.

https://github.com/niceboygithub/AqaraGateway/issues/52

plesetsk commented 2 years ago

So it seems that there is different model types for model g2h. In Integration used code 'lumi.camera.gwagl02' instead of 'lumi.camera.gwag03',

I added 'lumi.camera.gwag03' to core/const.py and core/utils.py in every place near to 'lumi.camera.gwagl02' const.p:


SIGMASTAR_MODELS = [
    'lumi.gateway.aqcn02',
    'lumi.camera.gwagl02',
    'lumi.camera.gwag03',
    'lumi.camera.gwpagl01',
    'lumi.camera.agl001',
    'lumi.gateway.acn004'
]

utils.py

DEVICES = [{
    'lumi.gateway.acn01': ["Aqara", "Gateway M1S", "ZHWG15LM"],  # tested
    'lumi.aircondition.acn05': ["Aqara", "AirCondition P3", "KTBL12LM"],  # xStars tested
    # 'lumi.aircondition.acn04': ["Aqara", "AirCondition P3", "KTBL12LM"],
    # 'lumi.acpartner.acn04': ["Aqara", "AirCondition P3", "KTBL12LM"],
    'lumi.gateway.aeu01': ["Aqara", "Gateway M1S", "HM1S-G01"],
    # 'lumi.gateway.iragl01': ["Aqara", "Gateway M2", "ZHWG12LM"],
    # 'lumi.gateway.iragl7': ["Aqara", "Gateway M2", "HM2-G01"],
    'lumi.gateway.iragl5': ["Aqara", "Gateway M2", "ZHWG12LM"],  # tested
    'lumi.gateway.sacn01': ["Aqara", "Smart Hub H1", "QBCZWG11LM"],
    'lumi.gateway.aqcn02': ["Aqara", "Hub E1", "ZHWG16LM"],  # tested
    'lumi.camera.gwagl02': ["Aqara", "Camera Hub G2H", "ZNSXJ12LM"],  # tested
    'lumi.camera.gwag03': ["Aqara", "Camera Hub G2H", "ZNSXJ12LM"],  # tested
    'lumi.camera.gwpagl01': ["Aqara", "Camera Hub G3", "ZNSXJ13LM"],  # tested
    'lumi.camera.gwpgl1': ["Aqara", "Camera Hub G3", "CH-H03"],
    'lumi.camera.agl001': ["Aqara", "Camera Hub G2H Pro", "ZNSXJ15LM"],
    'params': [
    @staticmethod
    def gateway_alarm_mode_supported(model: str) -> Optional[bool]:
        """ return the gateway alarm mode supported """
        #  basic_cli not support
        if model not in ('lumi.camera.gwag03','lumi.camera.gwagl02', 'lumi.camera.gwpagl01'):
            return True
        return False
    @staticmethod
    def gateway_is_aiot_only(model: str) -> Optional[bool]:
        """ return the gateway is aiot only """
        if model in ('lumi.camera.gwag03','lumi.camera.gwagl02', 'lumi.gateway.iragl5',
                     'lumi.gateway.iragl7', 'lumi.gateway.iragl01',
                     'lumi.gateway.sacn01', 'lumi.camera.gwpagl01',
                     'lumi.camera.agl001'):
            return True
        return False
    @staticmethod
    def get_info_store_path(model: str) -> Optional[str]:
        """ return the path of zigbee info """
        if model in ('lumi.camera.gwagl02','lumi.camera.gwag03'):
            return '/mnt/config'
        return '/data'

Also in login details in core/shell.py I changed

        self.run_command("admin")
        if self._password:
            self.read_until(b"Password: ", timeout=1)
            self.write(self._password.encode() + b"\n")
        self.run_command("stty -echo")
        self.read_until(b"/ # ", timeout=10)

to

        self.run_command("root")
        if self._password:
            self.read_until(b"Password: ", timeout=1)
            self.write(self._password.encode() + b"\n")
        self.run_command("stty -echo")
        self.read_until(b"/ # ", timeout=10)

After this go to telnet g2h

and run

mkdir /data/bin
cd /data/bin
wget -O /tmp/curl "http://master.dl.sourceforge.net/project/aqarahub/binutils/curl?viasf=1"; chmod +x /tmp/curl
/tmp/curl -s -k -L -o /data/bin/mosquitto https://raw.githubusercontent.com/niceboygithub/AqaraCameraHubfw/main/binutils/mosquitto; chmod a+x /data/bin/mosquitto

and than

rm /tmp/out/mosquitto
killall mosquitto
/data/bin/mosquitto -d

don't reboot camera because initial script on it will replace the public mosquitto (/data/bin/mosquitto -d) to predifined one (/tmp/out/mosquitto)

For fix boot modify /etc/normal.xml

instead:

        <process name="/tmp/out/mosquitto">
                <arg desc="foreground run"></arg>

put

        <process name="/data/bin/mosquitto">
                <arg desc="foreground run">-d</arg>
plesetsk commented 2 years ago

Some info from telnet. I don't know if it is normal.

 mosquitto
1658305446: mosquitto version 1.6.10 starting
1658305446: Using default config.
1658305446: Opening ipv4 listen socket on port 1883.
1658305446: Binding listener to interface "lo".
1658305446: Error: Address already in use
ps | grep mos
  142 root      2052 S    /data/bin/mosquitto -d
  905 root         0 Z    [mosquitto]
  907 root      1688 S    grep mos

Devices work fine

niceboygithub commented 2 years ago

If run mosquito without, it will run /tmp/mosquito first. So it is normal.