parent
0ec0cd2971
commit
4ab5c9c275
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SID=0
|
||||||
|
FB_IP=fritz.box
|
||||||
|
|
||||||
|
#
|
||||||
|
# define FB_USER and FB_PASS in file fbconfig.config the user must have access to the SmartHome
|
||||||
|
source fbconfig.config
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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 http://$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 http://$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 "http://$1/webservices/homeautoswitch.lua?switchcmd=getdevicelistinfos&sid=$SID")
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
login $FB_IP $FB_USER $FB_PASS
|
||||||
|
getdevices $FB_IP
|
||||||
|
|
||||||
|
echo $LIST
|
Loading…
Reference in new issue