MMM-FRITZ-Box-Callmonitor icon indicating copy to clipboard operation
MMM-FRITZ-Box-Callmonitor copied to clipboard

0|mm | TypeError: PythonShell is not a constructor 0|mm | at Class.loadDataFromAPI (/home/pi/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/node_helper.js:216:17)

Open rbrueckner82 opened this issue 7 years ago • 16 comments
trafficstars

Does anyone know this mistake, meets with this as well as the FitBit module, according to MichMich it lies at the respective modules and not at the MagicMirror Core.

https://github.com/MichMich/MagicMirror/issues/1415

0|mm | TypeError: PythonShell is not a constructor 0|mm | at Class.loadDataFromAPI (/home/pi/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/node_helper.js:216:17) 0|mm | at Class.socketNotificationReceived (/home/pi/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor/node_helper.js:62:10) 0|mm | at Socket. (/home/pi/MagicMirror/modules/node_modules/node_helper/index.js:113:11) 0|mm | at emitTwo (events.js:126:13) 0|mm | at Socket.emit (events.js:214:7) 0|mm | at /home/pi/MagicMirror/node_modules/socket.io/lib/socket.js:513:12 0|mm | at _combinedTickCallback (internal/process/next_tick.js:131:7) 0|mm | at process._tickCallback (internal/process/next_tick.js:180:9)

rbrueckner82 avatar Oct 01 '18 07:10 rbrueckner82

Which MM version are you using?

Jopyth avatar Oct 02 '18 07:10 Jopyth

i had the issue with 2.4.1 and the latest 2.5.0

rbrueckner82 avatar Oct 02 '18 07:10 rbrueckner82

I have exactly the same issue. I tried to debug the fritz_access.py script. It seems to me something goes wrong when downloading the phone books. My FritzBox contains two phonebooks: The standard one which I can't delete and an external phonebook from my Google account. In my case result["NewPhonebookList"] in line 25 is 0,1. When moving through this list the second time phonebook_id gets the comma value instead of the value 1. I tried to fix it, but I still get the PhythonShell is not a constructor error I am using MagicMirror v2.5.0

PieBa avatar Oct 08 '18 20:10 PieBa

Same issue for me. I also tried to use curly brackets in line 10 of node_helper.js like so: const {PythonShell} = require ... But, now I receive:

SyntaxError: Unexpected Token F in JSON at position 2

M4Rv avatar Oct 10 '18 14:10 M4Rv

M4Rv,

Were you able to figure this out? I am getting the same issue after I had the brackets.

shayfer avatar Oct 21 '18 20:10 shayfer

same here :(

jub-jan avatar Nov 01 '18 16:11 jub-jan

I fixed it (at least for me)! It took me hours to find out, that it's a combination of three issues:

  1. As mentioned aldready above by M4Rv the require statement in line 10 of node_helper.js requires curly brackets: const {PythonShell} = require('python-shell');

  2. Options beginning at line 210 of node_helper.js need additional option "pythonPath":

		var options = {
			pythonPath: 'python',
			mode: 'json',
			scriptPath: path.resolve(__dirname),
			args: args
		};
  1. I assume this is only an issue, if the Fritz!Box uses more than one Phonebook: The NewPhoneookList received in line 22 of fritz_access.py contains commas between the IDs. These commas need to be removed from the array before going through the array in the for loop. I added the line result["NewPhonebookList"] = result["NewPhonebookList"].replace(",","") in fritz_access.py right before the existing line for phonebook_id in result["NewPhonebookList"]:

I hope this works also for you.

PieBa avatar Nov 03 '18 21:11 PieBa

good job, worked for me! it shows me recent calls but no live status "xyz is calling" - did i miss something in the config?

jub-jan avatar Nov 05 '18 08:11 jub-jan

Alerting of incoming calls worked for me from the beginning. I only had the above issue with the display of the list of recent calls. Did you activate the callmonitor of your Fritz!Box as described in step 4 of the installation instructions?

PieBa avatar Nov 05 '18 09:11 PieBa

Yeah i did.. at least i think so - hard to tell without feedback. running FRITZ!OS 06.87 on 6490 cable.

jub-jan avatar Nov 05 '18 10:11 jub-jan

good job, for me i set 1. and 2. and now is working fine

thanks

rbrueckner82 avatar Nov 05 '18 10:11 rbrueckner82

I reduced code for step 3 and created a new fork pieba which contains the changes for all three steps: https://github.com/PieBa/MMM-FRITZ-Box-Callmonitor/tree/pieba

New step 3: In file fritz_access.py just add .replace(",","") in line 26 before the : So the complete new line 26 would be like this: for phonebook_id in result["NewPhonebookList"].replace(",",""):

PieBa avatar Nov 09 '18 08:11 PieBa

How about a PR on this module?

Jopyth avatar Nov 18 '18 19:11 Jopyth

How about a PR on this module?

I am not a programmer and I am new to MM, github and linux. I don't know how to do a PR. However I'd like to contribute if I can.

PieBa avatar Nov 21 '18 17:11 PieBa

I have the problem that incoming calls are no longer displayed centrally. I have changed the items described above.

dajohnny2410 avatar Dec 06 '18 21:12 dajohnny2410

I have the problem solved for me :) (Python 3.8.x, MM2) Hier is the code.

In the file "node_helper.js": ... const {PythonShell} = require("python-shell"); //const PythonShell = require('python-shell'); ...

In the file "fritz_access.py":

..... import argparse, os, sys, json from fritzconnection import FritzConnection import urllib.request as urllib2 .....

and ..... def forward_file(self, url, filename): try: f = urllib2.urlopen(url) content = f.read().decode("utf-8") .....

brennerv avatar May 15 '21 16:05 brennerv