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

Refactor & improve support for gateway devices #924

Merged
merged 18 commits into from
Feb 7, 2021

Conversation

starkillerOG
Copy link
Contributor

Due to a merge conflict PR #782 was closed, this is the continueation of that PR.

Restructure the gateway devices to put everything with simular API together.

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

@starkillerOG
Copy link
Contributor Author

@rytilahti I finally got around to implementing the changes as you suggested in your rivieuw: #782 (comment)

I think this is now ready for merging.
Could you take another look?

@starkillerOG
Copy link
Contributor Author

@rytilahti can you merge this?
All checks pass.

If this is merged I can continue with implementing the subdevices in HomeAssistant (such as the switches and relays etc.)

Add command to set vibration sensitivity of vibration sensor
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.

Sorry for the delay @starkillerOG, this looks great! Just a couple of very minor changes and then we can merge this.

miio/gateway/gateway.py Outdated Show resolved Hide resolved
miio/gateway/gateway.py Outdated Show resolved Hide resolved
miio/gateway/gateway.py Outdated Show resolved Hide resolved
miio/gateway/gateway.py Outdated Show resolved Hide resolved
@rytilahti rytilahti changed the title re-structure gateway devices Refactor & improve support for gateway devices Feb 7, 2021
miio/gateway/gateway.py Outdated Show resolved Hide resolved
miio/gateway/gateway.py Outdated Show resolved Hide resolved
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.

Sorry, I forgot that the checkers will require the import anyway. Here's what you can do to fix that flake8 error about the gateway class.

Btw, if you run pre-commit install the repository, the linting checks will be run locally before you can even commit (makes it faster than waiting for CI to check for isort/black/others) :-)

miio/gateway/devices/subdevice.py Outdated Show resolved Hide resolved
miio/gateway/devices/subdevice.py Show resolved Hide resolved
starkillerOG and others added 2 commits February 7, 2021 22:05
Co-authored-by: Teemu R. <tpr@iki.fi>
Co-authored-by: Teemu R. <tpr@iki.fi>
@starkillerOG
Copy link
Contributor Author

starkillerOG commented Feb 7, 2021

pre-commit install

Thanks for the tip, but I use Github Desktop, Not that fimiliar with the github command line yet.
Is there also a single command from poetry that runs all checks?
(or a simular command I can run from windows cmd in the github dir to run all checks at once?)

nvm, just saw that it also works with Github Desktop, that is very nice!!!

@starkillerOG
Copy link
Contributor Author

@rytilahti all checks now pass

@rytilahti
Copy link
Owner

Great! Thanks for your patience and hard work on refactoring this! 🎉

@rytilahti rytilahti merged commit a8289a6 into rytilahti:master Feb 7, 2021
@rytilahti rytilahti mentioned this pull request Mar 13, 2021
xvlady pushed a commit to xvlady/python-miio that referenced this pull request May 9, 2021
* re-structure gateway devices

* re-apply already merged commit

* black formatting

* fix isort and flake8

* fix black

* fix issort

* fix magnet sensor zigbee id

* update zigbee ids

* vibration sensitivity

Add command to set vibration sensitivity of vibration sensor

* fix issort

* simplify subdevice_model_map

* remove unnesesarry comment

* move imports to the top

* fix black

* Update miio/gateway/devices/subdevice.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* Update miio/gateway/devices/subdevice.py

Co-authored-by: Teemu R. <tpr@iki.fi>

* fix black

* fix isort and flake8 wanting to move above GatewayException class

Co-authored-by: Teemu R. <tpr@iki.fi>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants