Loading a URL on the local lan such as URL/index.php?runzmday=true

smartapp
hubv2

(John Skinner) #1

Hello!
I was wondering if there is a way to call a URL as a webbrowser would, when I set the SmartThings app to away/arm. It would need to call up: URL/index.php?runzmday=true which tells my zoneminder instance to use motion capture mode and then another url to disarm it. Is there an existing bit of code out there to do this. Just to call up a URL when a mode is set?

Essentially, this tells zoneminder to go into record, or do not record mode via processing the URL path that I listed, /index.php?runzmday=true.

Thanks in advance! Hopefully what I described makes sense!

Edit: I’ve edited the content of this post to contain more of the information I am looking for.


(Kevin Tierney) #2

Yes, it’s fairly easy.

Here’s the official docs on how to do it
http://docs.smartthings.com/en/latest/smartapp-developers-guide/calling-web-services-in-smartapps.html

Here’s an example that does a HTTP post when a virtual switch is turned on. Changing from POST to GET should be minimal


(John Skinner) #3

This is awesome, thank you for the reply!

This will be my first adventure into a custom app for this, now to integrate this with the smart home monitor app, so that away = record url /get and home = do not record url /get.

Also, to figure out virtual switches and how to make them work.

Thanks again for the direction!
John S


(John Skinner) #4

I am running into an issue with this where I just want to call the URL, no parse a response from it, and the URL is a local machine on my network that is not public facing. I can call it from my browser just fine and it performs the operation on the device that is listening for the call, however smartthings is either telling me: org.apache.http.conn.ConnectTimeoutException:
or it tells me
java.lang.SecurityException: Endpoint is blacklisted

depending on if I include http:// or not in the uri.

I have successfully learned how to have it identify with the virtual switch and perform actions if it is being toggled on or off, I just need to make it access the URL when it is on, or off, on will turn on record, off will turn it off. Easy enough right?

Basically, can I use addresses Local to the LAN the hub is installed in, or do the addresses need to be public facing? I think it has something to do with using HubAction?


(Kevin Tierney) #5

Yes, you can send to the local ip. You have to use the hub action commands so that ST knows to send over loval lan and not though internet. Take a look at the camera device type here for a good example

There are some OK docs that might help in the section on building LAN device types under the ST documentation


(Mr. Smith) #6

So how do i turn this into a Get?