Skip to content

Commit

Permalink
Keylock access added
Browse files Browse the repository at this point in the history
Fixes #12
Possibility added to activate or deactivate the keylock (Buttons on top of the Fritz!Box can be activated or deactivated.
  • Loading branch information
jhubig committed Apr 24, 2020
1 parent a446b7d commit 757554f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
The script allows you to control/check your FritzBox from the terminal with a shell script. It is planned to add more functions in the future.
The shell script uses cURL to create an SOAP request based on the TR-064 protocol to talk to the AVM Fritz!Box and AVM Fritz!Repeater.

To change state of the LEDs in front of the Fritz!Box the TR-064 protocol does not offer the possibility. Therefore the AHA-HTTP-Interface is used. This only works from firmware version `7.10` and upwards.
To change state of the LEDs in front of the Fritz!Box or activate the keylock (buttons on the can be activated or deactivated) the TR-064 protocol does not offer the possibility. Therefore the AHA-HTTP-Interface is used. This only works from firmware version `7.10` and upwards.

Please raise an issue with your function you would like to add.

Expand Down Expand Up @@ -92,6 +92,8 @@ After the successful installation and setup following functions should be availa
| TAM | <index> and ON or OFF | e.g. TAM 0 ON (switches ON the answering machine) |
| TAM | <index> and GetMsgs | e.g. TAM 0 GetMsgs (gives XML formatted list of messages) |
| LED | 0 or 1 | Switching ON (1) or OFF (0) the LEDs in front of the Fritz!Box |
| LED | 0 or 1 | Switching ON (1) or OFF (0) the LEDs in front of the Fritz!Box |
| KEYLOCK | 0 or 1 | Activate (1) or deactivate (0) the Keylock (buttons de- or activated) |
| LAN | STATE | Statistics for the LAN easily digestible by telegraf |
| DSL | STATE | Statistics for the DSL easily digestible by telegraf |
| WAN | STATE | Statistics for the WAN easily digestible by telegraf |
Expand All @@ -118,3 +120,5 @@ Here you can find more information on TR-064 protocol and the available actions
* http://fritz.repeater:49000/tr64desc.xml
* https://wiki.fhem.de/wiki/FRITZBOX#TR-064
* https://avm.de/service/schnittstellen/

AVM, FRITZ!, Fritz!Box and the FRITZ! logo are registered trademarks of AVM GmbH - https://avm.de/
31 changes: 26 additions & 5 deletions fritzBoxShell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
# https://wiki.fhem.de/wiki/FRITZBOX#TR-064
# https://avm.de/service/schnittstellen/

version=1.0.3
# AVM, FRITZ!, Fritz!Box and the FRITZ! logo are registered trademarks of AVM GmbH - https://avm.de/


version=1.0.4

dir=$(dirname "$0")

Expand Down Expand Up @@ -104,12 +107,9 @@ getSID(){
### ----------------------------------------------------------------------------------------------------- ###

LEDswitch(){
# Collect the challenge
# Get the a valid SID
getSID

# If no valid SID is received, then IP or web password is probably not correct
if [ "$SID" = "" ]; then echo "No valid login. Wrong IP or web password?";return 1; fi

if [ "$option2" = "0" ]; then LEDstate=2; fi # When
if [ "$option2" = "1" ]; then LEDstate=0; fi

Expand All @@ -124,6 +124,24 @@ LEDswitch(){
wget -O - "http://$BoxIP/home/home.lua?sid=$SID&logout=1" &>/dev/null
}

### ----------------------------------------------------------------------------------------------------- ###
### --------- FUNCTION keyLockSwitch FOR ACTIVATING or DEACTIVATING the buttons on the Fritz!Box -------- ###
### ----------------------------- Here the TR-064 protocol cannot be used. ------------------------------ ###
### ----------------------------------------------------------------------------------------------------- ###
### ---------------------------------------- AHA-HTTP-Interface ----------------------------------------- ###
### ----------------------------------------------------------------------------------------------------- ###

keyLockSwitch(){
# Get the a valid SID
getSID
wget -O - --post-data sid=$SID\&keylock_enabled=$option2\&apply= http://$BoxIP/system/keylocker.lua 2>/dev/null
if [ "$option2" = "0" ]; then echo "KeyLock NOT active"; fi
if [ "$option2" = "1" ]; then echo "KeyLock active"; fi

# Logout the "used" SID
wget -O - "http://$BoxIP/home/home.lua?sid=$SID&logout=1" &>/dev/null
}

### ----------------------------------------------------------------------------------------------------- ###
### -------------------------------- FUNCTION readout - TR-064 Protocol --------------------------------- ###
### -- General function for sending the SOAP request via TR-064 Protocol - called from other functions -- ###
Expand Down Expand Up @@ -519,6 +537,7 @@ DisplayArguments() {
echo "| TAM | <index> and GetMsgs | e.g. TAM 0 GetMsgs (gives XML formatted list of messages) |"
echo "|--------------|------------------------|-------------------------------------------------------------------------|"
echo "| LED | 0 or 1 | Switching ON (1) or OFF (0) the LEDs in front of the Fritz!Box |"
echo "| KEYLOCK | 0 or 1 | Activate (1) or deactivate (0) the Keylock (buttons de- or activated) |"
echo "|--------------|------------------------|-------------------------------------------------------------------------|"
echo "| LAN | STATE | Statistics for the LAN easily digestible by telegraf |"
echo "| DSL | STATE | Statistics for the DSL easily digestible by telegraf |"
Expand Down Expand Up @@ -596,6 +615,8 @@ else
Deviceinfo "$option2";
elif [ "$option1" = "LED" ]; then
LEDswitch "$option2";
elif [ "$option1" = "KEYLOCK" ]; then
keyLockSwitch "$option2";
elif [ "$option1" = "TAM" ]; then
if [[ $option2 =~ ^[+-]?[0-9]+$ ]] && { [ "$option3" = "GetInfo" ] || [ "$option3" = "ON" ] || [ "$option3" = "OFF" ] || [ "$option3" = "GetMsgs" ];}; then TAM
else DisplayArguments
Expand Down

0 comments on commit 757554f

Please sign in to comment.