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

HI Todd, Is it possible to allow the Hostname to be used in HTTP Requests, instead of the IP Address?
Specifically from automations/routines.

I have a Raspberrypi which get allocated a different IP address occasionally.

Iā€™m afraid not; there is no name server running on the hub, so it knows nothing of host names, and I donā€™t think the HTTP library would even accept them (although I donā€™t recall if Iā€™ve even tried it or not).

Canā€™t you configure your router to assign your Pi a static IP address?

Ok. Good to know Iā€™m not missing something.

Ok, Iā€™m trying to utilize this for the first time with a Denon receiver. The command

http://192.168.x.xxx/MainZone/index.put.asp?cmd0=PutMasterVolumeSet/-45.0

works in a web browser. But when I then put it into a slot on the Requestor as

GET: http://192.168.x.xxx/MainZone/index.put.asp?cmd0=PutMasterVolumeSet/-45.0

and attempt to run it, it returns the error ā€œNot Configuredā€.

The address Iā€™m trying to hit is on my local network. What am I missing?

Hey there @TAustin,

Thank you for all your time and hard work on your edge drivers and in these forums. Iā€™ve been following/using your drivers for some time and they work great!

I just had 2, (hopefully very quick) questions about this driver that Iā€™m completely stumped on, unsure if Iā€™ve hit a limitation here :slight_smile:

Firstly, Iā€™m hoping to use an API that uses temporary tokens for authentication. Iā€™ve got a ST Device to request token and another to use the token but is there any way to use variables in the headers so I donā€™t need to manually copy paste the token?

Secondly, the page Iā€™m looking at getting data from (undocumented Asus router webpage) doesnā€™t use proper json format :slightly_frowning_face: Iā€™m guessing this means I canā€™t extract the key values but thought Iā€™d ask in case thereā€™s a fancy trick to it! It looks similar to json but I donā€™t recognise the format so Iā€™ve included the raw http response below in case you are familiar with it:

fanctrl_info = ; curr_cpuTemp = ā€œ66.040ā€; curr_rxData = fanctrl_info[3]; curr_coreTmp_2 = fanctrl_info[1]; curr_coreTmp_5 = fanctrl_info[2];

For this one, I think I saw a similar reply earlier in this thread. See if it works by adding a port as your browser will do this automatically. By default, http is port 80 so itā€™ll likely be:

GET: http://192.168.x.xxx:80/MainZone/index.put.asp?cmd0=PutMasterVolumeSet/-45.0

Turns out the solution is to, instead of using Web Requestor 1.2, go with Web Req Multi Master. It works in that utility.

But Iā€™m going to keep the Requestor 1.2, as a ā€˜repositoryā€™ for the requests Iā€™m utilizing in individual http switches.

1 Like

<<>>>

Fixed my issue 10 seconds after posting :slight_smile:

FYI - Web Requestor 1.2 is mighty old and has been replaced by the multi master version. It may still be out on my channel, but at some point you might want to get your automations transfer over. :slight_smile:

Yea, thatā€™s a tough one since SmartThings doesnā€™t support variables and I really have no way to implement them like the old webcore app. There IS a way to dynamically create your web requests using Rules. Iā€™m not sure if there would be a way to pluck the token out of some other deviceā€™s field and use it to build your URL in a ruleā€¦ probably not. For what you are trying to do, you may need to accomplish it outside of SmartThings, if thatā€™s an option for you. For example, if you have an always-on PC or Home server or Raspberry Pi or similar, you could better achieve what you are trying to do through use of the SmartThings RESTful API.

Yea, unfortunately I donā€™t have any tricks to help you. That definitely is not JSON and would need a custom parser to extract the values.

2 Likes

Thanks for taking a look at that one, @TAustin!
Thatā€™s good to know, I will research up on rules and/or see what alternatives there are out there.

1 Like

Iā€™m using this utility to treat a Denon surround AVR as a multi-zone system. Iā€™ve been doing that anyway, but this is the finishing touch. I created two Multi-Requestors; this is necessary because a device attribute can only be called once per routine. One Requestor is labeled ON-LEFT and the other OFF-RIGHT.

The Denon is set up as 5 + 2. Center in the bathroom, fronts in the dining room, surrounds in the garden. (2nd zone in the basement is a fully independent zone.) The Routines are in ST, and of course are exposed to Alexa as ā€˜scenesā€™. So if I say ā€œturn on garden muteā€, each of the Requestors is called. And each sends a goform/formiPhoneAppDirect.xml? GET to the correct IP address to change the appropriate left and right levels. -12 is mute; 50 is normal.

I will likely soon do Alexa routines for these. Because ā€œAlexa, turn off dining room muteā€ is far more cumbersome than ā€œAlexa, unmute dining roomā€.

2 Likes

Awesome use of the driver! Thank you for sharing your setup.

Thanks! The other thing Iā€™m going to do is assess which of my automations makes the most http calls, and then create that number of these Requestors. Iā€™ve already created 15 separate http switches; using Requestors instead will likely allow me to at least halve that once I delete the switches. Always have to keep the device limit in mind nowadays.

Hi, my name is Jacinto.

I have a question. i do add an device scanning on my smartthings hub, but it does not show the device Web Requestor and i have it on the channel and edge driver install.

Thanks for your response.

First, be sure you have this driver:

Web Requestor Multi v1.2
Version 2023-01-17T16:50:07.623400032

Then after youā€™ve done the Add device / Scan for nearby devices, be sure youā€™ve checked all your rooms for the new device - it should be in whatever room your SmartThings hub device is in.

@TAustin Iā€™ve currently got your Web Requestor driver set up and working correctly to start and stop an HTTP device (Hue Sync Box but thatā€™s not relevant). I am trying to configure the same using the HTTP Devices driver but running in to a problem I canā€™t resolve.

Hereā€™s the Settings for the ST device:

When I tap on (and off) I am getting this:

2024-02-20T21:38:18.067187488+00:00 TRACE HTTP Devices V1  Received event with handler capability
2024-02-20T21:38:18.103750321+00:00 INFO HTTP Devices V1  <Device: db0e572b-4d9d-4958-a9e1-5a3ac88e751c (HTTP Switch)> received command: {"args":{},"capability":"switch","command":"on","component":"main","positional_args":{}}
2024-02-20T21:38:18.209654405+00:00 TRACE HTTP Devices V1  Found CapabilityCommandDispatcher handler in thisDriver
2024-02-20T21:38:18.213652572+00:00 INFO HTTP Devices V1  Switch triggered:	on
2024-02-20T21:38:18.254148947+00:00 INFO HTTP Devices V1  <Device: db0e572b-4d9d-4958-a9e1-5a3ac88e751c (HTTP Switch)> emitting event: {"attribute_id":"switch","capability_id":"switch","component_id":"main","state":{"value":"on"}}
2024-02-20T21:38:18.270363405+00:00 INFO HTTP Devices V1  SEND PUT COMMAND: https://192.168.254.68/api/v1/execution
2024-02-20T21:38:18.283776155+00:00 INFO HTTP Devices V1  	with body: {"syncActive":true}
2024-02-20T21:38:18.288677072+00:00 INFO HTTP Devices V1  	with headers: Authorization=Bearer <redacted>
2024-02-20T21:38:18.296511780+00:00 DEBUG HTTP Devices V1  HTTP Switch device thread event handled
2024-02-20T21:38:18.300823238+00:00 ERROR HTTP Devices V1  HTTP Switch thread encountered error: [string "init.lua"]:227: attempt to index a nil value (global 'key')

Can you tell what I may doing wrong?

Hi. Let me review the code for that error and Iā€™ll get back to you.

BTW, do you have in device settings for HTTP Request URL Scheme set to ā€œSeparate State URLsā€?


UPDATE: It looks to be related to the header you have configured. How long is the bearer token and does it contain any special characters?

I do, yes.

Itā€™s 210 chars and it does have characters such as / = and .

Note it does work in the Web Requestor driver. At least I think it does. Iā€™m actually running in to some issues there now, I have a single Web Req device with slots 1 and 2 working yet slots 3 and 4 do not with the same info (getting a 401 error suggesting an issue with the token). And as a test I tried creating a new Web Requestor device and replicating the working code from slots 1 and 2 and that does not work either. That has me confounded. Slots 1 and 2 on the original Web Req device continue to work. I thought maybe a copy and paste error but I cannot see it.

Ok Iā€™ll try to reproduce the issue here.