I have a new Edge driver to share that provides the ability to issue POST and GET web requests to a specified URL. This functionality can help users that may today depend on webCoRE or other cloud-based means to do a similar task. Of course being an Edge driver it enables you to have fast & local automations.
There are two ways this driver can be used:
- Pre-configure up to 50 different POST/GET URL strings, which can then be individually triggered through Automations/Rules or via a button in the mobile app.
- Issue custom URL POST/GET commands from within a Rule
>>>>>UPDATE: Please go to this readme file for the latest instructions
Limitations
- Although GET method is supported, it currently does not actually do anything with the returned data from the server. I’m open to ideas here on how to expand this.
UPDATE: Enhancements made in new driver to better use response data; see post - The Edge platform limits communication to IP addresses on your local LAN only. So if you need to POST or GET to an internet URL, you’d have to run a bridging/forwarding server on a Raspberry Pi or similar. Message me if you need this; I have the bridging program available.
Instructions
- Use the link below to access my shared channel, enroll your hub, and select the ‘Web Requestor’ driver. (This is the same shared channel I used for my vEdge driver)
SmartThings. Add a little smartness to your things. - When the driver gets installed onto your hub (up to 12 hours), you can do an Add device / Scan nearby and a new device called ‘Web Requestor’ will be created in your ‘No room assigned’ room.
If you want to set up pre-configured web requests, do the following:
- Go to the device details screen of Web Requestor and go into device Settings by tapping the 3 vertical dots in the upper right corner of the screen. Here you can configure up to 50 web requests. The format must be:
POST:http://<ip:port/path> or GET:http://<ip:port/path> or
POST:https://<ip:port/path> or GET:https://<ip:port/path>
Notes regarding URL string:
- you must include a valid IP and port number; if you normally don’t include port number in other apps or a browser, use ‘:80’
- if your URL contains any spaces, use ‘%20’
Each request ‘slot’ has a default example string you can modify; note that any slot can be either POST or GET
- After you have saved some web requests, return to the device details screen and tap the button labeled ‘Select web request to execute’. Then select the corresponding request number and your web request will be sent.
- The send status will be displayed for about 3 seconds and then reset. Possible values are:
– OK: your request was sent and accepted by the server (HTTP 200 OK)
– Failed: the request could not be executed for any number of reasons, e.g. IP or port not found, timeout, socket error, etc.
– No HTTP response: no acknowledgement from server; it didn’t recognize the request
– HTTP error nnn - HTTP error number nnn was returned by the server
– Refused: connection was refused
– Not configured: the string in Settings hasn’t been properly configured or it is invalid or has a bad format - You can now create Automations or Rules to trigger your configured web requests.
If you want to specify a custom web request URL in a Rule, here is an example of how that would be done:
{
"name": "Test Web Requestor",
"actions": [
{
"if": {
"equals": {
"left": {
"device": {
"devices": [
"4c4f0e69-2542-4a05-83bf-1dfa0f0ccaad"
],
"component": "main",
"capability": "presenceSensor",
"attribute": "presence"
}
},
"right": {
"string": "present"
}
},
"then": [
{
"command": {
"devices": [
"3b70d48d-d458-472e-befd-e18afd173382"
],
"commands": [
{
"component": "main",
"capability": "partyvoice23922.webrequest",
"command": "GET",
"arguments": [
{
"string": "http://192.168.1.104:1755/tts_SCPD.xml"
}
]
}
]
}
}
]
}
}
]
}
Sadly there is a bug currently in Automations where command arguments can’t be provided (reported to SmartThings), so Rules are the only option until that gets fixed. UPDATE: I’m getting help from ST to find an alternative, so hopefully Automations will be also available for custom web requests soon…
Timeouts
There is currently a 3 second timeout set for all HTTP requests.
Acknowledgement
It’s important that I acknowledge @Alwas who provided the inspiration for this driver. His input and testing was essential for its creation. THANK YOU @Alwas!