jeffreydwalter / arlo

Python module for interacting with Netgear's Arlo camera system.
Apache License 2.0
517 stars 124 forks source link

Mode Changing no longer works / other functions work with same credentials #197

Open cgmckeever opened 1 year ago

cgmckeever commented 1 year ago

Was using 1.2.58, mode changing seemed to stop in the last week. Noticed that 1.2.61 came out, thought it might resolve an issue .. same issue continued

Web login for the user allows all these functions described.

Code appear to be able to:

Code fails (more code below as well)

arlo.Arm(basestation)
arlo.CustomMode(basestations[0], "mode" + mode)

What version of Python are you using (python -V)?

Python 3.8.12

What operating system and processor architecture are you using (python -c 'import platform; print(platform.uname());')?

Dockerized Python Slim https://github.com/cgmckeever/smartthings/blob/master/arlo-util/Dockerfile ** update for 1.2.61

Which Python packages do you have installed (run the pip freeze or pip3 freeze command and paste output)?

arlo==1.2.61
cachetools==5.2.0
certifi==2022.9.24
charset-normalizer==2.1.1
google-api-core==2.10.2
google-api-python-client==2.66.0
google-auth==2.14.1
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.7.1
googleapis-common-protos==1.57.0
httplib2==0.21.0
idna==3.4
monotonic==1.6
oauthlib==3.2.2
pickle-mixin==1.0.2
protobuf==4.21.9
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyparsing==3.0.9
PySocks==1.7.1
requests==2.28.1
requests-oauthlib==1.3.1
responses==0.10.15
rsa==4.9
six==1.16.0
sseclient==0.0.22
uritemplate==4.1.1
urllib3==1.24

Which version of ffmpeg are you using (ffmpeg -version)?

bash: ffmpeg: command not found

Which Arlo hardware do you have (camera types - [Arlo, Pro, Q, etc.], basestation model, etc.)?

VMB4000-siren Pro2

What did you do?

If possible, provide the steps you took to reproduce the issue. A complete runnable program is good. (don't include your user/password or any sensitive info)

pip install -I arlo==1.2.61

arlo = Arlo(USERNAME, PASSWORD, "../../gmail.credentials")
basestation = arlo.GetDevice('Arlo-Main')
arlo.Arm(basestation)
mode = 1
basestations = arlo.GetDevices('basestation')
arlo.CustomMode(basestations[0], "mode" + mode)

What did you expect to see?

Change the mode

What did you see instead?

Hangs

Does this issue reproduce with the latest release?

cgmckeever commented 1 year ago

I think the error starts here

 def CustomMode(self, device, mode, schedules=[]):
        """ device can be any object that has parentId == deviceId. i.e., not a camera """
        parentId = device.get('parentId', None)
        if device.get('deviceType') == 'arlobridge':
            return self.request.post(f'https://{self.BASE_URL}/hmsweb/users/devices/automation/active', {'activeAutomations':[{'deviceId':device.get('deviceId'),'timestamp':self.to_timestamp(datetime.now()),'activeModes':[mode],'activeSchedules':schedules}]})
        elif not parentId or device.get('deviceId') == parentId:
            return self.NotifyAndGetResponse(device, {"from":self.user_id+"_web", "to": device.get("parentId"), "action":"set","resource":"modes", "transId": self.genTransId(),"publishResponse":True,"properties":{"active":mode}})
        else:
            raise Exception('Only parent device modes and schedules can be modified.')

where my device type is 'deviceType': 'basestation' and if I INSPECT the web-ui call it is in-fact making a call to /users/devices/automation/active (as opposed to using the self.NotifyAndGetResponse path)

however, short circuiting the device check and using self.request.post also brings up new errors ... looking

cgmckeever commented 1 year ago

self.NotifyAndGetResponse (from above) Just appears to sit on

DEBUG:urllib3.connectionpool:https://myapi.arlo.com:443 "POST /hmsweb/users/devices/notify/4R058A7NB5F33 HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://myapi.arlo.com:443 "POST /hmsweb/users/devices/notify/4R058A7NB5F33 HTTP/1.1" 200 None
jeffreydwalter commented 1 year ago

Hello, thank you for your PR! I made a branch to test out your changes and made some modifications to your proposed solution. Would you mind pulling down this branch and seeing if it works for you? https://github.com/jeffreydwalter/arlo/tree/fix-custom-mode

My basestation died so, I don't actually have any working Arlo cameras anymore. :(

cgmckeever commented 1 year ago

I will test shorty, but .. just looking at it, earlier I could not get it to work till I added the schema line .. but maybe you have another change in there accomplishing similar ...

and Ive said in the past -- I would totally send you a basestation ;)

cgmckeever commented 1 year ago

I get this

{"error": 401 Client Error: Unauthorized for url: https://myapi.arlo.com/hmsweb/users/devices}

even for something that had worked prior to the hotfix/PR I made

https://github.com/cgmckeever/smartthings/blob/master/arlo-util/www/cgi-bin/checkup.py

cgmckeever commented 1 year ago

@jeffreydwalter any thoughts on this?

cgmckeever commented 1 year ago
Hello, thank you for your PR! I made a branch to test out your changes and made some modifications to your proposed solution. Would you mind pulling down this branch and seeing if it works for you? https://github.com/jeffreydwalter/arlo/tree/fix-custom-mode

I had tried that and I got

{"error": 401 Client Error: Unauthorized for url: https://myapi.arlo.com/hmsweb/users/devices}

My earlier PR seems to work, but probably is not the clean way to do it ;)