• 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 @wishmaster270
    last edited by Feb 15, 2023, 9:15 PM

    @wishmaster270
    I uploaded my changes in the branch code_update_2023 and did not pullit to the master of the fork.
    I will have a look at the pull requests tomorrow.

    1 Reply Last reply Reply Quote 0
    • C Offline
      coernel @wishmaster270
      last edited by Feb 16, 2023, 11:15 AM

      @wishmaster270 This is great.
      I can confirm that executing fritz_acces.py with username and password now works! It results in some structured data:

      <Call><Id>4373</Id><Type>3</Type><Called>0123456789</Called><Caller>SIP: 9328727</Caller><CallerNumber>54321</CallerNumber><Name>Some fancy Name</Name><Numbertype>sip</Numbertype><Device>Tardis</Device><Port>13</Port><Date>03.09.22 12:55</Date><Duration>0:02</Duration><Count></Count><Path /></Call>
      

      I also get the module to show however it does not show active nor missed calls. It just shows “no call”, the spinner and the phonebook.

      I used this config:

      			module: 'MMM-FRITZ-Box-Callmonitor-py3',
      			position: 'bottom_left',
      			header: "Verpasste Anrufe", 
      			config: {
      				username: "foo",
      				password: "bar",
      				reloadContactsInterval: 24*60,
      				minimumCallLength: 0,
      				showContactsStatus: true,
      				maximumCallDistance: 60*6,
      				maximumCalls: 4,
      				fade: false,
      				debug: true,
      			}
      		},
      

      So I guess the communication between the js and the py is faulty.

      I would like to help you with your formatting though in the end…

      W 1 Reply Last reply Feb 16, 2023, 5:01 PM Reply Quote 0
      • W Offline
        wishmaster270 Module Developer @coernel
        last edited by wishmaster270 Feb 16, 2023, 5:16 PM Feb 16, 2023, 5:01 PM

        @coernel
        The pythons script is only responsible to fetch the call history and the phonebook of the fritz box. The call notification is handled by java script.
        So should see a alter containing the (wrong formatted) phone number for each incoming call.

        Are you sure you activated the call notification on your fritz box by dialing

        #96*5*
        

        with a phone connected to the box (DECT phone works as well).

        Edit:
        I do not think the formatting problem is related to this module. As of the documentation of the alert module it should be possible to send either simple text or html formatted text.
        As a debug test i tried to send html formatted text with one of my other modules which ends in the same problem

        S 1 Reply Last reply Feb 16, 2023, 5:25 PM Reply Quote 0
        • S Offline
          sdetweil @wishmaster270
          last edited by Feb 16, 2023, 5:25 PM

          @wishmaster270 known bug. fixed in next release

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

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          W 1 Reply Last reply Feb 16, 2023, 5:31 PM Reply Quote 1
          • W Offline
            wishmaster270 Module Developer @sdetweil
            last edited by wishmaster270 Feb 16, 2023, 5:36 PM Feb 16, 2023, 5:31 PM

            @sdetweil
            I should have checked that. Thank you for the link.
            With the current develop branch the formatting works as expected, too.

            Edit: If the comment is removed of the translation files the translations work as well and the right title is displayed

            C 1 Reply Last reply Feb 22, 2023, 10:00 AM Reply Quote 1
            • C Offline
              coernel @wishmaster270
              last edited by Feb 22, 2023, 10:00 AM

              @wishmaster270 and @Jan-0 Is there now a current repository with the issues fixed? I would love to use the module as well.
              Also it should be added here : https://github.com/MichMich/MagicMirror/wiki/3rd-party-modules

              W J 2 Replies Last reply Feb 22, 2023, 5:27 PM Reply Quote 0
              • J Offline
                Jose Walsh
                last edited by Feb 22, 2023, 1:53 PM

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

                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: “” + payload + “”,
                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?

                To fix this, you can remove the quotes and use template literals instead. Template literals allow you to include variables and formatting within a string using backticks () instead of quotes. Here's how you can modify the code to use template literals: socketNotificationReceived: function(notification, payload) { if (notification === "call") { //Show alert on UI this.sendNotification("SHOW_ALERT", { title: this.translate("title"), message: ${payload}`,
                imageFA: “phone”
                });

                //Set active Alert to current call
                this.activeAlert = payload;
                

                }
                }
                As for the translation issue, you need to make sure that the translate function is correctly configured in your module. The translate function should be defined in the getTranslations function in the module’s node_helper.js file. Here’s an example of how to define the translate function:
                getTranslations: function() {
                return {
                en: “translations/en.json”,
                de: “translations/de.json”
                };
                },

                translate: function(key) {
                return this.translate(key);
                }
                This assumes that you have translation files for English and German located in the translations folder of your module. You may need to modify this code to match the structure of your module.

                I hope this helps! Let me know if you have any other questions.

                1 Reply Last reply Reply Quote 1
                • W Offline
                  wishmaster270 Module Developer @coernel
                  last edited by wishmaster270 Feb 22, 2023, 8:22 PM Feb 22, 2023, 5:27 PM

                  @coernel
                  Hi,
                  as i can see this fork https://github.com/drtorchwood/MMM-FRITZ-Box-Callmonitor-py3/tree/code_update_2023 contains all changes needed.
                  But you will need to either use the current development version of MagicMirror or wait for the next release which i think is planned for 2022-04-01 to get the alerts formatted correctly.

                  C 1 Reply Last reply Feb 24, 2023, 9:05 AM Reply Quote 1
                  • C Offline
                    coernel @wishmaster270
                    last edited by Feb 24, 2023, 9:05 AM

                    @wishmaster270 said in MMM-Fritz-Box-Callmonitor: Notification formatting:

                    @coernel
                    Hi,
                    as i can see this fork https://github.com/drtorchwood/MMM-FRITZ-Box-Callmonitor-py3/tree/code_update_2023 contains all changes needed.
                    But you will need to either use the current development version of MagicMirror or wait for the next release which i think is planned for 2022-04-01 to get the alerts formatted correctly.

                    This is great however I just get this:
                    nocall.jpg
                    Is this the formatting error we are talking about without the Core update? If yes I am willing to wait. But this for me looks like more than a formatting setting!

                    Callmonitor definately is enabled via Fritz!Phone. And username and password are correct - I can access the Fritz!Box and the user has the view and edit settings:

                    Benutzer mit dieser Berechtigung können alle Einstellungen der FRITZ!Box sehen und bearbeiten.

                    Any help would be appreciated!

                    W 1 Reply Last reply Feb 24, 2023, 3:49 PM Reply Quote 0
                    • W Offline
                      wishmaster270 Module Developer @coernel
                      last edited by wishmaster270 Feb 27, 2023, 11:10 AM Feb 24, 2023, 3:49 PM

                      @coernel
                      The view you show indicates that there are no recent calls and that the fetch of the telephone book is still running or was not successful. But it is the normal view. The calls will be signaled as alerts. So make sure you have the default alert module activated in your config.js:

                      		{
                      			module: "alert",
                      		},
                      

                      The formatting will only be wrong in the alert.

                      Please make sure to check the following things, too:

                      • You cloned the right fork with the following command?
                      cd ~/MagicMirror/modules
                      git clone git@github.com:drtorchwood/MMM-FRITZ-Box-Callmonitor-py3.git
                      

                      Edit:
                      * You use the right branch by calling the following commands?
                      As of 2023-02-25 the changes are merged to the master branch of the fork. So no need to change to the code_update_2023 branch anymore.

                      • You installed the JavaScript dependencies?
                      cd ~/MagicMirror/modules/MMM-FRITZ-Box-Callmonitor-py3
                      npm install
                      
                      • You installed the Python dependencies?
                      sudo pip3 install fritzconnection
                      
                      • You activated the call monitor service of the box by dialing the following number with one of your phones?
                      #96*5*
                      
                      • You configured the right IP address in config.js with option fritzIP. Default is 192.168.178.1?
                      		{
                      			module: 'MMM-FRITZ-Box-Callmonitor-py3',
                      			position: 'bottom_left',
                      			header: "Verpasste Anrufe", 
                      			config: {
                      				username: "foo",
                      				password: "bar",
                      				fritzIP: "10.18.8.1",
                      				reloadContactsInterval: 50,
                      				minimumCallLength: 0,
                      				showContactsStatus: true,
                      				maximumCallDistance: 60*6,
                      				maximumCalls: 4,
                      				fade: false,
                      				debug: true,
                      			}
                      		},
                      

                      If the call monitor service is not activated on the fritz box you will see a message like this in the logs:

                      [24.02.2023 16:31.29.944] [ERROR] Error: connect ECONNREFUSED 192.168.178.1:1012
                          at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
                        errno: -111,
                        code: 'ECONNREFUSED',
                        syscall: 'connect',
                        address: '192.168.178.1,
                        port: 1012
                      }
                      

                      And again the call monitor service is independent of username and password. The credentials are used to fetch the telephone book and the past calls only.

                      Thats how the default view looks in my case:
                      fritzcallmonitor.png

                      And thats how it looks if there is a incomming call:
                      fritzcall.png

                      If you do not use the current development branch of MagicMirror there may be some html code in the alert and it will look like <span style='font-size:30px'>Tom</span>

                      fritzcallmonitor_tom.png

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 3
                      • 4
                      • 2 / 4
                      2 / 4
                      • First post
                        19/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