Difference between revisions of "Controling Homeautomation devices using wifi presence"

From BubbaWiki
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 :-)<br>
This guide is not finished yet. I'm working on it&nbsp;:-)<br>  
 
<pre>#!/bin/bash
<br>
<blockquote>
#!/bin/bash


HomeAutomationUrl="http://192.168.168.1/homeautomation/"
HomeAutomationUrl="http://192.168.168.1/homeautomation/"


# Devices that affects HomeAutomation<br>homeDevices[0]="84:00:d2:e4:3b:9f" #Xperia Ray<br>homeDevices[1]="d0:df:c7:fd:8d:ea" #Galaxy Tab
# 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<br>HomeAutomationDeviceIds[0]="20" #Xperia Ray<br>HomeAutomationDeviceIds[1]="21" #Galaxy Tab
# HomeAutomation device ids
HomeAutomationDeviceIds[0]="20" #Xperia Ray
HomeAutomationDeviceIds[1]="21" #Galaxy Tab


connected="AP-STA-CONNECTED"<br>disconnected="AP-STA-DISCONNECTED"
connected="AP-STA-CONNECTED"
disconnected="AP-STA-DISCONNECTED"


countHomeDevices=${#homeDevices[*]}
countHomeDevices=${#homeDevices[*]}
Line 23: Line 25:
connectionState=0
connectionState=0


if [ $2 = $connected ]; then<br> connectionState=1<br> echo "$3 Connected!" &gt;&gt; /var/log/hostapd.log<br> else if [ $2 = $disconnected ]; then<br> echo "$3 Disconnected" &gt;&gt; /var/log/hostapd.log<br> else<br> echo "What happened now?" &gt;&gt; /var/log/hostapd.log<br> fi<br> fi
if [ $2 = $connected ]; then
  connectionState=1
  echo "$3 Connected!" &gt;&gt; /var/log/hostapd.log
else if [ $2 = $disconnected ]; then
    echo "$3 Disconnected" &gt;&gt; /var/log/hostapd.log
  else
    echo "What happened now?" &gt;&gt; /var/log/hostapd.log
  fi
fi
 
$(wget -O /dev/null -q ""${HomeAutomationUrl}"ajaxinterface.php?do=toggleStatus&amp;status="${connectionState}"&amp;deviceid="${HomeAutomationDeviceIds[$i]}"" )
fi
 
done


$(wget -O /dev/null -q ""${HomeAutomationUrl}"ajaxinterface.php?do=toggleStatus&amp;status="${connectionState}"&amp;deviceid="${HomeAutomationDeviceIds[$i]}"" )<br> fi


done<br><br>
</pre>
</blockquote>

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