I use my Smartthings system to monitor a rental property. I’m trying to see if there is a way to develop an application that would report the external/public IP address of the cable modem that serves by SmartThings Hub. I looked into DynamicDNS but that now requires a recurring fee which I’d like to avoid. I would like to use the Public IP to remotely monitor/configure by Cable Modem. My modem is setup to NAT. I was thinking that the the Smarthings web portal might have access to this public IP and maybe there is a way to retrieve it?
Thanks, since this is a rental properly I don’t have any computers there. I’m monitoring smoke/CO alarms, thermostat and door openings (when there is no one in the unit). I want to be able to manage my cable modem/Wifi to change Wifi passwords and things like that. The modem only offers using a dynamic DNS service that charges $50/year which I’d like to avoid. I have no place to run a script so that it why I was hoping I could somehow use the smarthings setup.
If you create a php script with the following line on a web server some place, calling that script from an HTTP GET will return the WAN IP of your modem.
<?php echo $_SERVER['REMOTE_ADDR'];?>
You could create a SmartApp that would issue the GET on a schedule, and return the response to you in either a notification or text message.
However, if you have no internet presence in which to park the script, you’ll need to use one of the existing pages out there to do it, and this will dramatically increase the amount of work to be done in parsing the response.
Also new to ST. So, how would one use the above code inside an actual application that needs to trigger a local action? For example, when a given door opens, then trigger a rapberry pie which exposes a web interface for speech to a speaker. I can see other application examples calling a well known website, but still need a way to find the correct address of my server. Also, is there a way for this info to be stored and reused after periodic refreshes?
Thanks for all the code sharing and advice! I’m looking forward to sharing something useful pretty soon…
I tried the above code from pstuart’s github - created a new device type and a device. However, log only shows the poll routine running. I cannot see any responses being received in the parse routine.
I have looked at the postings - have definitely create a device of type ps_GetPublicIp. Did anyone else have this working? I know I am doing something wrong - have a similar problem with another app (vlc) that I have copied and used - it works sending http commands but not processing any responses back.
I had this working when Patrick first posted it, but since it has stopped working. From searching the posts it appears the DeviceNetworkId needs to be set appropriately to get responses back however everything I’ve tried does not work, so clearly I’m missing something.
When I just copy of the code you posted above and just create a device WITHOUT specifying the deviceNetworkId in the create form, its does not work as it did the first time I created it. But now, when I put the deviceNetworkId of d8922646:0050 in the create form, it does work. So something has changed on the platform where either the code above no longer sets the deviceNetworkId properly or we have to know in advance what the deviceNetworkID is so it can provisioned on the create device form.
One other thing that is strange, I added a line into your code to print out the deviceNetworkID (using sendEvent(…)). When I did that it did print out the event with the correct deviceNetworkId, however the remainder of the code stopped working, i.e. it never printed out the IP address. Just curious why this would affect how this app works, this environment seems very non-deterministic.