Skip to content
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

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

Open
dbrandesky opened this issue Dec 20, 2023 · 0 comments

Comments

@dbrandesky
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant