jeffreydwalter / arlo

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

CustomMode function seems to be broken #168

Closed TaZZaT closed 3 years ago

TaZZaT commented 3 years ago

Please answer these questions before submitting your issue. Thanks!

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

Python 2.7.16

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

('Linux', 'raspberrypi', '5.10.11-v7+', '#1399 SMP Thu Jan 28 12:06:05 GMT 2021', 'armv7l', '')

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

Paste your ouptut here
arandr==0.1.9
arlo==1.2.47
asn1crypto==0.24.0
automationhat==0.2.0
blinker==1.4
blinkt==0.1.2
boto3==1.17.3
botocore==1.20.3
buttonshim==0.0.2
Cap1xxx==0.1.3
certifi==2018.8.24
chardet==4.0.0
Click==7.0
colorama==0.3.7
colorzero==1.1
configparser==3.5.0b2
cookies==2.2.1
cryptography==2.6.1
drumhat==0.1.0
ecdsa==0.16.1
entrypoints==0.3
enum34==1.1.6
enums==0.0.2
envirophat==1.0.0
envs==1.3
ExplorerHAT==0.4.2
Flask==1.0.2
fourletterphat==0.1.0
funcsigs==1.0.2
future==0.18.2
futures==3.3.0
gpiozero==1.5.1
gyp==0.1
idna==2.6
influxdb==5.3.1
ipaddress==1.0.17
itsdangerous==0.24
Jinja2==2.10
jmespath==0.10.0
keyring==17.1.1
keyrings.alt==3.1.1
MarkupSafe==1.1.0
microdotphat==0.2.1
mock==2.0.0
monotonic==1.5
mote==0.0.4
motephat==0.0.3
msgpack==1.0.2
numpy==1.16.2
oauthlib==2.1.0
olefile==0.46
pantilthat==0.0.7
parse==1.18.0
pathlib==1.0.1
pbr==4.2.0
phatbeat==0.1.1
pianohat==0.1.0
picamera==1.13
piglow==1.2.5
pigpio==1.44
Pillow==5.4.1
pycairo==1.16.2
pycrypto==2.6.1
pycryptodome==3.3.1
pyemvue==0.12.2
pygame==1.9.4.post1
PyGObject==3.30.4
pyinotify==0.9.6
PyJWT==1.7.0
pyOpenSSL==19.0.0
pyserial==3.4
PySocks==1.7.1
python-dateutil==2.8.1
python-jose-cryptodome==1.3.2
pytz==2021.1
pyxdg==0.25
rainbowhat==0.1.0
requests==2.21.0
requests-oauthlib==1.0.0
responses==0.9.0
RPi.GPIO==0.7.0
RTIMULib==7.2.1
s3transfer==0.3.4
scrollphat==0.0.7
scrollphathd==1.2.1
SecretStorage==2.3.1
sense-hat==2.2.0
simplejson==3.16.0
six==1.12.0
skywriter==0.0.7
sn3218==1.2.7
spidev==3.4
sseclient==0.0.22
touchphat==0.0.1
twython==3.7.0
unicornhathd==0.0.4
urllib3==1.26.3
vim==0.0.1
warrant==0.6.1
Werkzeug==0.14.1

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

Paste your output here built with gcc 8 (Raspbian 8.3.0-6+rpi1) configuration: --prefix=/usr --extra-version='1~deb10u1+rpt1' --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100

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

Pro

What did you do?

When I call arlo.CustomMode(basestations[0], mode) I've created a small web server that sends mode changes to Arlo using Arlo.py examples...

Send a GET request::

get arlo mode --> curl http://localhost:8888/mode (This works)
set arlo mode --> curl http://localhost:8888/modex (This is now broken)
x=4 (home)
x=3 (stay)
x=2 (away)
x=0 (disarm)

If possible, provide the steps you took to reproduce the issue. curl http://localhost:8888/mode3

A complete runnable program is good. (don't include your user/password or any sensitive info)

def do_GET(self):
    self._set_headers()
    # self.wfile.write("<html><body><h1>hi!</h1></body></html>")
    path = self.path
    mode = path.replace("/", "")
    basestations = arlo.GetDevices('basestation')
    modes = arlo.GetModesV2()
    print(modes[0]['activeModes'])
    if re.match(r"mode[2-4]", mode):
       arlo.CustomMode(basestations[0], mode)
    elif re.match(r"mode0", mode):
   arlo.Disarm(basestations[0])
    elif re.match(r"mode", mode):
       modes = arlo.GetModesV2()
       responseMode = str(modes[0]['activeModes'])
       sendIt = re.search(r'\[u\'(.*)\'\]', responseMode)
       self.wfile.write(sendIt.group(1))
    elif re.match(r"SirenOn", mode):
   arlo.SirenOn(basestations[0])
    elif re.match(r"SirenOff", mode):
   arlo.SirenOff(basestations[0])
    elif re.search(r"GetLast", mode):
       cameraID = re.search(r'GetLast(.*)', mode)
       myJ = { 'lastImage' : data['lastImage'][cameraID.group(1)], 'lastVideo' : data['lastVideo'][cameraID.group(1)] }
       self.wfile.write(json.dumps(myJ))
       #self.wfile.write(data['lastVideo' ][cameraID.group(1)])
       #print(cameraID.group(1))

    modes = arlo.GetModesV2()
    print(modes[0]['activeModes'])

Paste your ouptut here Exception happened during processing of request from ('127.0.0.1', 33690) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 293, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 655, in init self.handle() File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request method() File "/home/pi/arlo/arlo_mode_2.py", line 72, in do_GET arlo.CustomMode(basestations[0], mode) File "/usr/local/lib/python2.7/dist-packages/arlo.py", line 435, in CustomMode return self.request.post('https://my.arlo.com/hmsweb/users/devices/automation/active', {'activeAutomations':[{'deviceId':device.get('deviceId'),'timestamp':self.to_timestamp(datetime.now()),'activeModes':[mode],'activeSchedules':schedules}]}) File "/usr/local/lib/python2.7/dist-packages/request.py", line 61, in post return self._request(url, 'POST', params, headers, raw) File "/usr/local/lib/python2.7/dist-packages/request.py", line 52, in _request raise HTTPError('Request ({0} {1}) failed: {2}'.format(method, url, r.json()), response=r) HTTPError: Request (POST https://my.arlo.com/hmsweb/users/devices/automation/active) failed: {u'data': {u'message': u'Failed to update Automation Definitions', u'reason': u'Unable to upload active automation. Please try again', u'error': u'AUTO-5050'}, u'success': False}

What did you expect to see?

Paste your ouptut here Should return the mode I selected e.g. mode3

What did you see instead?


Paste your ouptut here
From my debug log --> 

HTTPError: Request (POST https://my.arlo.com/hmsweb/users/devices/automation/active) failed: {u'data': {u'message': u'Failed to update Automation Definitions', u'reason': u'Unable to upload active automation. Please try again', u'error': u'AUTO-5050'}, u'success': False}

### Does this issue reproduce with the latest release?
Yes.  Note:  arlo.GetModesV2() works fine.  It seems the API at Arlo has changed.  I have been using my program for over two years...  No longer works since the recent authentication changes.  I also have a python program that listens to the event store.  That also works great.  As far as I can tell only the CustomMode Change is broken.

Thanks in advance.
TaZZaT commented 3 years ago

Quick note:

if I change things around in arlo.py for the CustomMode function this works -->

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}})

This cause the error above -->

return self.request.post('https://my.arlo.com/hmsweb/users/devices/automation/active', {'activeAutomations':[{'deviceId':device.get('deviceId'),'timestamp':self.to_timestamp(datetime.now()),'activeModes':[mode],'activeSchedules':schedules}]})

I'm thinking arlo's site is now looking for additional parameters or the "if"statement is not determining my system correctly (aka --> if(device["deviceType"].startswith("arloq")):).

jeffreydwalter commented 3 years ago

@TaZZaT I'll take a look at this soon,. Feel free to submit a PR to fix it.

neilferreira commented 3 years ago

Fixed ✌️

TaZZaT commented 3 years ago

@neilferreira Thank you!

jeffreydwalter commented 3 years ago

This should be fixed with the latest release (1.2.50).

cgmckeever commented 2 years ago

Looks like Im having a similar issue @TaZZaT . When I swap out the CustomMode with your snippet it works (for a basestation)

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}})

however, I didnt see a change to that line https://github.com/jeffreydwalter/arlo/blame/master/arlo.py#L551

@neilferreira what was the fix?

jeffreydwalter commented 2 years ago

@cgmckeever the fix was to set the schemaVersion header. I do that when you successfully authenticate. https://github.com/jeffreydwalter/arlo/blob/edbd17fb8ab60b1d5d36354c52f4ddb0966a9514/arlo.py#L186

cgmckeever commented 2 years ago

odd, Im having the exact issue and I think I pulled the latest

Requirement already satisfied: arlo in /usr/local/lib/python3.9/site-packages (1.2.57)

Using the suggested snippet seems to resolve it.

self.NotifyAndGetResponse