/
CheckIfHome
106 lines (93 loc) · 2.42 KB
/
CheckIfHome
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
if [ ! -d /tmp/CheckUser ]
then
mkdir /tmp/CheckUser
fi
Stuart=Away
Sharon=Away
Dane=Away
Scott=Away
macadresser=`wl -i eth1 assoclist`
antal=0
antal=`qcsapi_sockrpc get_count_assoc wifi0`
while [ $antal -gt 0 ]
do
antal=`expr $antal - 1`
macadresser="`qcsapi_sockrpc get_station_mac_addr wifi0 $antal`;$macadresser"
done
case "$macadresser" in
*XX:XX:XX:XX:XX:XX*)
Stuart=Home
;;
esac
case "$macadresser" in
*XX:XX:XX:XX:XX:XX*)
Sharon=Home
;;
esac
case "$macadresser" in
*XX:XX:XX:XX:XX:XX*)
Dane=Home
;;
esac
case "$macadresser" in
*XX:XX:XX:XX:XX:XX*)
Scott=Home
;;
esac
if [ "$Stuart" = Home ]
then
if [ ! -f /tmp/CheckUser/StuartHome ]
then
touch /tmp/CheckUser/StuartHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/home?access_token=<Access Token>" -k
fi
else
if [ -f /tmp/CheckUser/StuartHome ]
then
rm -f /tmp/CheckUser/StuartHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/away?access_token=<Access Token>" -k
fi
fi
if [ "$Sharon" = Home ]
then
if [ ! -f /tmp/CheckUser/SharonHome ]
then
touch /tmp/CheckUser/SharonHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/home?access_token=<Access Token>" -k
fi
else
if [ -f /tmp/CheckUser/SharonHome ]
then
rm -f /tmp/CheckUser/SharonHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/away?access_token=<Access Token>" -k
fi
fi
if [ "$Dane" = Home ]
then
if [ ! -f /tmp/CheckUser/DaneHome ]
then
touch /tmp/CheckUser/DaneHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/home?access_token=<Access Token>" -k
fi
else
if [ -f /tmp/CheckUser/DaneHome ]
then
rm -f /tmp/CheckUser/DaneHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/away?access_token=<Access Token>" -k
fi
fi
if [ "$Scott" = Home ]
then
if [ ! -f /tmp/CheckUser/ScottHome ]
then
touch /tmp/CheckUser/ScottHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/home?access_token=<Access Token>" -k
fi
else
if [ -f /tmp/CheckUser/ScottHome ]
then
rm -f /tmp/CheckUser/ScottHome
curl "https://graph-eu01-euwest1.api.smartthings.com/api/smartapps/installations/<AppID>/Phone/away?access_token=<Access Token>" -k
fi
fi