-
-
Notifications
You must be signed in to change notification settings - Fork 568
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
Added more light controls for gateway #624
Conversation
print(x) | ||
return x >> 24 | ||
|
||
def brightness_and_color_to_int(brightness: int, color: Tuple[int, int, int]) -> int: |
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.
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: |
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.
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]) |
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.
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]) |
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.
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 |
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.
'.utils.rgb_to_int' imported but unused
Black would make changes.
Do you mind running running |
miio/gateway.py
Outdated
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
color_map = { | ||
"red": (255, 0, 0), |
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.
Black would make changes.
miio/gateway.py
Outdated
"orange": (255, 165, 0), | ||
"aqua": (0, 255, 255), | ||
"olive": (128, 128, 0), | ||
"purple": (128, 0, 128) |
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.
Black would make changes.
Yeah, I've fixed linting issues, there are no conflicts now. |
Great, let's get this merged then. Thanks 👍 |
* added color and brightness functionality * added command to set both color and brightness * linting fixes
* 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>
Colors and brightness stuff added