jonghwanhyeon / python-switchbot

A Python library to control SwitchBot devices connected to SwitchBot Hub

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when getting Curtains: "TypeError: __init__() takes 3 positional arguments but 4 were given"

ninijay opened this issue · comments

Hey there

I was trying to access my curtains via the switchbot api. I tried to get all devices using the example code provided by the repo and always encounter this issue:

Traceback (most recent call last):
  File "/Users/zanidd/dvnll/repos/client-work/escape-room/switchbot_test.py", line 18, in <module>
    devices = switchbot.devices()
  File "/Users/zanidd/dvnll/repos/client-work/escape-room/venv2/lib/python3.9/site-packages/switchbot/__init__.py", line 14, in devices
    return [
  File "/Users/zanidd/dvnll/repos/client-work/escape-room/venv2/lib/python3.9/site-packages/switchbot/__init__.py", line 15, in <listcomp>
    Device.create(client=self.client, id=device["device_id"], **device)
  File "/Users/zanidd/dvnll/repos/client-work/escape-room/venv2/lib/python3.9/site-packages/switchbot/devices.py", line 53, in create
    return device_cls(client, id=id, **extra)
  File "/Users/zanidd/dvnll/repos/client-work/escape-room/venv2/lib/python3.9/site-packages/switchbot/devices.py", line 101, in __init__
    super().__init__(self, client, id, **extra)
TypeError: __init__() takes 3 positional arguments but 4 were given

Seems to be an issue somewhere in here:

class Curtain(Device):
    device_type_for = "Curtain"

    def __init__(self, client: SwitchBotClient, id: str, **extra):
        super().__init__(self, client, id, **extra)

        self.curtain_ids: List[str] = extra.get("curtain_devices_ids")
        self.calibrated: bool = extra.get("calibrate")
        self.grouped: bool = extra.get("group")
        self.master: bool = extra.get("master")
        self.open_direction: str = extra.get("open_direction")

Oh, there is a grammatical error. I'll fix it right now.

I just uploaded the fixed version. Upgrade the package please.

thank you <3