Disable internet connection of specific echo device on fritz box via script
-
Create an access profile for the echo device
1.1 FRITZ!Box Web UI -> Internet -> Filter -> Access Profiles -> New Access Profile
https://service.avm.de/help/en/FRITZ-Box-7590/017p1/hilfe_filter_zugangsprofile -
Map the access profile to the echo device
2.1 FRITZ!Box Web UI -> Internet -> Filter -> Parental Control
https://service.avm.de/help/en/FRITZ-Box-7590/017p1/hilfe_kindersicherung_uebersicht -
Get the access profile id
3.1 Open the web developer tools - network monitor on Firefox (F12 -> Network)
https://developer.mozilla.org/en-US/docs/Tools/Network_Monitor
3.2 Edit the access profile created in step 1
3.4 Select the first POST request with the file data.lua
3.5 Select parameters of the request
3.6 Copy the value of the „edit“ parameter (example filtprof1234) -
Run the attached script with the following parameters
enable internet connection of the echo device ->fritzboxprofile.sh [ip] [password] [profileid] unlimited
disable internet connection of the echo device ->fritzboxprofile.sh [ip] [password] [profileid] never
Example for openHAB
Items
Group:Switch:OR(ON,OFF) echoanaus "Alle Echos" ["Switchable"]
Switch echoesszimmeranaus "Echo Esszimmer" (echoanaus) ["Switchable"]
Rules
rule "echoesszimmeranaus"
when
Item echoesszimmeranaus changed
then
createTimer(now) [|
if (echoesszimmeranaus.state == OFF) {
executeCommandLine("/etc/openhab2/scripts/fritzboxprofile.sh 192.168.178.1 fritzboxpasswort filtprof1234 never", 5000)
} else {
executeCommandLine("/etc/openhab2/scripts/fritzboxprofile.sh 192.168.178.1 fritzboxpasswort filtprof1234 unlimited", 5000)
}
]
end
- Search for the devices in the alexa app
- Say „Alexa, schalte Echo Esszimmer aus“ or „Alexa, schalte Alle Echos aus“
- Add the item to the sitemap to enable an echo device
Script
#!/bin/sh
challenge=$(curl -s "http://$1/login_sid.lua?username=" | grep -Po '(?<=<Challenge>).*?(?=</Challenge>)')
md5=$(echo -n ${challenge}"-"$2 | iconv -f ISO8859-1 -t UTF-16LE | md5sum -b | awk '{print substr($0,1,32)}')
response="${challenge}-${md5}"
sid=$(curl -i -s -k -d "response=${response}&username=" "http://$1" | grep -Po -m 1 '(?<=sid=)[a-f\d]+' | tail -1)
curl -d "sid=${sid}&edit=$3&time=$4&budget=unlimited&apply=&page=kids_profileedit" "http://$1/data.lua" >/dev/null 2>&1
Sources
- https://administrator.de/wissen/informationen-webinterface-fritzbox-shellscript-auslesen-214598.html
- https://www.kuketz-blog.de/fritzbox-wlan-toggle-per-skript/
Only tested with FRITZ!Box 7590
Tested on RaspberryPi