Skip to main content

Communicate with the AVM FritzBox

Project description

Python versions https://img.shields.io/pypi/l/fritzconnection.svg

Python-Tool to communicate with the AVM FritzBox. Uses the TR-064 protocol.

Installation:

pip install fritzconnection

Dependencies

fritzconnection requires the python modules lxml and requests:

pip install lxml requests

Available Modules, Commands and Tools

fritzconnection.py makes the SOAP interface of the FRITZ!Box available on the command line. Shows all available services and actions when run with the argument -c. Use -h for help.

This is the main module and works standalone. The other modules listet here are utility modules for convenience and examples on how to use fritzconnection.

fritzstatus.py is a command line interface to display status information of the FRITZ!Box. It also serves as an example on how to use the fritzconnection module.

fritzmonitor.py is a Tkinter GUI to display current IP as well as the upstream and downstream rates. It also makes it easy to reconnect and thus get a different IP from your ISP.

fritzhosts.py is a command line interface to display the hosts known by the FRITZ!Box with IP, name, MAC and status.

fritzwlan.py Utility module for FritzConnection to list the known WLAN connections.

fritzcallforwarding.py Utility module for FritzConnection to manage callforwardings.

fritzphonebook.py Utility module for FritzConnection to access phone books.

fritzcall.py Gives access to recent phone calls: incoming, outgoing and missed ones.

Other Files

fritztools.py contains some helper functions and test.py contains unit tests.

Quickstart:

Inspect the API:

>>> import fritzconnection as fc
>>> fc.print_api(address=<ip-address>, password=<the password>)

Both parameters address and password are optional. If there is more than one Fritz!Box in the network, an address must be provided, because otherwise it’s undefined which box will respond. Also most services are only accessible by providing a password.

An API-Call is made by the call_action-method of the FritzConnection-Class. This method takes the servicename, the actionname and optional arguments as parameter and may return a dictionary with the results (as described in the TR-064 protocoll description). A simple example is to reconnect for a new external ip:

>>> from fritzconnection import FritzConnection
>>> connection = FritzConnection()
>>> connection.call_action('WANIPConn', 'ForceTermination')
# or more comfortable:
>>> connection.reconnect()

The latter wrapps the call_action-method. For a more complete example look at the fritzhosts.py souce-code.

Changed with version 0.8.5:

  • lxml-dependency updated from 4.3.4 to 4.5.1 to work with some newer linux-versions.

Changed with version 0.8.4:

  • bugfix in connection.reconnect(). This bug has been introduced with version 0.8. For versions 0.8 to 0.8.3 ‘reconnect’ requires a password because of a changed service call.

  • documentation updated.

Changed with version 0.8.3:

  • bugfix in tests (new in 0.8.0)

  • code cleanup in fritzconnection

Changed with version 0.8.2:

  • unified version numbering of the modules.

  • ServiceError, ActionError and AuthorizationError are also importable from the package.

  • some code cleanup.

Changes in the development process: .hgignore removed and .gitignore added, changes in setup.py, readme changed to restructured text.

As Atlassian has announced to drop support for mercurial on bitbucket und will remove the according repositories (in June 2020), development of fritzconnection has converted from hg to git and the repository has been transfered to github. Unfortunately the issue- and discussion-history will be lost this way (even by keeping the new git-repository at bitbucket).

Changed with version 0.8.1:

FritzStatus: bugfix requiring a password in combination with fritzconnection >= 0.8.0

FritzStatus: added the external_ipv6 attribute

FritzStatus: added the max_linked_bit_rate attribute for the physical rate. Also added the str_max_linked_bit_rate attribute for a more readable output. (password must be provided for these infomations)

FritzConnection: added the AuthorizationError exception.

Changed with version 0.8.0:

bugfix how servicenames are extracted from the xml-description files. However, the api has not changed.

The requirements are now fixed for lxml (4.3.4) and requests (2.22.0) as these versions are still supporting python 2.7

Changed with version 0.7.1 - 0.7.3:

bugfixes, no new features or other changes.

Changed with version 0.7.0:

FritzConnection does now check for the environment variables FRITZ_USER and FRITZ_PASSWORD in case that neither user nor password are given.

FritzStatus now accepts user and password as keyword-parameters. Keep in mind, that FritzBoxes may return different informations about the status depending whether these are gathered with or without a password.

Changed with version 0.6.5:

There is a new attribute package_version:

>>> import fritzconnection
>>> fritzconnection.package_version
0.6.5

Because every module of the fritzconnection-package has it’s own version, version-history of the package gets confusing over time. From now on every change of the content of the package is indicated by the the package-version. Every unchanged module keeps it’s version. So i.e. the recent package-version is 0.6.5 but the fritzconnection-module is still in version 0.6 cause nothing has changed in this module since then.

Changed with version 0.6:

FritzConnection now uses long qualified names as servicename, i.e. WLANConfiguration:1 or WLANConfiguration:2. So these servicenames can now be used to call actions on different services with the same name:

>>> connection = FritzConnection()
>>> info = connection.call_action('WANIPConnection:2', 'GetInfo')

For backward compatibility servicename-extensions like ‘:2’ can be omitted on calling ‘call_action’. In this case FritzConnection will use the extension ‘:1’ as default.

On calling unknown services or actions in both cases KeyErrors has been raised. Calling an unknown service (or one unaccessible without a password) will now raise a ServiceError. Calling an invalid action on a service will raise an ActionError. Both Exceptions are Subclasses from the new FritzConnectionException. The Exception classes can get imported from fritzconnection:

>>> from fritzconnection import ServiceError, ActionError

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fritzconnection-0.8.5.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

fritzconnection-0.8.5-py3-none-any.whl (72.0 kB view details)

Uploaded Python 3

File details

Details for the file fritzconnection-0.8.5.tar.gz.

File metadata

  • Download URL: fritzconnection-0.8.5.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for fritzconnection-0.8.5.tar.gz
Algorithm Hash digest
SHA256 9d51569abc63f910b2cc530861ed3e1957522df45bd61b5430b6cff87d48a87b
MD5 a7ba36999ca38a156fc21dbfc565fd9a
BLAKE2b-256 68d3ec3108265ee11dca093b7b2a631ed343451812d5a1ff2f5340466e5d4d6c

See more details on using hashes here.

Provenance

File details

Details for the file fritzconnection-0.8.5-py3-none-any.whl.

File metadata

  • Download URL: fritzconnection-0.8.5-py3-none-any.whl
  • Upload date:
  • Size: 72.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for fritzconnection-0.8.5-py3-none-any.whl
Algorithm Hash digest
SHA256 155084cb9b5c8a005661ce037584302383618b6323a558056c7c247adda363ab
MD5 cd538ef60c265f7c453a1654e7cd0123
BLAKE2b-256 0edcea499f61d160efe6f33bcbc3d7b21e937a91e22a57f098b6eda9b680a8f6

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page