[SOLVED] Is it possiple to call a number using fritzbox binding

i am working with openHab since a few weeks and have it connected with my RWE Smarthome.
Now i got the idea if too many windows are too long opened during winter i want to get informed.
the informations via email are working very well but i also would like to get a phonecall about
the situation. Is this possible ???

Continuing the discussion from Making a phone call with OpenHab?:

Thanks, yes its similar, but what i want to do is make a call from my fritzbox and this is normaly very easy.
Let me show in VB.net:
Dim doc As String = “http://fritz.box/fon_num/dial_foncalls.lua?sid=” & gSid & “&dial=” & nr & "&xhr=1"
Dim request As HttpWebRequest = CType(WebRequest.Create(doc), HttpWebRequest)
Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
with this 3 lines i can call any number, but i need the fritzbox logon SID and this is my question
Can i get the SID from the fritzbox binding???

ok, i could fix it on my own translating my vb.net to Python and now it runs well

Maybe you could share it?

No Problem i hope its ok to post the code here in Reply:

import re,hashlib,requests,sys
host = '’
pw = 'xxxxxxx’
SSID = 'wlan-ssid’
url = ‘http://’+host
headers = {
‘Host’: host,
‘User-Agent’: ‘Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0’,
‘Accept’: ‘text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8’,
‘Accept-Language’: ‘de,en-US;q=0.7,en;q=0.3’,
‘Content-Type’: ‘application/x-www-form-urlencoded; charset=UTF-8’,
‘Referer’: ‘’,
‘Connection’: ‘keep-alive’,
‘Pragma’: ‘no-cache’,
‘Cache-Control’: ‘no-cache’,
commandarg = sys.argv[1]
except Exception as ce:
commandarg = ‘-Stat’

def login():
r = requests.get(url + “/login_sid.lua”)
challengereg = re.search(r’(.)</\Challenge>’, r.text, re.M|re.I).group(1)
challengestr = challengereg+"-"+pw
responsehash = hashlib.md5(challengestr.encode(‘utf-16le’)).hexdigest()
response = challengereg+"-"+responsehash
data = {‘response’ : response,‘page’: ‘’,‘username’ : ‘’}
rp = requests.post(url+’/login_sid.lua’,headers=headers, data=data)
sidreg = re.search(r’(.
)’, rp.text, re.M|re.I).group(1)
except Exception as e:

def status():
r = requests.get(url + “/wlan/wlan_settings.lua?sid=”+sid)
if ‘name=“active” checked> WLAN-Funknetz aktiv’ in r.text:
print(“W-Lan an!”)
elif ‘name=“active” > WLAN-Funknetz aktiv’ in r.text:
print(“W-Lan aus!”)
requests.get(url + “/login_sid.lua?logout=&sid=+”+sid)

def call(inputvar):
requests.get(url + “/fon_num/dial_foncalls.lua?sid=”+sid+"&dial="+inputvar+"&xhr=1")
requests.get(url + “/login_sid.lua?logout=&sid=+”+sid)

def useron():
r = requests.get(url + “/net/network_user_devices.lua?sid=”+login())
userreg = re.findall(r’(?m)[“name”]\s=\s"([^"]+?)",[^[]+?[“online”]\s=\s"1",’, r.text)

def main():
if commandarg == “-Call”:
elif commandarg == “-Stat”:
elif commandarg == “-User”:

The syntax is:
python FritzI.py -Stat ==> the actual WLAN Status
python Fritz.py -User ==> shows all ‘online’ devices
python Frits.py -Call phonenumber ==> calls the given phonenumber

inside openhab i call it in a rule using
executeCommandLine("I:/WinPython-32bit- FritzI.py " + “-Call 08xxxxxx”)

Have fun