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

Can you use Web Requestor as a device in sharp tools and set it up to broadcast like in webcore? I was thinking like what I have below, but I’m not sure if that would work.

Hi, OK I managed to squeeze everything in by removing unnecessary spaces and returns. However, I cannot send proper authorization headers or content-type headers, any thoughts?

Sorry to say these are not supported at the moment but I will look at a way to include them; No promises on timeframe as I have my hands full right now.

2 Likes

Understood, thank you!

Hi,

I’m trying to look at a number of workarounds to be able to enable motion on my cameras when I leave the house.

I’ve looked at @TAustin ONVIF driver but my model of cam seems to be having issues with enabling motion with that driver, so I am looking at a different approach a web request.

I’ve managed to craft the require parameters into a GET message, however the Foscam camera I am using seems to require all the params to return a success result, which results in a rather long string, current 419 characters (although this could be sightly higher dependent on the values you specify in each config section).

It looks like the driver only allows up to 250 characters as posting in my crafted message truncates at that number and will not allow typing of any other items.

I am really hoping this is not a system limit imposed by Smartthings and is something that could be perhaps increased with the next version of the driver?

@TAustin, I appreciate you are busy supporting an number of you drivers so this is something that may take time to be looked at, but I would like to thank you for the excellent range of device types you are creating. You are more than ably filling the gap Samsung seem to be creating with retirement of groovy leaving voids that the community needs to sort out, I think post 30th Sept many users will be on these forums who are not aware of Groovy being sunset looking for solutions to their broken devices/automations and your devices will likely make a foundation for those fixes. It is great we have such a strong community

From what I gather in Todd’s post where he added support for posting ‘body’ data along with a request, it can be done but you would need to preconfigure the request with your URL + payload.

When you view the Web Requestor ‘master’ device in the SmartThings mobile app, you can tap the ... in the top-right corner of the app and choose Settings to preconfigure a number of requests. The first 5 requests support including body data.

Then from the SharpTools side of things you can call one or more of those requests using the setSelection method along with the number of the slot you configured.

From some quick testing, I suspect this will only work in a very limited set of cases. The request that is issued doesn’t appear to include a Content-Type header at all, so many webservers won’t recognize the content as JSON and thus won’t parse it.

Are you using ‘Assistant Relay’? From a quick review of the Assistant Relay code, it looks like it’s based on Express (Node.JS) and thus would require the content type header to be set to application/json for it to parse the body properly. :frowning:


@TAustin I understand you have your hands full at the moment, but throwing this request out there… it would be really cool if the on-the-fly POST() command accepted an optional body content so people could dynamically create requests – that way they could inject variables/values into their requests via rule engines like SharpTools. Similarly, it would be great to default the POST requests to application/json or provide an optional parameter to specify headers and/or content-type. :pray:

1 Like

@Wayne_Myers

It is sadly the case that I’ve been unable to get motion events to work with Foscam cameras. Based on a lot of debugging help with @milandjurovic71, and internet forum reading, I’ve concluded that the models we’ve tried simply do not support events through the ONVIF interface. (Of course it works with their own proprietary app and interface).

Do your cameras have a documented REST API interface? I’d be interested in understanding that more, and exactly what you are trying achieve regarding enabling motion events.

If you are referring to what you can actually type into the request string field in Settings, any character limitation there is being imposed by the SmartThings app, not the driver. There is no maximum string length defined in the device profile. I’ll have to see if it is possible to increase the 250 character limitation by explicitly defining a maximum string size, but I’m doubtful. How long do you need? If this is a common need, I suppose I could provide a ‘bodypart1’ and ‘bodypart2’ field that would at least double the potential body size.

And thank you for the kind words! :pray:t3:

1 Like

You are correct. The only headers I explicitly set are Accept = */*, and Content_Length. However I can certainly look at adding a Content-Type header that would be set via another Settings field. I could also try and parse the data and guess what type it is…

I would like to support that, but last I looked at doing it, there was a problem with SmartThings supporting multi-argument commands. But that was last year, and maybe it has been fixed. I will look into it.

2 Likes

Thank you @TAustin

In terms of what I would like to achieve with event enablement. I want to be able to switch the cameras to notify me when I am either away or during the night if there is movement. At the momoent, I have an automation using rboys Foscam groovy app, that allows me to arm/disarm the cameras through toggling a switch dependent on mode, SHM status.

Originally I went down the ONVIF driver route, but had a feeling there was a struggle to make it work with my camera’s, hence why I looked at your web requester driver knowing that the cameras can enable/disable feature with GET requests. I will then build some routines to send either an enable request, or disable request dependent on the mode etc. Having notification events or the camera feeds viewable in the ST app are all nice to haves for me and not essential, as I send email notifications from the cameras anyway on movement, and also get them to upload stills and video to an sFTP server.

I have command reference for the Foscam cameras, it was last updated in 2016 but all the commands I have tried so far work It used a cgi script as a proxy, but you use a get statement to call the camera.

I have created a string to enable the camera, and when posted through the web browser it works, and I get a successful result back, which by checking in the Foscam app or the Web UI you can see it is successful using the ‘setMotionDetectConfig’ parameter.

The problem is that schedule and area have multiple versions of the parameter that must be passed to enable correct function of motion events, you have to pass as a minimum the ‘isEnable’ command and the ‘schedule’ and ‘area’ parameters or it does not work. There multiple elements to schedule and area

I did try not passing as many parameters but for the events function to work, which is what it refers to as a notification event, If you just pass the ‘isEnable’ parameter the camera looks like it is enabled in the WebUI, but in the app it says that schedule and area is not set so you will not recieve notifications. In fact when you then use ‘getMotionDetectConfig’ to get the state, you can see those parameters are set to zero.

As of now I got the string down to 419 Chars, but that did not include URL encoding which I am hoping will also not be needed.

If you would like a copy of the Foscam dev CGI User guide just let me know the best way to get it to you

Being unfamiliar with the underlying code capabilities within the Edge driver ecosystem, is there a possibility of ever being able to add/edit custom names or aliases for the numbered web requests?

1 Like

It is possible to do that, yes. I would have to add the name fields into the device preferences. I don’t know if I would run into any limits, since I have >50 fields there already! And this would effectively double that. I may give this a shot in my next update. I’ve got a few change requests to address, so hope to have an update out in about another week.

1 Like

That would be great. I’m running multiple instances of the driver to separate/organize my requests, but I have one with 15 requests already that’s driving me crazy. :grin:

1 Like

I’m asking about something I know absolutely nothing about. Whatever I’ve managed to get working in webCore, was done by copying commands from the forum and trying them until they work. So against that background:

Can any of your Edge solutions be used to Start/Stop playback on Heos (Denon) speakers: https://community.symcon.de/uploads/short-url/eMRFvjrfZl8Wp4AwvZPqiv2WpEK.pdf and Denon HEOS - Bindings | openHAB.
From what I could find is that telnet commands have to be used and members previously reported that it is not available on the Smartthings hub?
Edit: Don’t know if it would help to look at how the guys at Hubitat did the integration with a Groovy smartapp and drivers: GitHub - dcmeglio/hubitat-heos

If I understand the Readme in respect of this driver correctly, I should be able to use your driver to control these devices? (Qwikswitch system sold in South Africa.) This link would perhaps be easier for a quick look. My understanding is that it will however be “dumb” integration in that the driver will only send a request, but will not know if the device is on/off? To have that kind of communication/integration, devices have to support the MQTT protocol?

I think both of those things are true. One would have to write a custom telnet client library for Lua, as I don’t see any that already exist. It could be done, but would take some effort.

Web requestor does not use Telnet, which has its own protocol requirements, so it wouldn’t work for you.

Another way to implement this is with an app running on, say a Raspberry Pi, that talks to an Edge driver on one side, and sends/receives the telnet commands to the speakers on the other - so acting as a bridge. MQTT probably isn’t the answer since the device itself doesn’t support it.

I’ve done some more thinking about this and realize I may not be able to fully address the challenge you are having, due to some platform constraints.

Right now the selectable list of web requests on the Controls screen is a fixed, predefined list of labels. They can not be dynamically updated based on any names provided through settings. I could still add a display field on the Controls screen to show the configured name of the executed webrequest - but that would be after-the-fact.

I don’t know if it be worth the trouble of adding name input fields in Settings if the only place they would be shown is after a web request number is already selected. But let me know your thoughts.

In automations, we have the same problem - the fields you can select are similarly fixed and predefined. So even if I did provide a way to assign a name to the web requests, they wouldn’t show up on the automations menus.

So all this is to say that until the SmartThings custom capabilities allow for dynamic lists in both select buttons and automations, my hands are a bit tied. Some developers might be aware there is a ‘media presets’ capability in ‘proposed’ status that kind of provides this, but it is rather oriented towards selecting from a list of media tracks (‘favorites’).

1 Like

Here is a look at what that mediaPresets capability would look like, taken from my Roku driver where it is used:


IMG_2685

Its label (can’t be changed) says ‘Play a favorite’. You tap the star button and you get a list that can be configured by the driver dynamically. I suppose I could use this if I added the ability to name the requests, but the button label would always be a bit hokey. One thought is to maybe have the ability to name the requests only for request #1-20, just to stay within any possible limits in both the device preferences fields and this particular capability.

I am not the least bit surprised that these constraints exists. Just thought it was worth asking the question. Thanks for looking.

i manged to send a get to node red on my pi zero w to make my google mini say the freezer is open ,
im chuffed lol it only took me a few hours :grin:

thanks @TAustin for another great driver

2 Likes

I use Node Red more and more these days. Super simple automations because making complex routines is way over my head. But with http request driver it opens up whole new frontier. If I only knew how to properly write json. :smile::person_shrugging:

Hi Wayne - Sorry it’s taken me a while to circle back on this, but I’m working on updates to this driver now.

I will be implementing a ‘part 2’ body in the device settings and the driver will simply concatenate the two together in the final message. Hopefully that will give you what you need (up to 500 characters).

1 Like