Reading the temperature from FRITZ!DECT devices

If you own a FRITZ!Box router from the German company AVM that has an integrated DECT base station, you are able to connect devices from their FRITZ!DECT accessory line, like switchable power outlets and radiator controller via DECT.

The FRITZ!DECT 200, 210 and 300 are also equipped with a temperature sensor. With a recent firmware for the FRITZ!Box router, AVM now shows you a temperature diagram for the past 24 hours. Unfortunately, it only seems to be for informational purposes and it is not possible to download the temperature data from the router. Also, the data will be lost after you restart your router.


But what is not very well-known is that AVM provides access to the connected devices via their own Home Automation HTTP Interface. Once, you are logging in to the FRITZ!Box, using a Session-ID, you are able to use the mentioned HTTP interface. By using this interface, you are not only able to read the temperature from the FRITZ!DECT devices, you are also able to read a variety of other information and you are able to turn the power of the power outlets on and off and to control the temperature of the radiation controller. So, actually you could design your own personal Home Automation System, using the interface on your Raspberry Pi if you want. Since I am using the MyFRITZ!App provided by AVM to control the devices, I am mainly interested to only read the temperature. With the following Bash script, it is very easy to periodically read out the temperature from a connected FRITZ!DECT device. You just have to fill in the password of your FRITZ!Box and the unique AIN of your device, which is shown in the ‘Smart Home’ menue of the FRITZ!Box.

# -----------
# definitions
# -----------
# ---------------
# fetch challenge
# ---------------
CHALLENGE=$(curl -s "${FBF}/login_sid.lua" | grep -Po '(?<=<Challenge>).*(?=</Challenge>)')
# -----
# login
# -----
MD5=$(echo -n ${CHALLENGE}"-"${PASS} | iconv -f ISO8859-1 -t UTF-16LE | md5sum -b | awk '{print substr($0,1,32)}')
SID=$(curl -i -s -k -d "response=${RESPONSE}&username=${USER}" "${FBF}" | grep -Po -m 1 '(?<=sid=)[a-f\d]+')
# -----------------
# fetch temperature
# -----------------
TEMPINT=$(curl -s ${FBF}'/webservices/homeautoswitch.lua?ain='${AIN}'&switchcmd=gettemperature&sid='${SID})
TEMPFLOAT=$(echo $TEMPINT | sed 's/\B[0-9]\{1\}\>/,&/')
# ------------------
# output temperature
# ------------------

It is also relatively easy to call the script within a python script. Supposed, you have saved the bash script under the name ‘’, you can use the following python code as a wrapper which you can include in your own scripts.


import sys
import os

# read the temperature from the fritz device
process = os.popen('sudo ./')
str =

if not str:

str = str.replace(',','.')
str = str.replace('\n','')

print str

I use the code shown here to read the temperature from one of my FRITZ!DECT200 devices on the lower floor of my apartment, store it in a RRDtool database and generate a graph, together with the temperature on the upper floor which is measured by a Bosch BMP180 pressure sensor.


You can easily see that the trend of the graph is exactly the same like it is in the diagram showed by the FRITZ!Box router itself.