INNER CODE UNIT · Python

available_buttons

theyosh/TerrariumPI · hardware/button/__init__.py:50

    def available_buttons(__cls__):
        return [
            {"hardware": hardware_type, "name": button.NAME}
            for hardware_type, button in __cls__.available_hardware.items()
        ]

    # Return polymorph relay....
    def __new__(cls, _, hardware_type, address, name: str = "", callback=None):
        try:
            known_buttons = terrariumButton.available_hardware
            return super(terrariumButton, cls).__new__(known_buttons[hardware_type])
        except:
            raise terrariumButtonException(f"Button of hardware type {hardware_type} is unknown.")

    def __init__(self, button_id, _, address, name: str = "", callback=None) -> None:
        "Create a new button based on type"

        self._device = {"device": None, "id": None, "address": None, "name": None, "state": None}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…