-
-
Notifications
You must be signed in to change notification settings - Fork 564
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 basic dmaker.fan.p8 support and streamline miOT fan implementations #1029
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'm wondering if we should rethink how we should handle model handling. From the user's viewpoint it doesn't make sense to have separate classes for similar devices, where avoidable.
One potential way to achieve this would be to 1) allow explicit definition for models (as it is currently for the main impl class) and 2) if none is given, resort to calling info()
on the first I/O call to find out the model. What do you think?
I've introduced a class per device to have improved CLI support. I'm unsure it's a good decision or not. |
I think we should not do that as it has more potential for causing confusion in the long run, so here is my proposal for the CLI use:
Would that work for you? Would it be okay for you to rely on manual model definition for the next release (which I wish to get one out ASAP), and then adding this model feature for the next one after that? |
Fine for me! This PR shouldn't block the release. |
Okay, great! I'll try to prepare a new release later tonight then :-) |
I created #1038 to explore the idea I described above. It is rather hacky at this point and will need some more work, but I think something like that would be good to have in the longer term. |
Agreed. And another thing we should rethink is that how we handle new devices. Now we have a long list of miot-enabled devices(#627). And for each new device, we write many similar codes. Lines 16 to 82 in 62ee748
So I think we can fetch its MIoT-Spec from the server, and parse it so that it is automatically adapted. That 's what I have done in https://github.com/ha0y/xiaomi_miot_raw . Thanks to you and @syssi because it would not have been possible without your great works. If you don't mind, please give it a try. And the adapting method is in https://github.com/ha0y/xiaomi_miot_raw/blob/master/custom_components/xiaomi_miot_raw/deps/miot_device_adapter.py , which simply tries to find out all supported services and properties. |
Hi @ha0y and sorry for the late response, I have been following your efforts to provide generic support for miot devices. And I completely agree, that the current way we are doing miot support in this library does not scale. However, I have two concerns here:
I wrote some initial ideas on adding generic device types to this library here #1059 (comment) -- do you have an insight how easy it would to create rather generic, device-type specific interfaces for miot devices? In other words, do you know if, for example the vacuum devices, use same set of siid&piid values for a specific set of basic functionalities, or would that require device-specific mappings for each and every device? Considering we have a common "BaseFan" interface, what would it take to have the devices from the category to have at least basic functionality in a single "MiotFan" implementation? |
@rytilahti as dat as I have seen.. the devices do not have same set of siid&piid. There are some overlaps, but imho you can't assume same piid/siid point to the same sorry of property. |
Yes, it is not possible to vendor these files in the library, because each device has their own definition files, and dozens of devices join Xiaomi IoT every week.
It is also not possible to use the same set of siid & piid because they are not fixed. Accroding to Xiaomi's document, the manufacturer can specify the service and property of their device, which will change the order of them. And the apps doesn't identify those services and properties by iid, but by URN, which (as far as I know) only exists in spec files. When it comes to fan: many manufacturers create a private service to provide some additional functions, including 1%-100% speed. This is also a tough problem. |
Closes: #882