You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1003 B
44 lines
1003 B
#!/bin/bash
|
|
|
|
SID=0
|
|
|
|
#
|
|
# define FB_USER and FB_PASS in file fbconfig.config the user must have access to the SmartHome
|
|
if (test -r $HOME/.fbsh.config); then
|
|
source $HOME/.fbsh.config
|
|
fi
|
|
|
|
#
|
|
# login into the FB, grabbing a valid Session Key into variable SID
|
|
# parameters: FritzboxIP Username Passwort
|
|
#
|
|
function login () {
|
|
local CID
|
|
local PW
|
|
local TMP
|
|
|
|
CID=$(curl -s $1/login_sid.lua | grep -o "<Challenge>[a-z0-9]\{8\}" | cut -d">" -f 2)
|
|
PW=$(echo -n "$CID-$3" | iconv -f ISO8859-1 -t UTF-16LE | md5sum -b | cut -c -32)
|
|
SID=$(curl -s $1/login_sid.lua -d response=$CID-$PW -d username=$2 | grep -o "<SID>[a-z0-9]\{16\}" | cut -d ">" -f 2)
|
|
if [ "$SID" == "0000000000000000" ]; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
#
|
|
# listing all switches FB using the SID parameter
|
|
# parameter
|
|
function getdevices () {
|
|
LIST=$(curl -s "$1/webservices/homeautoswitch.lua?switchcmd=getdevicelistinfos&sid=$SID")
|
|
return 0
|
|
}
|
|
|
|
|
|
login $FBSH_HOSTNAME $FBSH_USER $FBSH_PASS
|
|
getdevices $FBSH_HOSTNAME
|
|
|
|
echo $LIST
|
|
|