Skip to content

Adding functions to video.py - getting "AttributeError: 'ApiWrapper' object has no attribute '<new function name>'" #233

Open
@dbrandesky

Description

@dbrandesky

I'm attempting to contribute to this project by adding some API options I'd like to use for my Amcrest IP5M cameras. I figured out the "pattern" for the functions in video.py; the particular item I'm adding is a "video in" option, so I created the following in the corresponding section of video.py:

   def set_night_switch_mode(self, value: int, channel: int) -> str:
        # 0: No Switch, always use day
        # 1: Switch depends on brightness
        # 2: Switch depends on time, switch to Night when time is after sunset or before sunrise
        # 3: No Switch, always use Night
        # 4: No switch, always use Normal
        return self.set_video_in_option(
            "SwitchMode", str(value), channel=channel
        )

    async def async_set_night_switch_mode(self, value: int, channel: int) -> str:
        # 0: No Switch, always use day
        # 1: Switch depends on brightness
        # 2: Switch depends on time, switch to Night when time is after sunset or before sunrise
        # 3: No Switch, always use Night
        # 4: No switch, always use Normal
        return await self.async_set_video_in_option(
            "SwitchMode", str(value), channel=channel
        )

I then created a venv to test my changes, made sure all the requirements were installed, then followed the instructions in the README to run some commands in a Python CLI.

First I ran the example in the README with no problem:

    from amcrest import AmcrestCamera
    camera = AmcrestCamera('192.168.0.1', 80, 'admin', 'password').camera

    #Check software information
    camera.software_information
    'version=2.420.AC00.15.R\r\nBuildDate=2016-09-08'

I then tried running my new function and received the following feedback:

camera.set_night_switch_mode()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'ApiWrapper' object has no attribute 'set_night_switch_mode'

I'm not really sure how I can update the ApiWrapper, from what I can tell it just calls each class so it should import the new functions as well. I know a decent amount about Python scripting but I'm far from a developer so I could be missing something obvious.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions