Difference between revisions of "Controling Homeautomation devices using wifi presence"
Jump to navigation
Jump to search
(Created page with 'This guide is not finished yet. I'm working on it :-)<br> <br> <blockquote> #!/bin/bash HomeAutomationUrl="http://192.168.168.1/homeautomation/" # Devices that affects HomeAut...') |
|||
Line 1: | Line 1: | ||
This guide is not finished yet. I'm working on it :-) | This guide is not finished yet. I'm working on it :-)<br> | ||
<pre>#!/bin/bash | |||
<br> | |||
< | |||
#!/bin/bash | |||
HomeAutomationUrl="http://192.168.168.1/homeautomation/" | HomeAutomationUrl="http://192.168.168.1/homeautomation/" | ||
# Devices that affects HomeAutomation | # Devices that affects HomeAutomation | ||
homeDevices[0]="84:00:d2:e4:3b:9f" #Xperia Ray | |||
homeDevices[1]="d0:df:c7:fd:8d:ea" #Galaxy Tab | |||
# HomeAutomation device ids | # HomeAutomation device ids | ||
HomeAutomationDeviceIds[0]="20" #Xperia Ray | |||
HomeAutomationDeviceIds[1]="21" #Galaxy Tab | |||
connected="AP-STA-CONNECTED" | connected="AP-STA-CONNECTED" | ||
disconnected="AP-STA-DISCONNECTED" | |||
countHomeDevices=${#homeDevices[*]} | countHomeDevices=${#homeDevices[*]} | ||
Line 23: | Line 25: | ||
connectionState=0 | connectionState=0 | ||
if [ $2 = $connected ]; then | if [ $2 = $connected ]; then | ||
connectionState=1 | |||
echo "$3 Connected!" >> /var/log/hostapd.log | |||
else if [ $2 = $disconnected ]; then | |||
echo "$3 Disconnected" >> /var/log/hostapd.log | |||
else | |||
echo "What happened now?" >> /var/log/hostapd.log | |||
fi | |||
fi | |||
$(wget -O /dev/null -q ""${HomeAutomationUrl}"ajaxinterface.php?do=toggleStatus&status="${connectionState}"&deviceid="${HomeAutomationDeviceIds[$i]}"" ) | |||
fi | |||
done | |||
</pre> | |||
</ |
Revision as of 06:15, 29 June 2012
This guide is not finished yet. I'm working on it :-)
#!/bin/bash HomeAutomationUrl="http://192.168.168.1/homeautomation/" # Devices that affects HomeAutomation homeDevices[0]="84:00:d2:e4:3b:9f" #Xperia Ray homeDevices[1]="d0:df:c7:fd:8d:ea" #Galaxy Tab # HomeAutomation device ids HomeAutomationDeviceIds[0]="20" #Xperia Ray HomeAutomationDeviceIds[1]="21" #Galaxy Tab connected="AP-STA-CONNECTED" disconnected="AP-STA-DISCONNECTED" countHomeDevices=${#homeDevices[*]} date >> /var/log/hostapd.log for (( i=0; i<=$(( $countHomeDevices -1 )); i++ )); do if [ $3 = "${homeDevices[$i]}" ]; then connectionState=0 if [ $2 = $connected ]; then connectionState=1 echo "$3 Connected!" >> /var/log/hostapd.log else if [ $2 = $disconnected ]; then echo "$3 Disconnected" >> /var/log/hostapd.log else echo "What happened now?" >> /var/log/hostapd.log fi fi $(wget -O /dev/null -q ""${HomeAutomationUrl}"ajaxinterface.php?do=toggleStatus&status="${connectionState}"&deviceid="${HomeAutomationDeviceIds[$i]}"" ) fi done