[ST Edge] Web Requestor: a driver to issue local POST and GET HTTP requests

It’s been a while since I used autoremote how exactly do you make the post webrequest run locally with an IP address? Are you running a forwarding service? If not that is amazing, please show me an example of a url post. Thank you in advance!

I use a task in Tasker that runs Actions > Plugin > AutoRemote > WiFi which can start and stop a web server on the Tasker host device on port 1817. That web server means I can use a URL of the form:

http://192.168.1.80:1817/?message=ANNOUNCE=:=Speaker=:=Message

I think you can add a path before the ?message if you want to but I am not entirely sure.

What I then choose to do is create a profile in Tasker using Profiles > Event > Plugin > AutoApps and that will trigger the tasker event if a ‘command filter’ is found in the URL, and in my example that is ANNOUNCE=:=.

The =:= separator is part of the AutoApps command format. It just means you can get some parsing done for you by the tasker action if that floats your boat.

I don’t particularly recommend this as a solution, it is just a rather laggy fudge I came up with before I lost any enthusiasm I had for Tasker and the AutoApps and at the time I built it into DTH, thus teaching myself how they worked. I also am not terribly keen on Cast-Web-API style man-in-the-middle solutions, mainly because it just seems incredible that they are necessary.

Just wanted to drop you a line and thank you for the Autoremote tip. I’m now running local commands to tasker. With the harmony remote app for tasker I can now turn on and off my air conditioning locally. I can’t thank you enough, the possibilities are endless!

Good to hear it works for you. I have just switched to a different tablet as my previous one was just too old and was becoming unusable. Sadly I struggle to keep AutoRemote WiFi responsive on the newer (but still old) one.

I’m using tasker and Autoremote on an Nvidia shield tv and as of yet has been working great!

This works perfectly for making Blue Iris perform actions based on SmartThings events. HUGE thanks to @TAustin for making this and his sidebar assistance.
For example, this can perform the same functions, completely local and without groovy, that the existing BI Fusion Smartapp allows for, like syncing the BI server Profiles to SmartThings location modes (e.g. ST changes to Away, set BI Profile to 1) and allows for triggering cameras based on SmartThings events (e.g. opening door triggers a camera).

A few notes without trying to completely derail the flexibility of this edge driver on a specific use:

  1. Just like BI Fusion, it still requires unchecking “Use Secure Session Keys and Login Page” in the BI Web Server settings and requires you run the web server, of course. This means you don’t want to give your server WAN access but instead use Stunnel or with a VPN, though that is typically good advice anyway. This limitation is detailed in the BI Help file directly but also says it is possible to elevate permissions from specific IPs, so I may just be missing something here (could not get it to work otherwise). Check the BI Fusion link above for some more details on this.
  2. The URL you’d use from the Web Requestor to drive BI to trigger a camera would be:
    GET:http://[BIServerIP]:[Port]/admin?camera=[ShortCamName]&trigger&user=[BIUserName]&pw=[BIPassword]
    If wanting to do a profile change, it’d be similar, with:
    http://[BIServerIP]:[Port]/admin?profile=[Number]&lock=[0, 1, or 2 for run, temp, or hold]&user=[BIUserName]&pw=[BIPassword]
    There is a huge amount of possibility here - check the BI Help file in the HTTP Interface section for all the options.
  3. If you ever plan to trigger more than one camera in a single automation, do not put them in the same device because automations in ST only allow a single device and the devices can only do one command per use in automations.
3 Likes

Notice of Driver update:

A minor fix has been made to the driver to improve handling of non-text values for extracted key values.

As I made this change, I uncovered an anomaly in the way SmartThings may handle output fields in the app: if you extract and display a value that SmartThings interprets as a date/time value, the mobile app may keep expecting a date/time value. So if you change the extraction key to look at some other value in the response data that is text or numeric, for example, the app may display ‘Invalid Date’. The issue does seem to clear itself after closing and reopening the app and it will again display other data types ok. Just be aware…

2 Likes

Is anybody else using Web Requestor v1.2 to send Get Requests to a tablet running Fully Kiosk Browser, seems I’m getting app overlay, or it’s just me?

I think this one needs escalating.

@nayelyz can you help please? This driver returns the result of web requests in a ‘response’ attribute and we’ve discovered that if you display the attribute value in the details view it will actually try and interpret the value as HTML rather than showing the raw code. That seemed to have some interesting potential, but it rather seems like bad stuff can happen too. In this case it looks like the DOM can be messed with. My worry is whether engineered code could do something worse than make a mess.

1 Like

Just to be clear, do you want to report the acceptance of HTML in the capability value because it causes strange behavior in the app?

I reported before that the HTML was being accepted, if in this case, it is causing major issues in the app, I can share those comments with the team so they consider putting a higher priority on it.

Sort of. I have no problem with HTML being accepted in capability values. It is the way it is handled that concerns me.

It would appear that HTML in attributes isn’t being safely handled as can be seen from the device history tab @Alwas posted, and he tells me that it still looked like that fifteen hours later. It shouldn’t be possible for anything like that to happen, even if the Fully Browser has responded with eleventy billion pages of HTML when a simple ‘OK’ would do.

My personal opinion is that HTML in values should generally be displayed as raw text and not interpreted, but if you want to interpret it then at least sandbox it.

If you have already reported an issue then nothing I have said should really be a surprise to the team. However the Edge drivers have increased the pace of community development so much that protecting users from themselves may need prioritising.

1 Like

I totally agree, I already added the picture and the comments shared above in my report.
Thank you for your input to help us know better the impact of this issue.

1 Like

Right now I throw whatever HTTP response I get into a simple text field capability. To mitigate these types of issues, I should probably limit the number of characters I put to something reasonable. But I agree with @orangebucket that the platform shouldn’t allow itself to get messed up because a dumb developer like me overloads a text field - whether it’s HTML code or whatever.

So my question is: IS there supposed to be a character limit on text field values? and if so, what is it?

Wow. Great concept. Can you please summarize:

  1. is this available in Webcore yet, or not? Hypothetically, if it were available in Webcore it could be paired with VoiceMonkey to, for example, use voice commands to run a TV that a) can accept HTTP commands but b) is not yet officially integrated with Alexa.

  2. If it runs locally, would I need an Android phone or tablet…. and would that phone/tablet work fine just running SmartThings mobile app? Or is it needing an intermediary such as Tasker?

Hi - this is a SmartThings Edge driver, meaning it runs locally on a SmartThings hub. You can do similar things in webcore for sure, but we’re not sure how long that is going to be around, so best to start doing things with Edge drivers for future proofing and to take advantage of local execution.

You need some device that is running the SmartThings mobile app - yes either Andriod phone or tablet (or iPhone). There’s no other intermediary - just an Edge driver that runs on your hub.

It needs me to update my version of Smartthings to run this. Given the issues I’m seeing in the forum with the current version, I’m gonna wait a bit and revisit this in some weeks.

Forgive my stupid question, could this in theory allow me to set up local execution for currently cloud integrated WiFi devices? I’m thinking specifically about switchbot, api is here GitHub - OpenWonderLabs/SwitchBotAPI: SwitchBot API Documents
Sorry if I misunderstood the drivers capabilities…have a 4 month old so permanently frazzled at the mo

I took a very quick look at that API, and it requires additional data to be sent in a json body along with the HTTP request. This Web Requestor driver will only send http requests with endpoint URLs and optional parameters, but not a json body.

However, I think that an Edge driver could certainly be developed to support this switchbot API.

2 Likes

Thanks for the reply :slight_smile: I will leave that to more capable members of the community. In the meantime I’m going to play around with this driver as I’m sure I can do something with it. Thanks for all the Dev work youre doing

1 Like

“I have a rule that attempts to connect to an IP address and port on the TV every few minutes.”

I’m sure this is a very simple answer but I can’t figure it out- how did you set it up so it pings every few minutes?

My use case is similar but slightly different- I would like the web requestor to ping a device every few minutes only while another separate device is on

I’ve got it so when the trigger device turns on, web requestor makes a single web request, which is ALMOST good enough, I just need it to keep making the request every X minute until the trigger device turns off again.

Thnx in advance

Edit: I know I could accomplish this easily in webcore, but I’m trying to keep everything in smartthings automations/routines.