• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

MMM-Fritz-Box-Callmonitor: Notification formatting

Scheduled Pinned Locked Moved Unsolved Troubleshooting
31 Posts 7 Posters 12.9k Views 7 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    Jan 0
    last edited by Feb 4, 2023, 2:35 PM

    Hi,
    I’m referring to this module (https://github.com/paviro/MMM-FRITZ-Box-Callmonitor). Although it is quite outdated, I still like it and I was able to transfer it to an python3 environment. However, since some update (don’t know which one), the notification (“alert”) is not formatted properly.
    The reason seems to be in line 85 of the file MMM-FRITZ-Box-Callmonitor.js:

    	// Override socket notification handler.
    	socketNotificationReceived: function(notification, payload) {
    		if (notification === "call") {
    			//Show alert on UI
    			this.sendNotification("SHOW_ALERT", {
    				title: this.translate("title"),
    				message: "<span style='font-size:" + this.config.numberFontSize.toString() + "px'>" + payload + "<span>",
    				imageFA: "phone"
    			});
    
    			//Set active Alert to current call
    			this.activeAlert = payload;
    		}
    

    There are two problems: 1) the title is not translated but printed, 2) the message is not formatted but the formatting information is printed verbosely.
    Unfortunately, I’m neither an expert in the MagicMirror syntax nor in javascript. Could somebody give me a hint how I need to adopt the code?

    Thanks

    C 2 Replies Last reply Feb 5, 2023, 7:18 AM Reply Quote 0
    • C Offline
      coernel @Jan 0
      last edited by Feb 5, 2023, 7:18 AM

      @Jan-0 Can you please fork the updated module? I also tried to make it run under Python3 but failed.

      I will then install and have a look at the formatting - though I am no expert either I will give my best.

      1 Reply Last reply Reply Quote 0
      • C Offline
        coernel @Jan 0
        last edited by Feb 5, 2023, 12:21 PM

        @Jan-0 Please publish your fork and I will have a look at the formatting!

        1 Reply Last reply Reply Quote 0
        • J Offline
          Jan 0
          last edited by Feb 5, 2023, 9:38 PM

          Thanks @coernel
          Here is the fork and the development branch: https://github.com/drtorchwood/MMM-FRITZ-Box-Callmonitor-py3/tree/code_update_2023

          C 1 Reply Last reply Feb 7, 2023, 9:22 PM Reply Quote 0
          • C Offline
            coernel @Jan 0
            last edited by Feb 7, 2023, 9:22 PM

            @Jan-0 I will have a look tomorrow!

            1 Reply Last reply Reply Quote 0
            • C Offline
              coernel
              last edited by Feb 9, 2023, 10:14 AM

              I tried to install it but the MagicMirror stays blank after that. I noticed that you don’t use a pyhton-3 shebang in your Python file. Could this be the cause? I will try later to add that!

              This is my config:

              {
              			module: 'MMM-FRITZ-Box-Callmonitor-py3',
              			position: 'bottom_left',	// This can be any of the regions. Best results in left or right regions.
              			header: "Verpasste Anrufe", // This is optional
              			config: {
              				username: "foo",
              				password: "bar",
              				reloadContactsInterval: 24*60,
              			}
              		},
              
              J 1 Reply Last reply Feb 10, 2023, 8:30 PM Reply Quote 0
              • J Offline
                Jan 0 @coernel
                last edited by Feb 10, 2023, 8:30 PM

                @coernel Perhaps, my renaming of the module is the problem. On my computer, the module is stilled named “MMM-FRITZ-Box-Callmonitor”. I only renamed it for the branch.
                I will check this in the next days.
                Does python3 fritz-access.py -u '<username>' -p '<password>' work?

                S C 2 Replies Last reply Feb 10, 2023, 9:01 PM Reply Quote 0
                • S Away
                  sdetweil @Jan 0
                  last edited by Feb 10, 2023, 9:01 PM

                  @Jan-0 if you rename a module, you have to rename the folder and the filename AND EDIT the file and change it’s register clause w the right name.

                  modulename - folder
                  modulename.js
                  edit modulename.js and change 1 line of code

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  1 Reply Last reply Reply Quote 0
                  • C Offline
                    coernel @Jan 0
                    last edited by Feb 14, 2023, 3:59 PM

                    After changing some lines as suggested by sdetweil the MagicMirror loads again.

                    @Jan-0 said in MMM-Fritz-Box-Callmonitor: Notification formatting:

                    python3 fritz-access.py -u ‘’ -p ‘’

                    The filename is fritz_access.py. So after executing it I got

                     print json.dumps({"filename": file, "content": content})
                              ^
                    SyntaxError: invalid syntax
                    

                    This was easily solded by changing it to print (json.dumps({"filename": file, "content": content})) (Just adding round brackets) - that was a change from Python2 to Python3.

                    However it was followed by the next error urllib2 does not work in Python 3. According to stackoverflow urllib.error and urllib.request must be used for Python3.

                    Are you sure you uploaded the right code to github? It seems you accidentally uploaded th old python2 code!

                    W 1 Reply Last reply Feb 14, 2023, 8:53 PM Reply Quote 0
                    • W Offline
                      wishmaster270 Module Developer @coernel
                      last edited by Feb 14, 2023, 8:53 PM

                      @coernel
                      @Jan-0

                      Additional to the wrong rename the fritz_access.py had the mentioned wrong urllib2 imports. I fixed the python script and the import of the PythonShell module in node_helper.js.

                      I created a pull request a few seconds ago.

                      J C 2 Replies Last reply Feb 15, 2023, 9:15 PM Reply Quote 1
                      • 1
                      • 2
                      • 3
                      • 4
                      • 1 / 4
                      1 / 4
                      • First post
                        8/31
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy