roth-m / miioclient-mqtt

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

Couldn't forward local client package: Invalid argument #10

Closed serhat-ozkara closed 4 years ago

serhat-ozkara commented 4 years ago

Starting client does not have any effect, no message can be sent: Reading _internal message Device id received Local client disconnected. Local client connected Received from local client: {"method":"_internal.hello"} got _internal.hello Local client connected Local client disconnected. Local client connected Local client connected Local client disconnected. Local client disconnected. Local client connected Local client disconnected. Local client connected Local client disconnected. Local client connected Local client disconnected. Local client connected Local client disconnected. Local client connected Local client disconnected. Local client disconnected. Local client connected Local client disconnected. Local client connected Received from local client: {"id":1,"method":"props","model":"lumi.gateway.mieu01","params":{"from.illumination":"10,,1587804754922,0.trg=0,,","illumination":1178}} sending reply: {"id":1,"result":"ok"} Couldn't forward local client package: Invalid argument Received from local client: {"id":2,"method":"props","model":"lumi.gateway.mieu01","params":{"from.illumination":"10,,1587805046382,0.trg=0,,","illumination":1096}} sending reply: {"id":2,"result":"ok"} Couldn't forward local client package: Invalid argument

Modified client started with: killall miio_client && /home/root/hack/miio_client &

roth-m commented 4 years ago

Add this ( killall miio_client && /home/root/hack/miio_client ) & but not 2 lines as you did. You might get 2 miio_clients running (including the original one)

serhat-ozkara commented 4 years ago

Thank you for the info @roth-m .

root@imx6ull14x14evk:/lumi/app/miio# netstat -tulpn Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:54322 0.0.0.0: LISTEN 22974/miio_client tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 490/dropbear
tcp6 0 0 :::22 ::: LISTEN 490/dropbear
udp 0 0 0.0.0.0:10008 0.0.0.0:
23056/gw
udp 0 0 0.0.0.0:54321 0.0.0.0:* 22974/miio_client

Tried id as you said but client does not recieve any commands still. Only one instance of client is running as can be seen from netstat.

It seems I can't send any commands to device, but can see messages from gateway from packet sender when I connect to UDP 54321 of the gateway:

{"id":6,"sid":"lumi.158d0003e7d8f7","model":"lumi.sensor_motion.v2","method":"props","params":{"device_log":"[1587814825,[\"event.motion\",[]]]"}}

Is there any sample payload to send to see that i can issue commands?

roth-m commented 4 years ago

If you get the messages using nc -u <ip> 54321 then a PING should work. Just send: {"method": "internal.PING"}

serhat-ozkara commented 4 years ago

Yes, I got this: {"method": "internal.PONG", "result": ["online"]}\00

It seems issue is elsewhere of the implementation of cadavre on HA

Thank you for your help!

serhat-ozkara commented 4 years ago

It turns out, this implemantation conflicts with HA Xiaomi vacuum implementation which uses https://github.com/rytilahti/python-miio. Both are using same port 54321. Adding this as as reference. Ability to change port might be very good idea or implement methods to the other library. @roth-m