-
-
Notifications
You must be signed in to change notification settings - Fork 556
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
Add support for 'lumi.gateway.mieu01' subdevices #728
Comments
lumi.gateway.mieu01
subdevices
@javicalle alright lets see if we can get this working:
That will print basic information about your gateway and that will confirm that the communication is okay. (although since it works with the HomeAssistant integration this schould not be a problem)
Hopefully that will print a list of your subdevices..... fingers crossed.... |
@javicalle actually now that I think of it, steps 2 till 4 can simply be replaced by running this test code: from miio import Gateway |
Here are the results (some values have been obfuscated):
and the
|
Also tested with same results:
|
That was indeed what I was going to sugest ;) Well it does look like your gateway is recognizing the "get_device_list" command. Could you try running some random fake command like "test123" and see if you then also get the How many subdevices do you have connected to your gateway? Unfortuanately I do not yet have an idea how to resolve that timeout issue.... |
@rezmus do you have an idea where this timeout is comming from, is it indeed because too many devices are connected and the response message grows too big for the gateway? Do you have any ideas how to resolve that? |
lumi.gateway.miXXXX and lumi.gateway.aqhm0X do not provide a way to get subdevices list. you need to define them yourself. |
I get the same error. Now the file content is:
And there are 5 devices connected to gateway. |
@javicalle apperently you cannot obtain the device list on the 'lumi.gateway.mieu01' according to @rezmus which is quite a dissapointment... Although I do find it strage that the gateway does not simply give the "method not found" as response to the "get_device_list" so maybe there is still some hope... For now lets first test if the subdevices actually work the same way, otherwise it is going to be a big effort to get 'lumi.gateway.mieu01' support. @javicalle do you know the sid and devicetype of your 5 connected subdevices? If so you can try:
where sid is the sid of the subdevice |
I only have 3 different types of devices:
My "Xiaomi Home" app don't have this option (no 'About' option available), and I have get the device info from others sources.
The modified app gives to me this info:
If my interpretation is correct, it does not fit with any of the currently implemented models. Anyway, I have tested the 2 available implementations with the motion sensor:
(I had to overwrite my venv's gateway class with the last one from the repository) In both cases I have had the same error:
I continue doing some tests |
I have modified my class DeviceType(IntEnum):
"""DeviceType matching using the values provided by Xiaomi."""
Unknown = -1
Gateway = 0 # lumi.0
Switch = 1 # lumi.sensor_switch
Motion = 2 # lumi.sensor_motion
MotionV2 = 222 # lumi.sensor_motion.v2 for testing purposes
.../... @command()
def discover_devices(self):
"""
Discovers SubDevices
and returns a list of the discovered devices.
"""
# from https://github.com/aholstenson/miio/issues/26
device_type_mapping = {
DeviceType.Switch: Switch,
DeviceType.Motion: Motion,
DeviceType.MotionV2: MotionV2, # probably not necessary class MotionV2(SubDevice):
"""Subdevice Motion specific properties and methods."""
properties = []
_zigbee_model = "lumi.sensor_motion.v2"
_model = "RTCGQ01LM"
_name = "Motion sensor v2" The Now, my test class is the next one:
With these changes I get exactly the same error. |
get_battery method is not supported by these hubs. |
I just commented the |
@javicalle the motion sensor, door sensor and button do not have specific properties you can get. (only subscriptions to events but that still needs to be implemented). Besides the
You could try those... In general there are 5 functions to interact with the device:
So you can play around with those functions, but you will need to know or be very lucky to guess the commands/properties.... If you truly want to figure out commands/properties you will need to sniff the trafic of the MiHome app and see if you can discover commands/properties that work with this gateway.
|
dev.get_property("voltage") |
@rezmus on my gateway 'lumi.gateway.v3' those two give my empty responses [], the same as if I issue a random non existing property like dev.get_property("this_does_not_exist") @javicalle but you can certainly try those on your gateway. |
My results:
|
aqara hubs can read lqi, mi hubs can't. |
@rezmus my hub 'lumi.gateway.v3' which is to my knowladge an chinese aqara hub gives an empty response on @javicalle intresting that the At this point it is pretty clear that the 'lumi.gateway.mieu01' supports different commands than the 'lumi.gateway.v3'. So someone who has acces to a 'lumi.gateway.mieu01' will have to do some development to get it supported with one of the biggest isues beeing there is no way to get the device_list. If the device_list was the only problem I could have made a workaround by letting users configure a manual device_list, but since there are more commands that differ, that method is going to run into problems. withouth having acces to the device ('lumi.gateway.mieu01') I can therefore not easily implement support.... I am sorry @javicalle. Of course it would be awesom if you could implement support @javicalle and I am open to helping and giving feedback on PR's for that, but that will be some effort. |
lumi.gateway.v3 - mi cn (called 2nd gen) lumi.gateway.miXXXX - mi global hubs in contrast to mi cn, aqara and mi global have almost similar hardware/firmware and run embedded linux (arm), but aqara is way better supported (new devices). all 3 hubs should work more or less the same for core methods to get/set props and invoke actions on subdevices, however they may vary on the list of supported models and minor stuff. |
This schould prevent some errors on the 'lumi.gateway.mieu01': #732 @rezmus do you have any sugestion to get a list of connected devices for 'lumi.gateway.mieu01' (does not matter if we get zigbee_id or the integer mapping values)? |
i took a look at firmware and i doubt there is such method. also never seen xiaomi cloud api reverse engineered. i think only solution is custom mi home version which dumps whole devices list to file. |
There are some pieces of the cloud api used by openhab (namely for the token extraction, https://www.openhab.org/addons/bindings/miio/#tokens), so it could be possible to obtain other information the same way. I don't know about other open source implementations for the API, porting the cloud access would require some serious effort, especially to keep the details similar to openhab's to avoid getting blocked by the servers. As like to keep this library offline-only, such functionality should be externalized to another project. |
Thanks for the hint @rytilahti!
Unfortunately the code is written in java which I don't know. @javicalle do you happen to know java? |
@rytilahti I agree that online cloud connection code would be best implemented in a separate python library. |
@starkillerOG I don't think it's a good idea to make python-miio to be directly dependent, if such library would be created. I think a proper way would be to make it possible to feed a list of available devices to the gateway class, then it wouldn't be dependent on any potential issues with the cloud access. The device list could simply be a simple ini/json configuration file with list of devices (and other things, if needed), which could also be manually filled, e.g., based on the information shown by the official app. |
Ticked, and I have DE too (my locale is BE). I actually re-installed the gateway from the informations given by micloud (ip and token) as that gives you the token very easily so it's the same. One thing maybe, in the micloud json, the gateway is the second device as the first one is a Xiaomi camera. |
@tbarbette could you try running this python code (preferably inside the virtual enviroment of HomeAssistant)?
And then see if the gateway is listed in the dict |
@tbarbette the order in which the devices are listed is not importend, a for loop over the devices is made to see if the gateway can be found: python-miio/miio/gateway/gateway.py Lines 207 to 221 in 5ea3157
|
@tbarbette Note that this needs to be an exact match of the mac (case and format sensitive). |
Hi,
I'm in spain so i put the de server Thanks for your help |
I agree, but that is something for a future PR, that is a bit more complicated than you might think:
|
@jonasCr do you see any errors in the log? |
Ook, that's it. Mine are in the Recognized section but not in the supported :( ... |
Yeah, I think it's because here there are selling a kit with the kit and 5 sensors (2 doors, 2 motion and 1 button) and all of them are recognized but not supported, for now. Hopefully the support is coming soon. Until that it's useless for me 😉 |
I get the same list than with the micloud client. Today I tried to hit "reload" and I don't get that message anymore... I only have sensors so I can't verify something else was added up. I think I did not select the right server at the first try, maybe the change of server was not saved? Anyway I guess it works :) Thanks! And yes, please support events :p |
Is there anything I can help with or do to get event driven sub-devices supported? |
@airampg thanks for the offer, I will look into this soon. |
Can't we put the "subdevices" manually? (if I take them out of the cloud? Any tutorials?) |
@MilorES the following python script schould do what you want:
|
Is there any activity to get these devices also supported? I would be happy to help and support but unfortunately I am really new to HA. But I am open to new challenges. :) |
@Artredis it is still on my to do list, but just did not have the time to get around to it. |
Hey @starkillerOG, thank you again for your amazing job. I was wondering if you are familiar with the custom integrations that use the MIoT-Spec such as: I just wanted to add that I have tried both and they are able to detect all my ZigBee devices connected to my lumi.gateway.mieu01 using the cloud connection method.
It detects, but does not create a device or integration for:
Comments:
Both of them have a noticeable delay (2 to 4 seconds) when changing the state of the sensors, as expected from the usage of the cloud. However, this is better than having nothing when I want to see if a window is open, or similar. |
@airampg I was aware that the status could be retrieved from the cloud. I think both integrations do not allow for local communication with the zigbee devices right? Local control and push updates were the main reason I did not look into the MioT integrations (since I think they use cloud). |
The other I put the new xiaomi miot auto and asked me if I wanted it local or by cloud ... (so if it might be that I use some for local). |
Thank you for your reply, and sorry for not replying earlier. The SD card of my HA host started getting corrupted a few weeks back and I have had some intense work to do. I have now ordered an SSD... not happening again! |
@airampg I finally found some time to work on the push server. I am still working on the PR, but at least you know that there is some real progress now. |
The miio PR: #1288 Are all tested and ready for revieuw. Combined these PRs will add support for the following new devices: | Door sensor | lumi.sensor_magnet.v2 | MCCGQ01LM |
How can we help with the work you are doing? Sending any device? any donation? (I didn't find anything) Thank You |
@MilorES thank you for your generous offer. Regarding the device/donation. |
@MilorES I just setup github sponsors for my account: https://github.com/sponsors/starkillerOG/ if you are still intrested. Regarding the 'lumi.gateway.mieu01' subdevices, I am still waiting on a revieuw from @rytilahti, I will give him a gentile reminder in the PR. |
Well, I understand that it is complicated, I will wait patiently. Can I watch something @rytilahti now? |
I'd be happy for the official HA integration using this library to support subdevices! But for others like me who have been patiently waiting for years now (for good reasons, not criticising here), I think it's worth mentioning that, meanwhile the "xiaomi-miot-auto" integration available through HACS has support for subdevices and more or less everything we discussed here, and beyond. |
The EU version of the gateway is supported in the current versión of the library and can be intergated in HA.
Some tests had been made to evaluate subdevices resolution with no success:
where
gateway_devices.py
:@starkillerOG sugest (home-assistant/core#22078) a new approach with the
get_device_list
command.The text was updated successfully, but these errors were encountered: