paviro / MMM-FRITZ-Box-Callmonitor

This an extension for the MagicMirror. It provides a callmonitor for FRITZ!Box users alerting them about incoming calls.
29 stars 24 forks source link

KeyError: 'NewPhonebookList' #23

Closed matthes0815 closed 7 years ago

matthes0815 commented 7 years ago

Hey,

I just installed your module and it doesn't work, it displays "unknown error". These are the logged lines:

MMM-FRITZ-Box-Callmonitor error while accessing FRITZ!Box: Traceback (most recent call last): File "/home/pi/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/fritz_access.py", line 74, in main(args) File "/home/pi/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/fritz_access.py", line 60, in main handle.download_phone_book() File "/home/pi/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/fritz_access.py", line 23, in download_phone_book for phonebook_id in result["NewPhonebookList"]: KeyError: 'NewPhonebookList'

Regards Matthias

Jopyth commented 7 years ago

Hi Matthias,

I am not sure what causes this. Can you execute this on the command line (with or without user name depending on whether you have a user name setup) and post the contents of api.log here? Replace PASSWORD with the password you use to access your FRITZ!Box.

python -c "import fritzconnection as fc; fc.print_api(password='PASSWORD')" > api.log
python -c "import fritzconnection as fc; fc.print_api(password='PASSWORD',user='USER')" > api.log

Best regards Joseph

matthes0815 commented 7 years ago

Hey Joseph,

thank you for your answer. I'm using a 7490 with Fritz!OS 6.60. api.log attached as api.txt api.txt

Regards Matthias

Jopyth commented 7 years ago

This is exactly the same model, OS version and API as I have, which is bad, because I can not reproduce your error. Do you have any entries in your phonebook? Do you get this error if you execute the python script directly (in the MMM-FRITZ-Box-Callmonitor folder)?

python fritz_access.py -p PASSWORD -u USER

If so, can you add a print result after line 22 of the script and see what the output looks like?

matthes0815 commented 7 years ago

Yes, there are about 30 entries in the phonebook. Executing the script directly leads to the same error, the print returns {} followed by the error message Traceback (most recent call last): File "fritz_access.py", line 75, in <module> main(args) File "fritz_access.py", line 61, in main handle.download_phone_book() File "fritz_access.py", line 24, in download_phone_book for phonebook_id in result["NewPhonebookList"]: KeyError: 'NewPhonebookList'

Jopyth commented 7 years ago

I have been able to reach the error you describe, if I use a user without the rights to access the Phonebooks. Does this fit your case? Please make sure your user has the right to access FRITZ!Box settings.

German screenshot below:

German example

matthes0815 commented 7 years ago

oh damn... I checked the box but unchecked "Smart Home" and didn't notice that this removes the tick from the first box as well. I'm sorry for wasting your time! Thanks for your help!

Jopyth commented 7 years ago

No problem, glad it works now!