1
0
Fork
You've already forked FritzBox-Call-Monitor
0
A lightweight bash script that monitors incoming calls on your AVM Fritz!Box and triggers desktop notifications or IoT devices in real time — no cloud, no external services, no frills.
  • Shell 100%
Rorschach2 441025f421 README.md aktualisiert
Signed-off-by: Rorschach2 <rorschach2@noreply.codeberg.org>
2026年07月12日 08:37:33 +02:00
screenshots Screeshot of gdbus notification 2026年06月20日 09:12:32 +02:00
.gitignore Dateien nach „/" hochladen 2026年05月22日 23:26:01 +02:00
fritzbox-callmonitor-iot Remove unnecessary check for 'curl' 2026年06月16日 21:36:50 +02:00
fritzbox-callmonitor-session fritzbox-callmonitor-session aktualisiert 2026年06月17日 16:27:43 +02:00
fritzbox-callmonitor-systemd-service bugs fixed 2026年06月17日 16:30:31 +02:00
fritzbox-callmonitor-user-service bugs fixed 2026年06月17日 16:33:03 +02:00
install.bash install.bash aktualisiert 2026年07月03日 22:07:04 +02:00
LICENSE Initial commit 2026年05月22日 23:24:27 +02:00
README.md README.md aktualisiert 2026年07月12日 08:37:33 +02:00

FRITZ!Box Call Monitor

A lightweight bash script that monitors incoming calls on your AVM FRITZ!Box and triggers desktop notifications or IoT devices in real time — no cloud, no external services, no frills.

Inspired by this article on gnulinux.ch, which focused on triggering an LED bar. This project extends that idea with desktop notifications, SSH-based remote triggering, IoT device support, and a proper installer.


Features

  • Desktop notifications via gdbus
  • Caller name display in the notification body (optional; FRITZ!Box phonebook must be imported)
  • Caller number display in the notification body
  • Called number display in the notification body
  • Missed Call notifications stay visible until dismissed, even in do-not-disturb mode
  • SSH-based remote triggering — run the monitor on a Raspberry Pi or server and send notifications to your desktop
  • IoT device support — trigger any HTTP-controllable device (LED bars, Shelly relays, Tasmota devices, etc.)
  • Systemd integration — runs as a system or user service, starts automatically at boot
  • Interactive installer with a TUI — guides you through the entire setup
  • Testing — Can be launched directly (temporarily, session only - foreground/background) from the installer for testing purposes
  • Unistall Routines — services can be removed from within the install script
  • Self-contained — no external dependencies beyond standard Linux tools
  • Phonebook support - FRITZ!Box phonebook can be imported; alternatively, a phonebook can be created manually.

How It Works

The AVM FRITZ!Box provides a call monitor on port 1012 that streams call events in real time over a plain TCP connection. The script connects to this port using netcat and reacts to incoming (RING) and disconnected (DISCONNECT) events.

Depending on the installation type, it either:

  • Sends a desktop notification directly via gdbus (local installation)
  • SSHs into a remote desktop and triggers gdbus there (over LAN)
  • Sends an HTTP request to an IoT device (over LAN)

Prerequisites

  • AVM FRITZ!Box (any model with call monitor support)
  • Linux with bash
  • The following tools must be available: awk, cut, curl (for the IoT branch only), grep, ip, nc, gdbus, iproute2/iproute, python3 (optional; for phonebook import)
  • For remote/Pi installations: ssh, ssh-keygen, ssh-copy-id
  • For systemd service installations: systemd
  • Mandatory on remote host: sshd (openssh / openssh-server package), gdbus (glib2/glib2.0-bin/glib-2 package)

In the installer menu, you can press the d key (for dependencies) to see what your system requires. However, checks for the necessary tools are performed automatically during the installation process anyway.

The installer offers the option to install missing tools directly during the setup process, eliminating the need for a restart if anything is missing. This applies to Arch (pacman), Debian/Ubuntu (apt-get), Fedora (dnf), FreeBSD (pkg), and openSUSE/Tumbleweed (zypper). Other package managers are not currently supported; if an unknown package manager is used and one or more of the required programs are unavailable, the installation will be aborted. FRITZ!Box Call Monitor relies on these programs and would simply not function without them.

The installer also checks whether an SSH connection to the remote host can be established and whether gdbus is available there. The package required for sshd might not be installed by default, preventing the SSH connection from being established; however, the installation can still proceed. To use the tool, openssh/openssh-server (for sshd) and glib2/glib2.0-bin/glib-2 (for gdbus) must be installed on the remote host. Otherwise, no notification will be displayed, even if the FRITZ!Box Call Monitor is running.

Preparation for using the FRITZ!Box phonebook

Export the FRITZ!Box phonebook from your FRITZ!Box:

  1. In the FRITZ!Box user interface, click "Telefonie". You can access the user interface either via http://fritz.box or via the local IP address of the FRITZ!Box (http://192.168.178.1 in the factory settings).
  2. In the "Telefonie" menu, click "Telefonbuch".
  3. Select a phone book, click the "Backup" button, and save the phone book as an XML file on your computer.

Important: If the file download is blocked by your browser, click "Keep" in Microsoft Edge or "Keep" in Chrome.

By default, the installer looks for the file ~/.config/fritzbox-callmonitor/phonebook.xml. However, if desired, you will be prompted to specify a different path and filename, but I recommend to save it as ~/.config/fritzbox-callmonitor/phonebook.xml. It makes the installation process a bit more convenient.

During the installation process, the phonebook is converted into plain text and saved at ~/.config/fritzbox-callmonitor/phonebook.conf. This step can also be performed after the installation has been completed. To this end, the installer provides a menu entry that allows you to convert the phonebook without having to go through the entire installation process again.

It is also possible to manually create a phonebook and save it at ~/.config/fritzbox-callmonitor/phonebook.conf. An existing phonebook can be easily edited. The entries should follow this format:

015112345678=John (mobile)
03012345678=Mary Jane (home)
03087654321=Boss (work)

Activating the FRITZ!Box Call Monitor

The call monitor on port 1012 is disabled by default and must be activated manually. If you run the installer without having port 1012 enabled, the installer will display a guide how to enable the port and exits.

Method 1: Using a connected phone Dial #96*5* from any phone registered to the FRITZ!Box. You may hear the message "The number you've dialed is not assigned" — this is normal. The call monitor is activated regardless.

Method 2: Using the FRITZ!Box phonebook

  1. Open the FRITZ!Box web interface
  2. Go to Telefonie → Telefonbuch
  3. Create a new entry named e.g. Activate Monitoring with the number #96*5*
  4. Enable the dialing aid under Telefonie
  5. Dial the entry using the dialing aid

To deactivate the call monitor, dial #96*4* using either method.

You can verify the call monitor is active with:

nc -zv 192.168.178.1 1012

If the connection succeeds, the call monitor is running.

Connection to 192.168.178.1 1012 port [tcp/*] succeeded!

Note: The FRITZ!Box call monitor requires no authentication and transmits data unencrypted. It is only accessible within your local network.


Installation

Make the installer executable and run it:

chmod +x install.bash
./install.bash

Installation process

  1. Check that all required tools are available
  2. Verify that the FRITZ!Box call monitor is active on port 1012
  3. Check for an existing installation and ask before overwriting (values ​​from the existing configuration are adopted by the installer and can be adjusted if necessary)
  4. Guide you through configuration via interactive input boxes (incl. optional phonebook import)
  5. When installing as a systemd service for remote notifications: Check whether gdbus is available on the remote host (a warning is issued if no SSH connection exists or gdbus is not found; the user can proceed or cancel if necessary).
  6. Write a config file and generate the appropriate systemd service file
  7. Set up SSH keys if needed (for remote installations)
  8. Enable and start the service

The installation program offers the option to convert the phonebook from XML to plain text (Option 10) without having to go through the entire installation process again.

Installation Types

Option Description
Remote (system service) Run on a Raspberry Pi or server; sends desktop notifications via SSH
Local (user service) Run directly on your desktop machine; triggers gdbus locally
IoT device Trigger an HTTP-controllable device on incoming calls
Background Run detached from the terminal for this session only
Foreground Run in the terminal for testing purposes

Configuration

The installer writes a config file to /etc/fritzbox-callmonitor.conf (system service) or ~/.config/fritzbox-callmonitor.conf (user service):

Variable="Value" Description
fritzbox="192.168.178.1" Typically, the FRITZ!Box IP address is automatically detected during the installation process based on the default gateway. However, this only works as long as no VPN connection or similar service has established a different default route. If none is shown, set it manually.
usr="youruser" Username on the desktop machine (mandatory for remote only)
output_device_ip="192.168.178.x" Desktop or IoT device IP (mandatory for displaying notifications on a remote desktop and for IoT device service)
callmonitor_port="1012" FRITZ!Box call monitor port (hard coded)
monitored_number="your_own_number" You will be prompted to enter the number during installation. However, this is optional.
PHONEBOOK_PATH=/"${HOME}"/.config/fritzbox-callmonitor/phonebook.conf Path to the phonebook (Do not change! or it might not work). The phonebook must live on the same machine where the service is running (not on a remote machine).

File Overview

File Description
install.sh Interactive installer
fritzbox-callmonitor-session Self-contained script for background/foreground use
fritzbox-callmonitor-systemd-service Script for remote system service (Pi/server)
fritzbox-callmonitor-user-service Script for local user service
fritzbox-callmonitor-iot Script for IoT device triggering

The following files will be generated during the installation process and then copied as 'fritzbox-callmonitor' to its appropriate directory:

File Description
System Service Notification on a remote host
/etc/fritzbox-callmonitor-s.conf Systemd system service config file
/etc/systemd/system/fritzbox-callmonitor-s.service systemd service file
/usr/local/bin/fritzbox-callmonitor-s executable service file generated by using systemd service unit template fritzbox-callmonitor-systemd-service
id_ed25519 This file will be generated on the host and it contains the private ssh key
id_ed25519.pub This file will also be generated on the host and it contains the puplic ssh key, which is also copied to the remote desktop using ssh-copy-id
${HOME}/.ssh/config config file for ssh connection, stores the ControlMaster options (only for remote desktop); if the file exists the new content will be appended
generated at runtime
${HOME}/.ssh/cm-{usr}@{remote-ip}:22 ControlMaster file: saved authentication information on a per-(user, host) basis, which lets you share one connection among multiple ssh/scp/rsync commands. This file is created, when an incoming call is detected; it is temporary and will disappear after 60 seconds.
User Service Notification on a local host
$HOME/.config/fritzbox-callmonitor-u.conf Systemd system service config file (system service)
$HOME/.config/systemd/user/fritzbox-callmonitor-u.service systemd service file (user service)
/usr/local/bin/fritzbox-callmonitor-u executable service file generated by using systemd service unit template fritzbox-callmonitor-user-service
IoT Service Trigger a WLED device or another IoT device (using curl)
/etc/fritzbox-callmonitor-i.conf Systemd system service config file
/etc/systemd/system/fritzbox-callmonitor-i.service systemd service file
/usr/local/bin/fritzbox-callmonitor-i executable service file generated by using systemd service unit template fritzbox-callmonitor-iot
Note:
A reinstallation overwrites the already installed service as well as the configuration file. If you wish to change the installation from a user service to a system service (and vice versa), I strongly recommend that you first uninstall the previous installation. This can be done directly via the installer. Furthermore, after reinstalling the service, you should check the ${HOME}/.ssh/config file for duplicate entries.

SSH Key Setup (Remote Installation)

For remote installations the installer automatically:

  1. Generates an SSH key pair for the service user if none exists
  2. Copies the public key to the desktop machine via ssh-copy-id

The key is generated without a passphrase so the service can connect unattended. To keep the setup secure:

  • The desktop machine should only accept SSH connections from the Pi's or server's local IP

  • Add the public ssh key on the remote host to:

    ~/.ssh/authorized_keys
    
  • Generates ControlMaster file ${HOME}/.ssh/config with saved authentication information on a per-(user, host) basis, which lets you share one connection among multiple ssh/scp/rsync commands. The file content will be:

    Host 192.168.178.XXX
     		User username
     		ControlMaster auto
     		ControlPath ~/.ssh/cm-%r@%h:%p
     		ControlPersist 60s
    
SSH Key vs. ControlMaster: What each of the two mechanisms solves
SSH keys replace password authentication. Without a key, every SSH connection would require an interactive password prompt - which is impossible for an unattended service. Thus, the key solves the authentication problem.
ControlMaster solves a different problem: even with a key, every new SSH connection incurs a cost of ~200–500 ms for the TCP handshake and key exchange (Diffie-Hellman). ControlMaster keeps a master socket open and allows subsequent connections to reuse it (in our use case: in the event of multiple incoming calls), reducing latency to ~10–30 ms. It therefore solves the connection setup problem.

Uninstalling

The installer includes an uninstall option in its menu:

  • Option 7 — Remove system service
  • Option 8 — Remove user service
  • Option 9 — Remove IoT services

This stops and disables the service, removes the service file, the executable, and the config file, and reloads the systemd daemon. Any imported phonebook must be deleted manually (~/.config/fritzbox-callmonitor/phonebook.conf).


Non-systemd Systems

On systems without systemd (e.g., Void Linux with runit), the installer automatically detects the absence of systemctl and limits the menu to options for background and foreground operation, as well as phonebook conversion. Service installation options are hidden.


Desktop Notification Details

Notifications are sent via gdbus using the freedesktop.org Notifications specification. No additional tools like notify-send or zenity are required.

  • Caller name is displayed in the notification body when available (see section Prerequisites)
  • Caller number is displayed in the notification body
  • Called number is displayed in the notification body

Example notification:

Incoming call

  • Timeout set to 10000 ms the blue line represents the timer; notification auto-dismisses after 10 seconds

Screenshot Incoming Call

In case a call was missed

  • Timeout set to 0 notification never auto-dismisses when a call is missed

Screenshot Missed Call

Connect and Answered events are skipped (since you should know whether you have conducted a phone call).


Compatibility

Tested on:

  • Raspberry Pi OS (Debian-based)
  • Arch (Cachy OS)
  • Further distributions to be confirmed
    • The installer detects whether it is running on Arch, Ubuntu/Debian, Fedora, openSUSE/Tumbleweed, or FreeBSD by checking for the corresponding package manager, and then offers the appropriate installation routine for missing tools or packages for that specific system. On systems without systemd, a simplified menu is displayed that allows the Fritz!Box Call Monitor to be launched from the terminal; installation as a system service is not possible in this case, for obvious reasons.

The FRITZ!Box call monitor is available on all FRITZ!Box models. International versions are supported — the call monitor protocol is identical regardless of region.


Roadmap

  • Optional use of an existing configuration for a reinstallation
  • Optional use of a phone book to display the callers name
  • Replace Whiptail dialogs (they are ugly as hell) with ASCII-based dialogs
  • Colorize the ASCII-based dialogs
  • other fancy things

Credits & Inspiration


License

MIT License — just don't blame me if your smart fridge starts ringing.