Well, I guess that means arp | grep " $MAC_ADDRESS " does not return anything meaningful in your case and hence new_state is empty and an error occurs in the next line.You could try to use wl assoclist | grep $MAC_ADDRESS instead (like in the original post), however this won’t work for devices, which aren’t directly connected over wifi, but over e.g a bridge or a repeater.
To increase the time between scans, just increase WATCHDOG_SLEEP_SEC.
Now my virtual presence devices are working fine. The only detail is in the “recent” actions for each device I see several “toggle presence device” lines (one for each watchdog iteration) . What can I do to avoid that and get only the relevant actions.
Thanks
Thanks for everyone’s hard work on this. I have the smartapp and device handlers set up. When I go to the URL in my browser it works perfectly in changing the presence senor within the SmartThings app. I must be doing something wrong on the DD-WRT side of things. Is there any settings I need to change to make the script work. I tried it with both curl and wget. Is there a way to see a log file of what is happening in the router scripts? How do I know if I have curl installed. I am running Firmware: DD-WRT v24-sp2 (03/25/13) mega.
The steps I took to install the script is as follows:
Copied the startup script and then clicked “saved startup”
Then I copied the custom script and clicked “run command”
It appears to then add a “custom script” section on the bottom of the page which is blank. But the script remains in the Command Shell section.
If I click “Save Custom Script” nothing changes.
I have looked all over the place but can’t seem to find a more descriptive way of installing a script.
Hello, I recomend you to run the commands in console (Curl and wget) and see if are working in your router. I was not able to get those commands working (stock version) and I had to install the optware version .
This is my first time trying anything regarding router scripts etc. So i am not familiar with running the commands in the console. I believe i have wget on my router but not curl. I tried installing the ipkg via telnet but it doesn’t seem to be updating and then when i try ipkg list it tells me to run ipkg update so something isn’t working correctly. You need ipkg to install Optware correct? Trying to make sense of what I have been reading on forums and ddwrt wikis.
As I told you I had to install curl from Optware, so, to get the command working I must call curl this way:
/opt/bin/curl -k ${PHONE1ON}
(I installed wget in /opt/bin and ${PHONE1ON} is the variable where I have the URL). When I tried to run wget or curl command with the default version that came with the router, I received an error because that version is not compatible with HTTPS.
If your router is compatible, I would recommend you to install tomatousb and not DDWRT, at my experience is more reliable. In the past I used DDWRT and has some problems running Optware software.
Sorry for my bad english, I’m from Costa Rica and my native language is spanish.
Thank you @blancofran. I am still having some issues and it appears my router is not really supported by Tomato. There are some workarounds but it looks like a lot of people have bricked them. I started doing some peeking around and my jffs said that there was no memory available so I installed a mini build which at least allowed me to use the ipkg update command. However when it connected to the repositories they couldn’t download any of the update files. I spoke with my father and he said I still had an old linksys router in a closet from when I was younger so I think I am going to try and flash that with tomato and start there. I may also try to install optware like recommended in the tutorial.
By the way, your english is great and your help thus far has been greatly appreciated.
I am going to hold off for now and try the second router later this week.
I just picked up a different router which supports the Tomato firmware. I also tried both the curl and wget commands and it recognizes both. I am just having a little bit of difficulty on where I am supposed to put the router scripts. The Tomato router has an Init (instead of startup), Shutdown, Firewall, and WAN up. I am fairly certain I want the startup script in the INIT section and that I am not using Shutdown or firewall. Do I put the rest of the script in WAN up or do I make a script file and load it onto the jffs mountable storage on the router. If so I am not sure how to copy a file using telnet onto the router. I have done a lot of searching.
Ok. I am making progress. I installed optware. I also have run some tests trying to access URLs using both the curl and wget command with success. However when I use the https links i receive an error telling me that https is not supported or disabled in libcurl. I tried using the /opt/bin/curl -k reference. I also tried installed a package called wget–ssl and I can’t seem to get that to work. Any help would be appreciated.
I am trying to implement the example in the first post.
But I couldn’t understand how to form the URL at:
PHONE1ON=“https://graph.api.smartthings.com/api/…”
First of all , is this a device handler or a smart app ? (the code in the first post)
I created it as a device handler and got the client ID from settings.
I finally got fed up with ST’s mobile presence and did this today on my Asus AC68 router. I also wanted to do this to get VPN capabilities since I’m sitting behind a FIOS router and Asus stock firmware doesn’t allow Access Point mode to use VPN without all sorts of weird hacks. It took me awhile, and I did have to make some modifications to the above instructions:
Since my router is dual band and I only cared about the 5ghz, I had to use wl -i eth2 assoclist
I had to enable jjjfs on my router and then created custom.sh and whatever.startup (so it starts up properly on reboot) and store it in /jjffs/etc/config.
What is everyone doing for logic? I am using Home Mode Director with both my and my wife’s real phones and these virtual switches. So pretty much if all of them are away, house will go into away mode, if one of them is home, the house will go into home mode. I need to use double presences as I have a wifi extender in the house and if I move towards the rear of the house, our mobile phones disconnect from the Asus router and connect to an Actiontec network extender.
My primary router is NOT DD-WRT compatible, but a few others that I use for WiFi extenders, etc are (and I already have it running on one of them).
So, does the DD-WRT router that this script runs on have to be the one that the Android/device actually connects to directly for its WiFi connection, or will this still work if the DD-WRT router is simply connected to and part of the same TCP/IP network?
All of the routers/network extenders work independently of each other. You can install it on your extenders and when you connect to them, it will work. The problem is when you roam throughout your house, you will drop off the extender and your presence sensor will say your there. I have this problem in reverse.
Stupid question #2: Does this method require SSHd to be running on the DD-WRT router?
The reason I ask is that, although there IS a firmware for my router, it doesn’t include ssh. I’ve looked around and found one that seems appropriate to add ssh, but since I’m a total DD-WRT noob, I’m not exactly sure of the process to figure out whether or not a specific firmware will work with my router, and/or whether or not anything else is needed to get it to work properly, etc (I saw mention of compressing the CFE, but…lost).
Thanks for all the hard work on this. I got both methods working at different times: impliciter’s and cjunghans’.
My problem is though the logic for multiple mac addresses isn’t correct for either method and I don’t know how to tweak the custom.sh appropriately.
I’d like for it to be when ALL MAC addresses leave the network than the presence gets switched to PHONEOFF. When I run it now and ANY of the MAC addresses leave than it toggles to PHONEOFF.
Like the logic offered in the smartthings app with ‘Everyone leaves’.
Not really - technically you can set up the scripts needed through the DD-WRT gui. But I found it a lot easier to troubleshoot the issues with your specific router if you can SSH into it. The DD-WRT gui I’m using doesn’t provide any errors on the scripts or anything - so if it doesn’t work on the first try it’d be tough to figure out why with out SSH I think.
I’m a total DD-WRT noob too but got it figured out for the most part.