Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discover_devices doesnt work with xiaomi gateway v3 #916

Closed
exeq89 opened this issue Jan 21, 2021 · 8 comments
Closed

discover_devices doesnt work with xiaomi gateway v3 #916

exeq89 opened this issue Jan 21, 2021 · 8 comments
Labels

Comments

@exeq89
Copy link

exeq89 commented Jan 21, 2021

Hello,
im writing with some problem. when im running this in python3.6:

from miio import Gateway

gateway = Gateway("192.168.1.201", "3473613977763634775674464d653232")

print(gateway.send("get_device_list"))
i get result
[{'did': 'lumi.158d0001f50a33', 'model': 'lumi.weather.v1', 'num': 1, 'total': 6}, {'did': 'lumi.158d0001f52069', 'model': 'lumi.weather.v1', 'num': 2, 'total': 6}, {'did': 'lumi.158d0001fa6d43', 'model': 'lumi.weather.v1', 'num': 3, 'total': 6}, {'did': 'lumi.158d0001fa80bb', 'model': 'lumi.weather.v1', 'num': 4, 'total': 6}, {'did': 'lumi.158d00027cf600', 'model': 'lumi.sensor_cube.aqgl01', 'num': 5, 'total': 6}, {'did': 'lumi.4cf8cdf3c7e54c7', 'model': 'lumi.plug.mmeu01', 'num': 6, 'total': 6}]

but, when im doing it like this:
[root@xxx]# miiocli gateway --ip 192.168.1.201 --token 3473613977763634775674464d653232 discover_devices
Running command discover_devices
Error: {'code': -5015, 'message': 'device not found'}
i got an error :(

im using centos8 and python:
[root@xxx]# pip3 show python-miio
Name: python-miio
Version: 0.5.4
Summary: Python library for interfacing with Xiaomi smart appliances
Home-page: https://github.com/rytilahti/python-miio
Author: Teemu R
Author-email: tpr@iki.fi
License: GPL-3.0-only
Location: /usr/local/lib/python3.6/site-packages
Requires: android-backup, croniter, netifaces, appdirs, construct, pytz, cryptography, click, tqdm, zeroconf, attrs, importlib-metadata

but when im runnig:
[root@xxxx]# miiocli gateway --ip 192.168.1.201 --token 3473613977763634775674464d653232 info
Model: lumi.gateway.mgl03
Hardware version: Linux
Firmware version: 1.4.6_0043

everything is fine

when i do: print(gateway.discover_devices()) but get_device_list is working hmm?
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.6/site-packages/miio/gateway.py", line 284, in discover_devices
devices_raw = self.get_prop("device_list")
File "/usr/local/lib/python3.6/site-packages/miio/gateway.py", line 330, in get_prop
return self.send("get_device_prop", ["lumi.0", property])
File "/usr/local/lib/python3.6/site-packages/miio/device.py", line 144, in send
command, parameters, retry_count, extra_parameters=extra_parameters
File "/usr/local/lib/python3.6/site-packages/miio/miioprotocol.py", line 213, in send
self._handle_error(payload["error"])
File "/usr/local/lib/python3.6/site-packages/miio/miioprotocol.py", line 273, in _handle_error
raise DeviceError(error)
miio.exceptions.DeviceError: {'code': -5015, 'message': 'device not found'}

i got the xiaomi gateway v3 with aqara cube, zigbee socket, and 4 temperature aqara sensors. What could i do?

@exeq89 exeq89 added the bug label Jan 21, 2021
@exeq89
Copy link
Author

exeq89 commented Jan 27, 2021

no one? :(

@syssi
Copy link
Collaborator

syssi commented Jan 27, 2021

It looks like the get_device_prop ["lumi.0", property] call fails. Could you try to identify the failing property?

@syssi
Copy link
Collaborator

syssi commented Jan 27, 2021

Uh... it's get_device_prop ["lumi.0", "device_list"]. May be your device doesn't support the command and the use of get_device_list is required.

@syssi
Copy link
Collaborator

syssi commented Jan 27, 2021

You could try to replace this line:

devices_raw = self.get_prop("device_list")

with

devices_raw = self.send("get_device_list")

But I don't know the supported format. May be you've luck!? :-)

@exeq89
Copy link
Author

exeq89 commented Jan 27, 2021

i changed the line You mention, still no luck:
miiocli gateway --ip 192.168.1.201 --token xxxxx discover_devices
Running command discover_devices
Error: {'code': -9999, 'message': 'user ack timeout'}

@rezmus
Copy link

rezmus commented Jan 28, 2021

>{"method":"get_device_list","params":[],"id":99767}
<{"code":0,"result":[{"did":"lumi.X","model":"lumi.sensor_switch.aq2","num":1,"total":4},{"did":"lumi.X","model":"lumi.vibration.aq1","num":2,"total":4},{"did":"lumi.X","model":"lumi.weather.v1","num":3,"total":4},{"did":"X","model":"lumi.sen_ill.mgl01","num":4,"total":4}],"id":99767}

@starkillerOG
Copy link
Contributor

Sorry for not seeing this topic earlier, lumi.gateway.mgl03 was not yet supported.
This PR: #924 that has been merged today adds support for that gateway.
With the latest master branch it schould now work.

@starkillerOG
Copy link
Contributor

I think this issue can therefore be closed.
@syssi, if an issue involves the gateway, please tag me.

@syssi syssi closed this as completed Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants