-
-
Notifications
You must be signed in to change notification settings - Fork 568
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
How to access zigbee peripherals (lumi.gateway.v3) #650
Comments
Unfortunately that part of the current gateway is not currently implemented, and it's waiting for someone to step in to do that. If you are interested in digging in, there is some test code I used during the initial implementation in this commit: 57ff028 The command to access zigbee devices differs per device ( If your goal is to access raw zigbee pieces, Long story short, there is no way to do that currently without code changes. To get started accessing the gateway and list the devices connected to it:
|
Thank you very much for answer, i am checking these posts and try to connect to my gateway from miio import Gateway gw = Gateway("192.168.123.123", "tokentokentoken") With this result pi@rpi:~ $ python3 mi.py During handling of the above exception, another exception occurred: Traceback (most recent call last): |
See https://github.com/rytilahti/python-miio/blob/master/miio/gateway.py#L27 - that lists the known subdevices. I'll create soon a PR to make it not crash but report an error during initialization, but until that you can simply modify that enum to contain that value. |
@rytilahti I think this ons can also be closed since the issues discussed here are all fixed I think |
The device type of 65 is still unknown/not implemented, so I think this can remain open? @miway80 could you please test your script with the current master, if it is otherwise working for you? Do you happen to know which device is the one that is causing the error? |
Sorry for later answer, with the current master i get it from miio import Gateway gw = Gateway("192.168.123.123", "tokentokentoken") pi@rpi:~ $ python3 mi.py |
@miway80 you schould use gw.discover_devices() to get the devices. If you run that command and want to access the devices again you can use the gw.devices property (note that a property is not callable, there do not use brackets behind a property, that is the warning you are seeing). |
Good, thanks, with gw.discover_devices() i get many subdevices, but how can i read and modify states each subdevices? I want use it for plug and switch Unknown subdevice type SubDeviceInfo(sid='lumi.158d0002013f4d', type_id=65, unkn own=1, unknown2=31, fw_ver=1) discovered, of Xiaomi gateway with ip: 192.168.31. 47 With gw.devices i only get only [] |
You need to run gw.discover_devices() and then gw.devices for the devices to show up in gw.devices. The error about the Unknown subdevice is a devicetype "65" that is not yet implemented in the code because we don't know what kind of device it is. |
If a subdevice is implemented you can get info of the subdevice by executing the following code:
The update() command will get the info from the device and then the properties can be vieuwd under the props: {} dict in print(dev). for control of specific subdevices see the implementation of that subdevice in the https://github.com/rytilahti/python-miio/blob/master/miio/gateway.py file. from the looks of it the plug does not have control capabilty implemented yet, but I imagine that it will use very simular commands as the already implemented AqaraRelayTwoChannels, you are very welcome to implement control capability of the plug! |
Thanks again, i just get info from hub_info, model: lumi.ctrl_86plug.aq1 is a wall plug as this photo I only want controller before wall plug and aqara wall one switch ( lumi.ctrl_neutral1.v1 ) |
With this code from miio import Gateway gateway = Gateway("192.168.1.IP", "tokentokentoken") gateway.discover_devices() for dev in devices: I get Unknown subdevice type SubDeviceInfo(sid='lumi.158d00015767a7', type_id=14, unknown=1, unknown2=0, fw_ver=4) discovered, of Xiaomi gateway with ip: 192.168.31.240 sid='lumi.158d00015767a7', type_id=14 == lumi.sensor_86sw1.v1 = aqara one switch wifi version seems that SwitchOneChannel = lumi.ctrl_neutral1.v1 |
@miway80 I just added the two device types in this PR: https://github.com/starkillerOG/python-miio/blob/patch-5/miio/gateway.py The RemoteSwitchSingleV1 (lumi.sensor_86sw1.v1) will probably not have properties that you can get and will require this PR to be merged and fully implemented #709, that will still take some time. If you want to use the AqaraWallOutlet (lumi.ctrl_86plug.aq1), you will have to figure out what properties the device has, follow these steps in editing the gateway.py file:
if you also want to controll the wall outlet you will need to implement something like is done with the @miway80 How experianced are you with programming? |
How experianced are you with programming? I am learning now in quarentine to program with tutorials.. Thank you very much, i just modified gateway.py and work for WallOulet, as do you said i changed neutral_0 by channel_0. <Subdevice Switch: lumi.158d0001f3b1b1 fw: 10 bat: 60 props: {}> Now the question is how can i change Status via python code? can i send any command for put Status on/off ? Also i will try sniff trafic using BlueStack, i have some xiaomi goods, if i get sniff goods then i can add to gateway.py and share here |
Excelent, so the properties that worked are Are there any other properties besides status and load_power that are visable in the MiHome app? to control the plug add this to the AqaraWallOutlet class:
then you can test it by running:
if it does not work:
|
Excelent, so the properties that worked are properties = ["channel_0", "load_power"] right? yes, it is ok Are there any other properties besides status and load_power that are visable in the MiHome app? No, in Mihome app only put, Today, Month, Current, Turn on / Turn off, Schedule, Countdown If only add it to gateway.py without modify mi.py i get a error, also if modify mi.py i get same error python3 mi.py |
The error says it all: the indentation is wrong, apperently line 943 of the gateway.py file has a tab as indentation while the rest of the file uses spaces (or the other way around). |
Sorry, i used tab and needed 2 spaces.. Now no identation error I check again and i change ["toggle"] for this another ["channel_0", "toggle"], ["channel_0", "on"], python3 mi.py The above exception was the direct cause of the following exception: Traceback (most recent call last): I just install BlueStack, but put can be not compatible with my hardware, i need a better laptop.. |
The error above means that you still have old files of the latest release version, the master branch has more up to date files that include the "extra_parameters" capability mentioned in the error.
Then the error above schould go away. |
0.5.1 is already out, but I'm thinking about streamlining the release process to make it easier to make releases (and to shorter the cycle to wait for fixes to go out) in the future. |
Sorry for later answer, but i was working.. I did it, but i got this error python3 mi.py Then i put # in line 2 and got this error python3 mi.py I also update and upgrade all via sudo apt-get, strange error because i dont have vacuum |
Hi again, i tried to fix it, yesterday installed neccesary modules croniter-0.3.32.tar.gz, zipp-3.1.0.tar.gz and importlib_metadata-1.6.0.tar.gz, now only vacuum and discovery error pi@rpi:~ $ python3 mi.py I check miio files and have discovery.py |
@miway80 I do not know much about these import errors, however version 0.5.1 of python-miio has been released yesterday. After you run that command you just need to reapply the changes that you made in the gateway.py file (just restore the backup of that file). |
@starkillerOG I just upgrade miio to 0.5.1. and restaure gateway.py but now i got other error python3 mi.py The above exception was the direct cause of the following exception: Traceback (most recent call last): |
I got error, then check in gateway.py and is lazy_discover=True from miio import Gateway print(gw.info()) gw.discover_devices() for dev in devices: I got -> 192.168.31.197 data= {"id": 1001, "method": "miIO.info", "params": []} |
@miway80 default is The gateway with ip 192.168.31.240 seems to be working as expected so I dont think there is need for aditional packet captures from that gateway. Mostly the gateway with ip 192.168.31.224 is intresting because we are trying to get that one to work right? So could you try with |
@miway80 I checked the device info from both gateways and they seem to be identical and running the same firmware, so they schould both work.... wifi signal strenght looks OK on both gateways (RSSI of -42 and -50) |
I just try it and get same error, Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last):
This gateway is very near to router, have good signal, i think that many devices linked is the problem |
I am kind of out of ideas if you can't get response of that gateway to show up in wireshark I would not know how to get it working.... You could try to remove the devices from the crouded gateway and move them to the now working gateway. Then you can test if the now working gateway stops working if you add too many devices and what the device limit is. But I understand that that might mess up you current setup if you start moving devices from one gateway to the other..... So it is up to you if your are willing to try that.... |
Yes, i will do it, but now very busy, about 10 days i will be more quiet, then try remove device one per one and put in other gateway checking code |
It could very well be that we are hitting the datagram size limitations (similar what happens with some devices when trying to request too many properties at once, hard to know without checking tho..), while it works just fine when the request is done through the cloud. |
Hi all, |
Can be is very similar to walloutlet Create a file x.py for get info from miio import Gateway gateway = Gateway("192.168.1.IP", "tokentokentoken") gateway.discover_devices() for dev in devices: And add to gateway.py Smart_plug = X ( X = number get in discover_devices) DeviceType.Smart_plug: Smart_plug, class Smart_plug(SubDevice):
|
@miway80 is right.
@wuid24 please post the results of that test script so we can point you in the right direction. |
Hi, trying to get the Plug type_id as @miway80 wrote, I've also tried to work on debug mode (using pycharm) and got the following error: |
@wuid24 alright, so there are two "unknown" devices, both with type_id=55, however in the latest python-miio gateway.py file this device type is already included as Besides those two water leak sensors 3 temperature sensors and 3 plugs are correctly detected.
I can see you did not update the gateway.py file from https://github.com/rytilahti/python-miio/blob/master/miio/gateway.py yet when you obtained this print. Please do update (the official version has not been released, so updating usig pip will not give you the latest version). Regarding the error message, you will get that error once you have the latest version of gateway.py because the
Regarding the plugs you want to integrate, as you can see you can already read out the status and load_power.
To add functionallity the Line 982 in de28e85
Try adding this to that class:
|
@wuid24 I also noticed that the |
@starkillerOG my understanding is that the older aqara sensors (the round ones) do not have the pressure measurement, only the newer rectangular ones do. |
@starkillerOG , i've aligned to gateway.py from master, I've added the
|
@miway80 thanks for the information. Your test script is missing a So the script schould be:
|
@miway80 You can also try replacing If those all don't work in the combinations that you can come up with, you will have to use bluestack to sniff the commands while turning on/off the plug and see what the exact commands are.... |
Hi, |
@wuid24 to be sure, it works with I just use python 3.7.1 and command line, so I don't know how pycharm works.... |
Will this command be true for the latest update in venv? |
I think so, but you can just try and then check if the gateway.py file looks the same right? |
@starkillerOG sorry for the late response, busy weekend...
|
@wuid24 thanks for confirming. |
just to report an error: |
when it will be possible to access the new platform via cloud for xiaomi gateways? |
Hi guys,
I am starting with python, I already have token and the gateway ip but I don't know how to start my code, can somebody send me a example or explain me how can i access my gateway and see zigbee devices?
I found it, but i dont know how can i put token and ip and read zigbee goods, for example controller my Plug = 11
Thanks in advance
The text was updated successfully, but these errors were encountered: