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

Thanks. With this change it now works. It did work a week ago with the colon, was a change made?

No, not to this! It’s a mystery…

Hi, thanks for making this.
I must be missing something, but I can’t work out how to send a series of commands without creating a device for each command.

I want to use routines to trigger a series of POST commands like this:

<YAMAHA_AV cmd=“PUT”><Zone_2><Power_Control>On</Power_Control></Zone_2></YAMAHA_AV>

I can do Routine, Control Devices in the smart app and send a Pre-configured web request, but then the device isn’t available to be used again in the routine.

I could string these commands together into one POST/web request, but I can’t work out how to do that either.

I feel I must be missing something obvious.

Thank you!

You’ve uncovered a shortcoming of using the automation routine screens in the mobile app. I think you’ll need to implement your automation using a Rule instead, which will allow you to do multiple commands for one device.

If you’ve never used Rules before, they may seem a bit intimidating at first because of the awkward JSON syntax, but having a template to start with helps a lot.

Here’s an example you could start with, which issues 2 sequential webrequests (slot #1 and slot #3) based on turning a virtual switch on (‘triggering deviceId’):

{
  "name": "Webreqsequence",
  "actions": [
    {
      "if": {
        "equals": {
          "left": {
            "device": {
              "devices": [
                "<triggering deviceId>"
              ],
              "component": "main",
              "capability": "switch",
              "attribute": "switch"
            }
          },
          "right": {
            "string": "on"
          }
        },
        "then": [
          {
            "command": {
              "devices": [
                "<webrequestor deviceId>"
              ],
              "commands": [
                {
                  "component": "main",
                  "capability": "partyvoice23922.webrequestselect",
                  "command": "setSelection",
                  "arguments": [
                    {
                      "string": "1"
                    }
                  ]
                },
                {
                  "component": "main",
                  "capability": "partyvoice23922.webrequestselect",
                  "command": "setSelection",
                  "arguments": [
                    {
                      "string": "3"
                    }
                  ]
                }
              ]
            }
          }
        ]
      }
    }
  ]
}

There is an alternate way you could do this by coding your requests into the rule itself rather than in the webrequestor device preconfigured slots. That way only supports GET and POST right now; I couldn’t tell by your post if you are actually needing PUT, which you can do for the pre-configured slots.

To actually get your Rule submitted and created in SmartThings you will either need the CLI, or my API Browser+ app, or do it by submitting your own RESTful API call from Postman or Curl. Happy to help guide you with any of those.

2 Likes

Is there any way to use the Web Requestor to control a device locally on the ST Hub?
I was able to use Automation Studio to create a simple http trigger to control a switch, but that only executes through the web.
Is it currently possible to use an html uri link to trigger a device on the ST Hub locally, without additional hardware or software running in the background?

Do you mean control a SmartThings Edge device or control some other LAN-based device?

I have 2 other drivers that allow you to control a SmartThings Edge device locally: one does it with HTTP requests, the other does it with MQTT messages.

1 Like

Hello Austin,
I mean to control another Zwave device on the ST Hub using a simple html request that can triggered by any local web browser on the same LAN.

It depends on if you want everything to be running locally. If that’s not a requirement, you could accomplish what you want via a browser by using the RESTful API to control your Zwave device.

But if you want it all to run local, then that is doable, but will require a combination of things. Without getting into TMI, you need to have an intermediate application to manage the messages into the SmartThings hub. That can be done with my edgebridge app or using MQTT. Then you can have a SmartThings device that can receive your browser-initiated request and trigger a SmartThings momentary button, for example. Then you’d have an automation that gets triggered by that and then does what it needs to do with your Zwave device.

I just did a quick experiment were I used a triggering device created by my LAN Trigger driver and I used a browser to send it a trigger through edgebridge. There’s some configuration involved.

Net: it’s doable but a bit convoluted.

1 Like

Yes, I need the http trigger to run even when there is no internet connection.
Could you please elaborate on how this would be done? By “can be done with my edgebridge app” do you mean Web Requestor or the LAN Trigger?
As I understand, the LAN Trigger app requires a Forwarding Bridge Server to be running elsewhere. If that’s the case, is there no way to do this without complicating the setup and adding additional dependencies?

Just to clarify, here is the basic desired behavior:

a. On my PC browser, I open a URL (GET Method), something like this: http://{STHub-IP}:{PORT}?SwitchA=on
b. ST Hub parses the request and turns ON SwitchA locally

I appreciate wanting something uncomplicated and with no dependencies, but unfortunately if you want to do this you need something like my edgebridge app (same thing as ‘Forwarding bridge Server’) and LAN Trigger driver. Webrequestor does not help with what you want to do: it is for sending requests OUT of the hub.

The reason you need this extra bit of complexity is this: Edge drivers do not have fixed port numbers. So if you were using a browser, you would not know what port number to send the request to at your hub’s IP address. Even if you did figure out what port number the driver was using, it can change whenever your hub is rebooted.

See the edgebridge link above, and/or this community topic:

Thank you for the clarification. So there is no way to run something like the edgebridge app directly on the ST hub? Would Automation Studio be unable to do this as well?
It does not necessary need to have a specific URL format scheme, as long as one URL link can turn ON and another turn OFF.

No

Any application that allows you to specify the full URL, including HTTP method, can work.

Any application that allows you to specify the full URL, including HTTP method, can work.

With Automation Studio, using “HTTP In” node, the generated URL is prefaced with “https://as-{ID}.app.scf.use2.devground.io”
This works, but it does require cloud access. Are you saying this can be modified to direct the http GET request directly to ST Hub on LAN?

No that won’t work then.