roth-m / miioclient-mqtt

MI miio_client replacement with MQTT support
47 stars 18 forks source link

issue after reset #13

Closed gianlucaromito closed 4 years ago

gianlucaromito commented 4 years ago

Hello, and first of all thanks for the great work! I was just playing around with it. It was all functioning perfectly. Now I've reset the gw holding the button... I tried to restart the miio_client but it does not respond to the python miioclient_mqtt anymore. Running the mioo_client from the command line on the gateway gives no more output as before. I've already tried to run the "reset.sh" command to "factory default" the unit without luck Running it just sits there: root@Aqara_Hub-9053:/usr/bin# /tmp/miio_client

If I press ctrl+c it seems to exit correctly

root@Aqara_Hub-9053:/usr/bin# /tmp/miio_client
^CSIGINT or SIGTERM received.
Closing all sockets.
root@Aqara_Hub-9053:/usr/bin#

If I try to run it in the background and then check the used ports I get this:

root@Aqara_Hub-9053:/usr/bin# /tmp/miio_client &
[1] 5306
root@Aqara_Hub-9053:/usr/bin# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost.localdo:54322 *:*                     LISTEN      5306/miio_client
tcp        0      0 *:ssh                   *:*                     LISTEN      3212/dropbear
tcp        0      0 *:4567                  *:*                     LISTEN      465/hkbridge
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      3212/dropbear
tcp6       0      0 [::]:4567               [::]:*                  LISTEN      465/hkbridge
udp        0      0 *:6666                  *:*                                 465/hkbridge
udp        0      0 *:10008                 *:*                                 465/hkbridge
udp        0      0 *:54321                 *:*                                 5306/miio_client
udp        0      0 *:bootpc                *:*                                 794/dhclient
udp        0      0 *:10136                 *:*                                 794/dhclient
udp        0      0 *:mdns                  *:*                                 465/hkbridge
udp6       0      0 [::]:63521              [::]:*                              794/dhclient
udp6       0      0 [::]:mdns               [::]:*                              465/hkbridge
root@Aqara_Hub-9053:/usr/bin#

What else can I check or do?

Thank you for your help! Gianluca

roth-m commented 4 years ago

Just kill the original miio_client (killall -9 miio_client) before running the new one. You should use netstat -nlup (not -t) as it is using UDP.

gianlucaromito commented 4 years ago

Thanks for the quick reply! Yes yeou are right about the nlup :) It seems that the original one does not start at boot... this is the situation after boot

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:6666            0.0.0.0:*                           467/hkbridge
udp        0      0 0.0.0.0:10008           0.0.0.0:*                           467/hkbridge
udp        0      0 0.0.0.0:68              0.0.0.0:*                           740/dhclient
udp        0      0 0.0.0.0:68              0.0.0.0:*                           741/dhclient
udp        0      0 0.0.0.0:4993            0.0.0.0:*                           740/dhclient
udp        0      0 0.0.0.0:4275            0.0.0.0:*                           741/dhclient
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           467/hkbridge
udp6       0      0 :::2308                 :::*                                740/dhclient
udp6       0      0 :::4452                 :::*                                741/dhclient
udp6       0      0 :::5353                 :::*                                467/hkbridge

I tried to start the original one by hand

root@Aqara_Hub-9053:~# /lumi/app/miio/miio_client
[20200819 20:56:41] [I] version: miio-client 3.5.8
[20200819 20:56:41] [I] Set TCP host to "ott.io.mi.com"
[20200819 20:56:41] [I] Set UDP host to "ot.io.mi.com"
[20200819 20:56:41] [I] OT smart conn sockfd: 3
[20200819 20:56:41] [I] OT agent listen fd: 4
[20200819 20:56:41] [I] BT conn listen fd: 5
[20200819 20:56:41] [I] Timer fd: 6, interval: 5000 ms
[20200819 20:56:41] [I] Sync timer fd: 7, interval: 0 ms
[20200819 20:56:41] [I] ACK timer fd: 8, interval: 3000 ms
[20200819 20:56:41] [I] autoreply timer fd: 9, interval: 1000 ms
[20200819 20:56:41] [I] pollfds[0]: 3
[20200819 20:56:41] [I] pollfds[1]: 4
[20200819 20:56:41] [I] pollfds[2]: 5
[20200819 20:56:41] [I] pollfds[3]: 6
[20200819 20:56:41] [I] pollfds[4]: 7
[20200819 20:56:41] [I] pollfds[5]: 8
[20200819 20:56:41] [I] pollfds[6]: 9
[20200819 20:56:46] [D] check_device_info:1992, didkeyreq_timestamp: 0, didkeyreq_interval: 30.
[20200819 20:56:46] [D] cmd_internal_request_dinfo
[20200819 20:56:46] [W] cmd_internal_request_dinfo:1769, ot_agent_internalfd: -1
[20200819 20:56:46] [W] No helper script?
[20200819 20:56:51] [D] check_device_info:1992, didkeyreq_timestamp: 0, didkeyreq_interval: 30.
[20200819 20:56:51] [D] cmd_internal_request_dinfo
[20200819 20:56:51] [W] cmd_internal_request_dinfo:1769, ot_agent_internalfd: -1
[20200819 20:56:51] [W] No helper script?

If I run the modified miio_client by hand and then run the netstat -nlup

root@Aqara_Hub-9053:~# netstat -nlup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:6666            0.0.0.0:*                           467/hkbridge
udp        0      0 0.0.0.0:10008           0.0.0.0:*                           467/hkbridge
udp     2432      0 0.0.0.0:54321           0.0.0.0:*                           1306/miio_client
udp        0      0 0.0.0.0:68              0.0.0.0:*                           740/dhclient
udp        0      0 0.0.0.0:68              0.0.0.0:*                           741/dhclient
udp        0      0 0.0.0.0:4993            0.0.0.0:*                           740/dhclient
udp        0      0 0.0.0.0:4275            0.0.0.0:*                           741/dhclient
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           467/hkbridge
udp6       0      0 :::2308                 :::*                                740/dhclient
udp6       0      0 :::4452                 :::*                                741/dhclient
udp6       0      0 :::5353                 :::*                                467/hkbridge

here another info if it is good for you

root@Aqara_Hub-9053:~# strace -s 1500 -f -p 1306
strace: Process 1306 attached
_newselect(6, [3 5], NULL, NULL, NULL

Hope this gives you more info about my problem :)

roth-m commented 4 years ago

It looks like you are now running the HomeKit version.... You need the "gw" program to which miio_client will connect.

gianlucaromito commented 4 years ago

and how can I get the gw program back? sorry for the "stupid" question... :)

gianlucaromito commented 4 years ago

I think I got it: reconfiguring the aqara hub with the xiaomi home app gives it the "gw" and removes the homekit. I've used the aqara app (android) Thanks for your help for getting me in the right direction!!!