What's new

Use Merlin for WiFiPresence

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

kevinnaronha

New Around Here
I am looking for a way to trigger an IFTTT Maker channel request depending on WiFi presence (i.e., whether a device is connected to the router). I browsed around the forum and found a post that looks for connected MAC addresses and based on that carries out certain action. I tried to modify the same for my purpose as below and saved the following as CheckIFHome2 in /jffs/scripts/:

Code:
#!/bin/sh

macadresser=`wl -i eth1 assoclist`

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
  *CC:29:VV:XX:YY:ZZ*)
     if [ ! -f /jffs/scripts/CheckUser/AlHome ]
     then
       touch /jffs/scripts/CheckUser/AlHome
       curl -X POST "https://maker.ifttt.com/trigger/AlHome/with/key/API-KEY"
     fi
     ;;
  *04:F1:VV:XX:YY:ZZ*)
     if [ ! -f /jffs/scripts/CheckUser/RsHome ]
     then
       touch /jffs/scripts/CheckUser/RsHome
     fi
     ;;
  *)
     if [ -f /jffs/scripts/CheckUser/RsHome ]
     then
       rm -f /jffs/scripts/CheckUser/RsHome
     fi
     ;;

     if [ -f /jffs/scripts/CheckUser/AlHome ]
     then
       rm -f /jffs/scripts/CheckUser/AlHome
     fi
     ;;
esac

I changed the chmod to 777. I also copied the init-start script (chmod 777) in the /jffs/scripts folder:

Code:
#!/bin/sh
cru a CheckIfHome "* * * * * /jffs/scripts/CheckIfHome2"
cru a CheckIfHome15 "* * * * * sleep 15; /jffs/scripts/CheckIfHome2"
cru a CheckIfHome30 "* * * * * sleep 30; /jffs/scripts/CheckIfHome2"
cru a CheckIfHome45 "* * * * * sleep 45; /jffs/scripts/CheckIfHome2"

I was hoping that the code will check if the two mac addresses are connected and will create the files RsHome AlHome depending on their presence status and that I will be able to trigger the Maker request using that information. However, the above is not working. I am not sure what am I missing....appreciate any advice....thanks!
 
That seems way more complex then it needs to be?

Code:
#!/bin/sh

wl -i eth1 assoclist | while read macaddress; do
        case "$macaddress" in
                *AA:BB:CC:DD:EE:FF*)
                /usr/sbin/curl -X POST "https://maker.ifttt.com/trigger/AlHome/with/key/API-KEY"
                ;;
        esac
done

and I think you only need one entry for the init-start script?
Code:
cru a CheckIfHome "15 * * * * /jffs/scripts/CheckIfHome"
 
I have to wonder though -- with cell phones reserving power n all, will it always be in the arp table? I can see situations where it might be "asleep" or in low power mode long enough to suggest that the unit is no longer present.

Oh, and I'm not familiar with ifttt... I wrote that code as if it's a watchdog -- some other default would trigger if the 15 minute heartbeat isn't received. If that's not possible, then yeah, keeping track of the users via those file placeholders should go back in.
 
Thanks....I tried the code, but still no results.

I uploaded both the CheckIFHome and init-start in the right folder and rebooted the router. Is there any way for me to help you debug the code.

Additional piece of information - I am using a Ubiquiti access point that is wired to the Asus router. On my Asus router I see the phones as "Physically Connected". I am guessing this will change the wl command. When I type wl -i eth1 status in PUtty, I get a response

Not associated. Last associated with SSID: ""

Appreciate your assistance.
 
Last edited:

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top