I’m looking to have a switch in my house execute an HTTP Post command when the switch is turned on or off. I have searched through a lot of threads and not found what i was hoping for.
Basically i have the backend automation done. The HTTP server handles what it needs to, but i’m looking to have smartthings be the Physical to Virtual interface.
So if i need to send a post to http://localhost:8080/toggle -on ’ ’ when the switch turns on and http://localhost:8080/toggle -off ’ ’ how would i do this? Ideally these would be CURL but i think JSON or regular POST would work.
My SmartApp Send Events to EventGhost does almost that - events in ST (switches, buttons, or several other things) are turned into HTTP GETs sent to a local web server via HTTP. The target server is a configuration item, but the format of the actual URL isn’t. If you need to customize the actual command issued you may need to modify the code. Still, it should be a useful starting point for you.
edit: to clarify a bit, when you deploy the SmartApp it will ask for a host, a port, a prefix, and then allows you to select one or more ST devices. If the host is “192.168.100.10”, port is “8080”, prefix is “ST”, and you’ve selected a device called “TestSwitchDevice”, the SmartApp will issue the following HTTP GET request when TestSwitchDevice is turned On: http://192.168.100.10:8080/?ST.TestSwitchDevice.switch.on
jjhtpc project is a good example. I used it as my starting point for my particle photon project. The following was called within a function to execute a post.