pyaarlo
pyaarlo copied to clipboard
arlo.base_stations[0] - AttributeError: 'NoneType' object has no attribute 'get'
since few days, mode changes are not working anymore....
base = arlo.base_stations[0] .....
Traceback (most recent call last): File "arlo_baby_alert_aus.py", line 4, in tfa_type='SMS',tfa_source='console',synchronous_mode=True) File "/usr/local/lib/python3.6/site-packages/pyaarlo/init.py", line 210, in init self._refresh_bases(initial=True) File "/usr/local/lib/python3.6/site-packages/pyaarlo/init.py", line 278, in _refresh_bases base.update_modes() File "/usr/local/lib/python3.6/site-packages/pyaarlo/base.py", line 251, in update_modes props = resp.get('properties', {})
Ignore my other comment in the other bug this is something else. I'll take a look.
What kind of cameras/base stations do you have?
Hi have the arlo baby cam. Iam able to read settings, but since few days iam not able to set parameters. Mode change or e.g. nighlight on/off isnt working anymore.
Arlo changed their back end and I think you need to force the API to use v2 for mode changes.
Try adding mode_api='v2'
to your pyaarlo.PyArlo
startup parameters.
when i try to change the mode, iam getting this....
mode disarmed is unrecognised unknown
Ok different results for the general parameter issue and the mode change issue...
Light on/off and other parameters are working with the automatic email 2FA authentification and with synchronous_mode=True,mode_api='v2'. But sometimes this error occurs and after a second or third try its working....
File "arlo_baby_alert_aus.py", line 11, in <module> tfa_password='XXXXXX',synchronous_mode=True,mode_api='v2') File "/usr/local/lib/python3.6/site-packages/pyaarlo/__init__.py", line 143, in __init__ self._be = ArloBackEnd(self) File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 44, in __init__ self._logged_in = self._login() File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 467, in _login if not self._auth(): File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 355, in _auth 'EnvSource': 'prod'}, headers) File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 618, in auth_post return self._request(path, 'POST', params, headers, False, raw, timeout, self._arlo.cfg.auth_host) File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 88, in _request body = r.json() File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None
But mode changes are not working.
If Iam tryin to change the mode (it doesnt matter if armed, disarmed, custom) the mode wont be recognised.
Error message:
Cam-Name: mode disarmed is unrecognised
Additionally I listed all the available modes and my custom modes are missing in this list...
{'disarmed': 'mode0', 'armed': 'mode1'}
Be careful, you included your password. I'll modify the code to not show it going forward.
Ohhh thanks for that hint
info.... same issues with pyaarlo-0.7.0b2
missing modes are based on the mode_api flag.
This are my modes with mode_api=v2:
['disarmed', 'armed'] {'disarmed': 'mode0', 'armed': 'mode1'} Cam: mode disarmed is unrecognised unknown
this are the modes with mode_api=v1 (here you can see my custom-mode "noisealarm" and the script could read the actual mode (with v2 the actual mode is shown as "unknown"):
['disarmed', 'armed', 'noisealarm'] {'disarmed': 'mode0', 'armed': 'mode1', 'noisealarm': 'mode3'} Noisealarm
with v1 there is no error "Cam: mode disarmed is unrecognised" , but the script is not doing any mode changes too.
#####################
its tricky v1 together with synchronous_mode=True is showing one new line "unable to read mode, try forcing v2" and custom mode is misssing again
unable to read mode, try forcing v2 ['disarmed', 'armed'] {'disarmed': 'mode0', 'armed': 'mode1'} Cam: mode disarmed is unrecognised actual mode: unknown
#####################
and it seems that this error....
File "arlo_baby_alert_aus.py", line 11, in <module> tfa_password='XXXXXX',synchronous_mode=True,mode_api='v2') File "/usr/local/lib/python3.6/site-packages/pyaarlo/__init__.py", line 143, in __init__ self._be = ArloBackEnd(self) File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 44, in __init__ self._logged_in = self._login() File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 467, in _login if not self._auth(): File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 355, in _auth 'EnvSource': 'prod'}, headers) File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 618, in auth_post return self._request(path, 'POST', params, headers, False, raw, timeout, self._arlo.cfg.auth_host) File "/usr/local/lib/python3.6/site-packages/pyaarlo/backend.py", line 88, in _request body = r.json() File "/usr/local/lib/python3.6/site-packages/requests/models.py", line 898, in json return complexjson.loads(self.text, **kwargs) File "/usr/lib64/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/usr/lib64/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib64/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None
.... occurs if iam running two commands very short timed. If i will wait some seconds between the commands, this error wont occur.
unfortunately still the same result with pyaarlo-0.7.0b5
If it's not too big can you post the script you are trying to run? Obviously with all the sensitive bits hidden.
of course. this is my example for the disarm mode....
from pyaarlo import PyArlo
arlo = PyArlo(username='[email protected]',password='arlopwdXXXX',
tfa_source='imap',tfa_type='email',
tfa_host='mailhost',
tfa_username='[email protected]',
tfa_password='mailpwdXXXX',synchronous_mode=True,mode_api='v2')
# Get the base_station instance corresponding to the Arlo Baby
base = arlo.base_stations[0]
print(base.available_modes)
base.mode = 'disarmed'
Output is:
['disarmed', 'armed']
Cam_name: mode disarmed is unrecognised
Here you can see that my custom mode which is called "Noisealarm" is missing. And the mode change to "disarmed" isnt working.
The authentification method is working, because my script to turn nighlight on e.g. is working now with this parameters.
Thanks. I'll give it a try here. But the code is pretty simple so it should work...
Thank you very much, maybe one additonal info, if iam removing the mode_api and the synchronous_mode parameter then iam receiving all my available modes, but mode changes are not working too....
['disarmed', 'armed', 'noisealarm']
{'disarmed': 'mode0', 'armed': 'mode1', 'noisealarm': 'mode3'}
That's interesting, it almost suggests I need a hybrid mode or a better auto mode.
The problem is Arlo keeps tweaking the back end and I have to play catch up because we're piggy backing off the webapi. The other month they completely changed the login mechanism, locked everybody out until I could push a fix...
I notice you are comfortable using a branch. Is it ok if I push some test code the 0.7.0.beta.5
?
Yes of course that would be ok for me... thanks a lot for your efforts
No worries. The other problem is I don't have all the cameras and base stations so I rely on people who do to help with the debugging.
no problem, if you tell me what i have to do, i would assist you with the debugging ;-)
Can you try 0.7.0.beta.5? You can try it with and without the mode_api
parameter. I pushed 2 things:
- fixed a problem with synchronous mode when there is no real change
- try to be cleverer with which api to use
unfortunately no luck with the new version, same results....
with synchronous_mode=True,mode_api='v2':
['disarmed', 'armed']
cam: mode disarmed is unrecognised
with synchronous_mode=True,mode_api='v1':
unable to read mode, try forcing v2
['disarmed', 'armed']
cam: mode disarmed is unrecognised
without synchronous & without mode_api parameter:
['disarmed', 'armed', 'noisealarm']
no mode change possible
We need some extra debug! The following should print out some debug.
import logging
from pyaarlo import PyArlo
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
_LOGGER = logging.getLogger('pyaarlo')
arlo = PyArlo(username='[email protected]',password='arlopwdXXXX',
tfa_source='imap',tfa_type='email',
tfa_host='mailhost',
tfa_username='[email protected]',
tfa_password='mailpwdXXXX',synchronous_mode=True)
# Get the base_station instance corresponding to the Arlo Baby
base = arlo.base_stations[0]
_LOGGER.debug(base.available_modes)
_LOGGER.debug("current-mode={}".format(base.mode))
base.mode = 'disarmed'
I think I got my v1/v2 code wrong. But that's ok for now, can you try again but force mode_api='v2'
this time.
The debug is showing what I need, so that's good.
Can add this parameter.
verbose_debug=True
Sorry to keep asking but I'm not seeing the modes I'm expecting.
Crap. It can go on a bit. We're looking for stuff to do with the modes. It should look something like this:
This bit is getting a list of all the modes. The definitions?uniqueIds
is the important bit and the request-body
contains the result.
2020-09-30 11:41:02,469 - pyaarlo - DEBUG - request-url=https://my.arlo.com/hmsweb/users/automation/definitions?uniqueIds=XXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXX
2020-09-30 11:41:02,469 - pyaarlo - DEBUG - request-params=
{}
2020-09-30 11:41:02,469 - pyaarlo - DEBUG - request-headers=
{}
2020-09-30 11:41:02,623 - pyaarlo - DEBUG - request-end=200
2020-09-30 11:41:02,628 - pyaarlo - DEBUG - request-url=https://my.arlo.com/hmsweb/users/devices/notify/XXXXXXXXXXXXX
2020-09-30 11:41:02,629 - pyaarlo - DEBUG - request-params=
{'action': 'set',
'from': 'XXXXXXXXXXXXXXXXXX_web',
'properties': {'devices': ['XXXXXXXXXXXXX']},
'publishResponse': False,
'resource': 'subscriptions/XXXXXXXXXXXXXXXXXX_web',
'to': 'XXXXXXXXXXXXX',
'transId': 'web!e06dec1e-4ba9-4536-afd6-55c2753cf1a4'}
2020-09-30 11:41:02,629 - pyaarlo - DEBUG - request-headers=
{'xcloudId': 'XXXXXXXXXXXXXXXXXXXXXXXX'}
2020-09-30 11:41:02,634 - pyaarlo - DEBUG - request-body=
{'data': {'XXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXX': {'modes': [{'id': 'mode0',
'name': '',
'type': 'disarmed'},
{'devices': {'XXXXXXXXXXXXX': {'motionStart': {'enabled': True,
'lightOn': {'brightness': 128,
'colorMode': 'white',
'duration': 10,
'enabled': True,
'flash': 'off',
'pattern': 'flood'},
'pushNotification': {'enabled': True},
'sendEmail': {'enabled': False,
'recipients': ['__OWNER_EMAIL__']},
'sensitivity': 80}},
'XXXXXXXXXXXXX': {'audioStart': {'action': 'motionStart',
'enabled': False,
'sensitivity': 3},
'motionStart': {'enabled': True,
'lightOn': {'brightness': 128,
'colorMode': 'white',
'duration': 10,
'enabled': True,
'flash': 'off',
'pattern': 'flood'},
'name': 'If '
'Motion '
'on '
'Side '
'Light',
'pushNotification': {'enabled': True},
'sendEmail': {'enabled': False,
'recipients': ['[email protected]']},
'sensitivity': 80}}},
'id': 'mode1',
'name': '',
'type': 'armed'},
{'devices': {'XXXXXXXXXXXXX': {'motionStart': {'enabled': True,
'lightOn': {'brightness': 255,
'colorMode': 'white',
'duration': 30,
'enabled': True,
'flash': 'off',
'pattern': 'flood'},
'pushNotification': {'enabled': False},
'sendEmail': {'enabled': False},
'sensitivity': 80}},
'XXXXXXXXXXXXX': {'motionStart': {'enabled': True,
'lightOn': {'brightness': 255,
'colorMode': 'white',
'duration': 10,
'enabled': True,
'flash': 'off',
'pattern': 'flood'},
'pushNotification': {'enabled': False},
'sendEmail': {'enabled': False},
'sensitivity': 80}}},
'id': 'mode2',
'name': 'Home',
'type': 'custom'}],
'olsonTimeZone': 'America/New_York',
'revision': 30,
'schedules': [{'enabled': True,
'id': 'schedule.1',
'name': 'Arm '
'light '
'7days '
'6pm-6am',
'schedule': [{'days': ['Tu',
'Mo',
'Su',
'Th',
'Fr',
'We',
'Sa'],
'duration': 720,
'endActions': {'disableModes': ['mode1'],
'enableModes': ['mode0']},
'startActions': {'disableModes': ['mode0'],
'enableModes': ['mode1']},
'startTime': 1080,
'type': 'weeklyAction'}]}],
'schemaVersion': 1,
'timeZone': 'EST5EDT,M3.2.0,M11.1.0',
'type': 'automation'}},
'success': True}
And this is where we parse them out. We map mode to name.
2020-09-30 11:41:02,634 - pyaarlo - DEBUG - mode0<=M=>disarmed
2020-09-30 11:41:02,634 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIdToName/mode0=disarmed
2020-09-30 11:41:02,634 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeNameToId/disarmed=mode0
2020-09-30 11:41:02,634 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIsSchedule/disarmed=False
2020-09-30 11:41:02,635 - pyaarlo - DEBUG - mode1<=M=>armed
2020-09-30 11:41:02,635 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIdToName/mode1=armed
2020-09-30 11:41:02,635 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeNameToId/armed=mode1
2020-09-30 11:41:02,635 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIsSchedule/armed=False
2020-09-30 11:41:02,635 - pyaarlo - DEBUG - mode2<=M=>Home
2020-09-30 11:41:02,635 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIdToName/mode2=Home
2020-09-30 11:41:02,640 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeNameToId/home=mode2
2020-09-30 11:41:02,640 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIsSchedule/home=False
2020-09-30 11:41:02,641 - pyaarlo - DEBUG - schedule.1<=S=>Arm light 7days 6pm-6am
2020-09-30 11:41:02,641 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIdToName/schedule.1=Arm light 7days 6pm-6am
2020-09-30 11:41:02,641 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeNameToId/arm light 7days 6pm-6am=schedule.1
2020-09-30 11:41:02,641 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/modeIsSchedule/arm light 7days 6pm-6am=True
2020-09-30 11:41:02,641 - pyaarlo - DEBUG - get+response running
2020-09-30 11:41:02,910 - pyaarlo - DEBUG - request-end=200
And now we work out what mode is active. The automation/active
call will do that. It returns an entry per device in the system. We find the one we are interested in and convert that into an activeMode
.
2020-09-30 11:41:02,910 - pyaarlo - DEBUG - request-url=https://my.arlo.com/hmsweb/users/devices/automation/active
2020-09-30 11:41:02,910 - pyaarlo - DEBUG - request-body=
{'success': True}
2020-09-30 11:41:02,911 - pyaarlo - DEBUG - request-params=
{}
2020-09-30 11:41:02,911 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/connectionState=available
2020-09-30 11:41:02,911 - pyaarlo - DEBUG - request-headers=
{}
2020-09-30 11:41:02,912 - pyaarlo - DEBUG - pinging Front Base
2020-09-30 11:41:02,917 - pyaarlo - DEBUG - notify+response running
2020-09-30 11:41:02,917 - pyaarlo - DEBUG - post+response running
2020-09-30 11:41:03,087 - pyaarlo - DEBUG - request-end=200
2020-09-30 11:41:03,088 - pyaarlo - DEBUG - request-body=
{'data': [{'activeModes': ['mode0'],
'activeSchedules': [],
'gatewayId': 'XXXXXXXXXXXXX',
'schemaVersion': 1,
'timestamp': 1601457641009,
'type': 'activeAutomations',
'uniqueId': 'XXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXX'},
{'activeModes': ['mode0'],
'activeSchedules': [],
'gatewayId': 'XXXXXXXXXXXXX',
'schemaVersion': 1,
'timestamp': 1601457641590,
'type': 'activeAutomations',
'uniqueId': 'XXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXX'},
{'activeModes': ['mode0'],
'activeSchedules': [],
'gatewayId': 'XXXXXXXXXXXXX',
'schemaVersion': 1,
'timestamp': 1601457642012,
'type': 'activeAutomations',
'uniqueId': 'XXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXX'},
{'activeModes': ['mode0'],
'activeSchedules': [],
'gatewayId': 'XXXXXXXXXXXXX',
'schemaVersion': 1,
'timestamp': 1601479479248,
'type': 'activeAutomations',
'uniqueId': 'XXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXX'},
{'activeModes': ['mode0'],
'activeSchedules': [],
'gatewayId': 'XXXXXXXXXXXXX',
'schemaVersion': 1,
'timestamp': 1601457641307,
'type': 'activeAutomations',
'uniqueId': 'XXXXXXXXXXXXXXXXXXX_XXXXXXXXXXXXX'}],
'success': True}
2020-09-30 11:41:03,089 - pyaarlo - DEBUG - Front Lights schedule cleared
2020-09-30 11:41:03,089 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/activeSchedule=None
2020-09-30 11:41:03,089 - pyaarlo - DEBUG - Front Lights mode change mode0
2020-09-30 11:41:03,089 - pyaarlo - DEBUG - set:ArloBase/XXXXXXXXXXXXX/activeMode=disarmed
2020-09-30 11:41:03,089 - pyaarlo - DEBUG - notify+response running
So we definitely need v1 for reading the modes. Can you try without mode_api
and with synchronous_mode=True
.
Same debug if possible.
Can you pull the latest version and try again. I'm thinking there is a timing issue in synchronous mode.
Try without mode_api
and synchronous_mode=True
on step closer ;-)....
only synchronous_mode=True, without mode_api is now able to list all available modes. and there is now unrecognised error..
['disarmed', 'armed', 'noisealarm']
synchronous_mode=True,mode_api='v2'
['disarmed', 'armed']
Babycam: mode disarmed is unrecognised
But with both options there is still no change of the mode possible :-(. (to disarmed or any other mode)
now i tried to change the mode to 'armed' and i got a new output....
['disarmed', 'armed', 'noisealarm']
file not written
attempt 1: error in response when setting mode=
None
Can you send me the debug without mode_api
when you try and change the mode.
of course do i have to change the code?
_LOGGER.debug(base.mode = 'disarmed') or something like that?
You could add:
_LOGGER.debug('setting to disarmed')
base.mode = 'disarmed'
Can you try again with mode_api='v1'
?
It was a timing issue - interesting. I'll get the code sorted and push a final, fixed version later today.
nice... iam looking forward to the new version & thank you very much for support. Great work!
sorry to bother you, but it seems that now iam facing a new issue regarding the snapshot function.
there is now error, but the camera is not taking a new snapshot.
my example_code....
#trigger snapshot
cam.request_snapshot()
#sleep
time.sleep(20)
#snapshot url
url = cam.last_image
#download snapshot jpg
urllib.request.urlretrieve(url, '/usr/local/test/www/img/snapshot.jpg')
Snapshots can be a pain.
Try the function get_snapshot
, it will wait until the snapshot is finished and return the image as a byte array. last_image
will still work.
Also, try stream_snapshot=True
as a parameter to PyArlo
, you can sometimes have more success with that type of snapshot.
I'm pushing a fix for snapshots today. It should speed things up a lot.
nice, iam looking forward to that fix.
I just merged it into master.
Unfortunately Iam facing again some errors.... arlo changed the API again??
error in response={'data': {'error': '2605', 'message': 'We are sorry, The system is experiencing an unexpected issue.'}, 'success': False} Traceback (most recent call last): File "arlo_baby_nightlight_on.py", line 8, in <module> tfa_password='XXXXXXXX.',synchronous_mode=True,mode_api='v1') File "/usr/local/lib/python3.6/site-packages/pyaarlo/__init__.py", line 233, in __init__ self._ml.load() File "/usr/local/lib/python3.6/site-packages/pyaarlo/media.py", line 98, in load for video in data: TypeError: 'NoneType' object is not iterable
That's a back end issue but I should handle it a lot better. I'll take a look.
I just pushed a fix that will handle it better but the problem is most likely caused by the Arlo back end.,