Prometheus Endpoint, written in Python to read FRITZ!Dect devices and export values as prometheus metrics.
Create at least one user account that you can access the FRITZ!Box settings with:
- Click "System" in the FRITZ!Box user interface.
- Click "FRITZ!Box Users" in the "System" menu.
- Click the "Add User" button.
- Enable the option "User account enabled".
- Enter a user name, a valid email address, and a password for the user.
- Enable the option "Access from the internet allowed" if the user may also access the FRITZ!Box over the internet.
- Enable the option "FRITZ!Box settings" under "Rights". You can assign additional rights according to your individual needs.
- Click "OK" to save the settings.
- Click "System" in the FRITZ!Box user interface.
- Click "FRITZ!Box Users" in the "System" menu.
- Click the "Add User" button.
- Enable the option "User account enabled".
- Enter a user name, a valid email address, and a password for the user.
- Enable the option "Access from the internet allowed" if the user may also use the FRITZ!Box services for which he is authorized over the internet.
- Disable the option "FRITZ!Box settings" under "Rights" because otherwise the user can access all of the settings.
- Assign additional rights according to the individual needs of the user.
- Click "OK" to save the settings.
After you have created the users with the desired rights, enable login to the home network with the user accounts:
- Click "System" in the FRITZ!Box user interface
- Click "FRITZ!Box Users" in the "System" menu.
- Click on the "Login to the Home Network" tab.
- Enable the option "Login with FRITZ!Box user name and password".
- Click "Apply" to save the settings.
Have a look at the sourcecode for details. Generally, you'll have to download and import the required python libraries. Refer to the official documentation on how to implement a prometheus exporter: https://github.com/prometheus/client_python.
You'll need to install python (I recommend python3) to prepare your local environment:
$ sudo apt-get update
$ sudo apt-get install python3-pip
$ sudo python3 -m pip install --upgrade pip setuptools wheel
$ sudo pip3 install prometheus_client fritzconnection
$ python3 exporter.py --< args[] >
{'NewDeviceId': 16,
'NewFunctionBitMask': 2944,
'NewFirmwareVersion': '04.16',
'NewManufacturer': 'AVM',
'NewProductName': 'FRITZ!DECT',
'NewDeviceName': 'FRITZ!DECT',
'NewPresent': 'CONNECTED',
'NewMultimeterIsEnabled': 'ENABLED',
'NewMultimeterIsValid': 'VALID',
'NewMultimeterPower': 0, //current power in watts Power value [1/100 W]
'NewMultimeterEnergy': , //Total consumption over the last year in kWh
'NewTemperatureIsEnabled': 'ENABLED',
'NewTemperatureIsValid': 'VALID',
'NewTemperatureCelsius': 200,
'NewTemperatureOffset': 0,
'NewSwitchIsEnabled': 'ENABLED',
'NewSwitchIsValid': 'VALID',
'NewSwitchState': 'OFF', //switch state
'NewSwitchMode': 'MANUAL',
'NewSwitchLock': False,
'NewHkrIsEnabled': 'DISABLED',
'NewHkrIsValid': 'INVALID',
'NewHkrIsTemperature': 0,
'NewHkrSetVentilStatus': 'CLOSED',
'NewHkrSetTemperature': 0,
'NewHkrReduceVentilStatus': 'CLOSED',
'NewHkrReduceTemperature': 0,
'NewHkrComfortVentilStatus': 'CLOSED',
'NewHkrComfortTemperature': 0
}
I've used hypriot os with a RaspberryPi 3B+. It works on a Raspberry Pi 2 too, although docker builds might take some time, so be calm to your Pi.
usage: exporter.py [-h] [-n NODE] [-p PORT] [-i INTERVAL] [-a AIN]
[-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}] [-w PASSWORD]
[-f ADDRESS] [-u USER]
Prometheus Fritz!DECT exporter
optional arguments:
-h, --help show this help message and exit
-n NODE, --node NODE The node, the exporter runs on
-p PORT, --port PORT The port, the exporter runs on
-i INTERVAL, --interval INTERVAL
The sleep interval of the exporter
-a AIN, --ain AIN The Aktor Identifikationsnummer (AIN) which identifies
the device
-l {DEBUG,INFO,WARNING,ERROR,CRITICAL}, --loglevel {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Set the logging level
-w PASSWORD, --password PASSWORD
The password to authenticate the FRITZ!Box
-f ADDRESS, --address ADDRESS
The address of the FRITZ!Box
-u USER, --user USER The user to authenticate the FRITZ!Box
You can run the exporter either via python itself or in a docker container. The required commands for running it via python are also in the supplied Makefile. For docker use:
t.b.d
or refer to the supplied Makefile.
You can also download it from docker hub via docker pull lukasbahr/...
- ✔️ Add CI/CD Support
- ❌ Add unit tests
- ❌ use buildx to create the proper image
- ❌ Add health metric, error metric, scrape interval, general information about exporter etc.