Grab data from a website by polling and trigger events?

I would like to have the final entry in the HN24 cm column from available as a tile/device, so I can trigger the so-called “20cm rule” at the local ski hill. What the best way to poll a website and get the date into my home automation system? Can I have my ST hub do the polling or do I need to install a service on my Mac? Or is something available through IFTTT?

Your “hub” won’t do the polling… Remember that custom SmartApps run only in the SmartThings Cloud

Regardless, yes… you can create a “cloud to cloud” Device type and have a SmartApp schedule a periodic refresh. I would not have it poll too frequently though; that’s discouraged and unnecessary.

Thanks. Is there a recommended library/routine/pattern for extracting data from an HTML page? (Or maybe the page is available as a JSON.)

The SmartThings “http” libraries available to DHs and SmartApps are rather self-explanatory.

NB: Not saying this is a better or worse way to go, but … WebCoRE is a popular tool for building automations without writing SmartApp code. I don’t know all its features, but it might include some basic REST-API query functionality.

This is correct. You can poll the API with webcore, then create a tile, email it or text it to yourself, or whatever. @music_and_cities Hit me up on the webcore forum if you’d like more information on this.

1 Like

I ended up writing a bash script to run every 15 minutes on my Mac, which sends it to IFTTT. On my Mac I could use a combination of nokogiri (for parsing the html) tail (for getting the most recent obversvation) awk (for getting the 8th entry) and head (for removing the extra line). I don’t think nokogiri, tail, awk, and head are available in the Smartthings platform.

echo `date '+%Y-%m-%d %H:%M:%S'`
snow=$(/usr/local/bin/nokogiri -e 'print @doc.at_css("body/pre")' | tail -2 | awk -F " " '{print $8}' | head -1)
echo "snow is" $snow

if (( $(echo "$snow > $1" | bc -l) )); then 
    echo $snow "is less than "$1" cm :("

If supported json I’m sure I could have done it in the SmartThings platform, but they seem to only have html.

There’s some snow in the forecast in the next few days, so hopefully I’ll be able to both test my notifications and also go skiing in some fresh pow.

1 Like