Controling Homeautomation devices using wifi presence

From BubbaWiki
Revision as of 06:11, 29 June 2012 by Daniel Malmgren (talk | contribs) (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...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This guide is not finished yet. I'm working on it :-)


  1. !/bin/bash

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

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