Skip to content

Commit

Permalink
add stubs for nanoleafapi (#11619)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlukas authored Dec 28, 2024
1 parent 4c5f85b commit 9424da3
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions stubs/nanoleafapi/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nanoleafapi.test_nanoleaf
2 changes: 2 additions & 0 deletions stubs/nanoleafapi/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "2.1.*"
upstream_repository = "https://github.com/MylesMor/nanoleafapi"
16 changes: 16 additions & 0 deletions stubs/nanoleafapi/nanoleafapi/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from nanoleafapi.digital_twin import NanoleafDigitalTwin as NanoleafDigitalTwin
from nanoleafapi.nanoleaf import (
BLUE as BLUE,
GREEN as GREEN,
LIGHT_BLUE as LIGHT_BLUE,
ORANGE as ORANGE,
PINK as PINK,
PURPLE as PURPLE,
RED as RED,
WHITE as WHITE,
YELLOW as YELLOW,
Nanoleaf as Nanoleaf,
NanoleafConnectionError as NanoleafConnectionError,
NanoleafEffectCreationError as NanoleafEffectCreationError,
NanoleafRegistrationError as NanoleafRegistrationError,
)
12 changes: 12 additions & 0 deletions stubs/nanoleafapi/nanoleafapi/digital_twin.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from nanoleafapi.nanoleaf import Nanoleaf

class NanoleafDigitalTwin:
nanoleaf: Nanoleaf
tile_dict: dict[str, dict[str, int]]
def __init__(self, nl: Nanoleaf) -> None: ...
def set_color(self, panel_id: int, rgb: tuple[int, int, int]) -> None: ...
def set_all_colors(self, rgb: tuple[int, int, int]) -> None: ...
def get_ids(self) -> list[int]: ...
def get_color(self, panel_id: int) -> tuple[int, int, int]: ...
def get_all_colors(self) -> dict[int, tuple[int, int, int]]: ...
def sync(self) -> bool: ...
1 change: 1 addition & 0 deletions stubs/nanoleafapi/nanoleafapi/discovery.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def discover_devices(timeout: int = 30, debug: bool = False) -> dict[str | None, str]: ...
68 changes: 68 additions & 0 deletions stubs/nanoleafapi/nanoleafapi/nanoleaf.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Any

RED: tuple[int, int, int]
ORANGE: tuple[int, int, int]
YELLOW: tuple[int, int, int]
GREEN: tuple[int, int, int]
LIGHT_BLUE: tuple[int, int, int]
BLUE: tuple[int, int, int]
PINK: tuple[int, int, int]
PURPLE: tuple[int, int, int]
WHITE: tuple[int, int, int]

class Nanoleaf:
ip: str
print_errors: bool
url: str
auth_token: str
already_registered: bool
def __init__(self, ip: str, auth_token: str | None = None, print_errors: bool = False) -> None: ...
def create_auth_token(self) -> str | None: ...
def delete_auth_token(self, auth_token: str) -> bool: ...
def check_connection(self) -> None: ...
def get_info(self) -> dict[str, Incomplete]: ...
def get_name(self) -> str: ...
def get_auth_token(self) -> str | None: ...
def get_ids(self) -> list[int]: ...
@staticmethod
def get_custom_base_effect(anim_type: str = "custom", loop: bool = True) -> dict[str, Incomplete]: ...
def power_off(self) -> bool: ...
def power_on(self) -> bool: ...
def get_power(self) -> bool: ...
def toggle_power(self) -> bool: ...
def set_color(self, rgb: tuple[int, int, int]) -> bool: ...
def set_brightness(self, brightness: int, duration: int = 0) -> bool: ...
def increment_brightness(self, brightness: int) -> bool: ...
def get_brightness(self) -> int: ...
def identify(self) -> bool: ...
def set_hue(self, value: int) -> bool: ...
def increment_hue(self, value: int) -> bool: ...
def get_hue(self) -> int: ...
def set_saturation(self, value: int) -> bool: ...
def increment_saturation(self, value: int) -> bool: ...
def get_saturation(self) -> int: ...
def set_color_temp(self, value: int) -> bool: ...
def increment_color_temp(self, value: int) -> bool: ...
def get_color_temp(self) -> int: ...
def get_color_mode(self) -> str: ...
def get_current_effect(self) -> str: ...
def set_effect(self, effect_name: str) -> bool: ...
def list_effects(self) -> list[str]: ...
def write_effect(self, effect_dict: dict[str, Incomplete]) -> bool: ...
def effect_exists(self, effect_name: str) -> bool: ...
def pulsate(self, rgb: tuple[int, int, int], speed: float = 1) -> bool: ...
def flow(self, rgb_list: list[tuple[int, int, int]], speed: float = 1) -> bool: ...
def spectrum(self, speed: float = 1) -> bool: ...
def enable_extcontrol(self) -> bool: ...
def get_layout(self) -> dict[str, Incomplete]: ...
def register_event(self, func: Callable[[dict[str, Incomplete]], Any], event_types: list[int]) -> None: ...

class NanoleafRegistrationError(Exception):
def __init__(self) -> None: ...

class NanoleafConnectionError(Exception):
def __init__(self) -> None: ...

class NanoleafEffectCreationError(Exception): ...

0 comments on commit 9424da3

Please sign in to comment.