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

Added more light controls for gateway #624

Merged
merged 3 commits into from
Feb 17, 2020
Merged

Added more light controls for gateway #624

merged 3 commits into from
Feb 17, 2020

Conversation

approximatenumber
Copy link
Contributor

Colors and brightness stuff added

print(x)
return x >> 24

def brightness_and_color_to_int(brightness: int, color: Tuple[int, int, int]) -> int:

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

@@ -102,3 +102,11 @@ def int_to_rgb(x: int) -> Tuple[int, int, int]:
def rgb_to_int(x: Tuple[int, int, int]) -> int:
"""Return an integer from RGB tuple."""
return int(x[0] << 16 | x[1] << 8 | x[2])

def int_to_brightness(x: int) -> int:

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

miio/gateway.py Outdated
if color_name not in color_map.keys():
raise Exception(f'Cannot find {color_name} in {color_map.keys()}')
current_brightness = int_to_brightness(self.send("get_rgb")[0])
brightness_and_color = brightness_and_color_to_int(current_brightness, color_map[color_name])

Choose a reason for hiding this comment

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

line too long (101 > 100 characters)

miio/gateway.py Outdated
if color_name not in color_map.keys():
raise Exception(f'Cannot find {color_name} in {color_map.keys()}')
current_brightness = int_to_brightness(self.send("get_night_light_rgb")[0])
brightness_and_color = brightness_and_color_to_int(current_brightness, color_map[color_name])

Choose a reason for hiding this comment

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

line too long (101 > 100 characters)

miio/gateway.py Outdated
@@ -5,9 +5,22 @@

from .device import Device
from .click_common import command
from .utils import int_to_rgb, int_to_brightness, rgb_to_int, brightness_and_color_to_int

Choose a reason for hiding this comment

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

'.utils.rgb_to_int' imported but unused
Black would make changes.

@coveralls
Copy link

coveralls commented Feb 8, 2020

Coverage Status

Coverage decreased (-0.08%) to 70.979% when pulling 465fabf on approximatenumber:gateway-more-lights into ecf2ff5 on rytilahti:gateway.

@rytilahti
Copy link
Owner

Do you mind running running tox -e lint to fix the linting for that file? I can merge it after that to the WIP PR.

miio/gateway.py Outdated

_LOGGER = logging.getLogger(__name__)

color_map = {
"red": (255, 0, 0),

Choose a reason for hiding this comment

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

Black would make changes.

miio/gateway.py Outdated
"orange": (255, 165, 0),
"aqua": (0, 255, 255),
"olive": (128, 128, 0),
"purple": (128, 0, 128)

Choose a reason for hiding this comment

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

Black would make changes.

@approximatenumber
Copy link
Contributor Author

Do you mind running running tox -e lint to fix the linting for that file? I can merge it after that to the WIP PR.

Yeah, I've fixed linting issues, there are no conflicts now.

@rytilahti
Copy link
Owner

Great, let's get this merged then. Thanks 👍

@rytilahti rytilahti merged commit 46a1a46 into rytilahti:gateway Feb 17, 2020
rytilahti pushed a commit that referenced this pull request Mar 15, 2020
* added color and brightness functionality

* added command to set both color and brightness

* linting fixes
rytilahti added a commit that referenced this pull request Mar 16, 2020
* WIP: gateway support thanks to dgi (dustcloud fame) and javascript miio lib

* add set_gateway_volume, slight fixes

* port over to the new cli api, remove MessageNet which was supposed only for testing

* Added more light controls for gateway (#624)

* added color and brightness functionality

* added command to set both color and brightness

* linting fixes

* Fully finish the GatewayAlarm class and fix style issues (#633)

* add new line

* remove To Do comment

Since this does not have to do with the gateway (I think)

* Fully finish the GatewayAlarm class

* black fix styles

* fix hound issue

* flake8 was wrong, black is wright

* ignore flake8 E203 error since black handles that

* Turning --> Turn

Co-Authored-By: Teemu R. <tpr@iki.fi>

* Turning --> Turn

Co-Authored-By: Teemu R. <tpr@iki.fi>

* add type return

Co-Authored-By: Teemu R. <tpr@iki.fi>

* add flake8 exception for single line

* remove global flake8 ignore

* add extra space

* add return types

* fix return types

* datatime.datetime is unknown type

* remove print()

* Reorganize classes

* Use parent and improve init

* Add Xiaomi Aqara Gateway to readme

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

* Cleanup gateway for initial release

* fix import sorting

Co-authored-by: Maksim Melnikov <approximatenumber@gmail.com>
Co-authored-by: starkillerOG <starkiller.og@gmail.com>
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.

4 participants