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

re-structure gateway devices #782

Closed
wants to merge 115 commits into from

Conversation

starkillerOG
Copy link
Contributor

@starkillerOG starkillerOG commented Aug 1, 2020

Restructure the gateway devices to put everything with simular API together.
The next step is to use common classes for devices with simular API (to be done in this PR).

This PR also creates the base classes for switches and light bulbs, so all known models are now fully supported, although some models have not been tested (they are assummed to have simular API calls as devices that are closely related).

This PR also adds subdevice support for the lumi.gateway.mgl03 and is a first step towards subdevice support for the lumi.gateway.mieu01

@coveralls
Copy link

coveralls commented Aug 1, 2020

Coverage Status

Coverage decreased (-6.2%) to 67.721% when pulling 3b3a3c9 on starkillerOG:patch-17 into 93b7a77 on rytilahti:master.

@starkillerOG
Copy link
Contributor Author

@rytilahti could you look if you agree with this structure for the gateway devices?
We have discussed this re-structuring before.

@starkillerOG
Copy link
Contributor Author

@rytilahti This is now finished, all tests pass and it now also includes all base classes for switches and light bulbs.

I can not actually test is since I don't own switches or light bulbs, but I am pretty sure it will work.
It is tested and does work with the weather sensors.

If this gets merged I can add all the light bulbs and switches to HomeAssistant.

@starkillerOG
Copy link
Contributor Author

The use of python-miio (importing) does not change with this PR, the following script will still work as it used to:

from miio import Gateway

gateway = Gateway("192.168.1.IP", "TokenTokenToken")

gateway.discover_devices()
devices = gateway.devices

for dev in devices.values():
    try:
        dev.update()
    except Exception as ex:
        print("got exception during update for %s: %s" % (dev.device_type, ex))
    print(dev)

Copy link
Owner

@rytilahti rytilahti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry for taking the time, it's a huuuge diff and I haven't found time to look much into it until now. Here's my initial round of comments, more will follow up later after the first round of changes :-)

miio/gateway/sub_device/lock.py Outdated Show resolved Hide resolved
miio/gateway/sub_device/motion_sensor.py Outdated Show resolved Hide resolved
miio/gateway/sub_device/remote_switch.py Outdated Show resolved Hide resolved
miio/gateway/sub_device/sensor.py Outdated Show resolved Hide resolved
miio/gateway/sub_device/switch.py Outdated Show resolved Hide resolved
miio/gateway/sub_device/button.py Outdated Show resolved Hide resolved
miio/gateway/sub_device/curtain.py Outdated Show resolved Hide resolved
miio/gateway/sub_device/sub_device.py Outdated Show resolved Hide resolved
miio/gateway/gateway.py Outdated Show resolved Hide resolved
miio/gateway/gateway.py Outdated Show resolved Hide resolved
@starkillerOG
Copy link
Contributor Author

@rytilahti no problem, you don't have to hurry, it is indeed a large restructure.

I won't have any time the next 3 weeks since I will be moving to a new house.
So I don't know if I will be able to finish this PR any time soon, but maybe in the evening hours.... we will see.

@starkillerOG
Copy link
Contributor Author

@rytilahti I have prosessed all feedback and all tests pass again.

@MicroSur
Copy link

MicroSur commented Aug 20, 2020

Is this PR will bring Aqara relay support in HomeAssistant at last?

And is it possible to expect the function of displaying the power consumtion on xiaomi wall switch with neutral line?

@starkillerOG
Copy link
Contributor Author

@MicroSur yes and yes.
But I will not have time to work on it in the coming weeks, and it still needs a second revieuw

This was referenced Jan 30, 2021
@starkillerOG
Copy link
Contributor Author

Whoops, I messed up the re-base to fix some merge conflicts.
Therefore I will close this PR and make a new one here: #924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet