kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
304 stars 59 forks source link

Get internal numbers of phone devices aka "Telefonie - Telefoniegeraete" [Enhancement] #80

Open bufemc opened 3 years ago

bufemc commented 3 years ago

I am currently trying to get the internal numbers of all "Telefonie - Telefoniegeraete" in the Fritzbox UI.. any ideas? I searched the documentation but could only find how to get e.g. Wifi devices and their mac uids. If this is missing in the current implementation I would like to propose it for an enhancement.

What: Phone devices connected to the Fritzbox, their internal number and their assigned phone number. E.g.:

Examples:

internal: **1
seen from outside: 79364
device type: FON 1 (aka fax device, connected to fon 1)

internal: **610
seen from outside: 84646
device type: DECT

These are the columns on top: image

Values seen so far in my case for device, but there could be much more:

If it's not planned to integrate this, or you just know how to do it, any hint would be nice!

bufemc commented 3 years ago

Okay, I maybe re-invented the wheel.. what you have to do seems to be this:

First retrieve the list: ('X_AVM-DE_OnTel:1', 'GetDECTHandsetList')

Then, for each retrieve the entry, e.g. for 1: ('X_AVM-DE_OnTel:1', 'GetDECTHandsetInfo', arguments={'NewDectId': 1})

Returns e.g. {'NewHandsetName': 'I1 84646', 'NewPhonebookID': 0}

Then maybe split by space, and take the 2nd, so "84646", plus maybe add the regional prefix before..

Quick & dirty code snippet:

        res = self.fc.call_action('X_AVM-DE_OnTel:1', 'GetDECTHandsetList')
        ids = res['NewDectIDList'].split(',')
        for id in ids:
            res = self.fc.call_action('X_AVM-DE_OnTel:1', 'GetDECTHandsetInfo', arguments={'NewDectId': id})
            print(res['NewHandsetName'])

REMARK: this is not the optimum yet. It misses the fax device connected to "fon 1" and phone numbers not assigned to handsets (I have 2 more phone numbers, which are currently not used). Maybe those could be retrieved by "deflections"? See https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/X_contactSCPD.pdf

NOTE: Other possibility could be to use: https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/x_voip-avm.pdf and from that 2.22 X_AVM-DE_GetClient

Update: seems to be a better way:

fc.call_action('X_VoIP:1', 'X_AVM-DE_GetNumbers')

But: you have to parse the returned XML..