lightworx Posted October 1 Share Posted October 1 Hi, I'm trying to control the Shelly Pro 2 relay using a Curl command as I want to prepare a .bat file to turn on and off the relay. I've used the command given in the Switch.set example down in the page. The command is: curl -X POST -d '{"id":1,"method":"Switch.Set","params":{"id":0,"on":true}}' http://${SHELLY}/rpc But I kept getting: curl: (3) URL rejected: Bad hostname I assume I need to add the IP address of the device somewhere, but since I have zero experience with Curl, everything I tried returned an error. I've tried to put the ip address after POST, and I got: curl: (7) Failed to connect to 192.168.1.51 port 443 after 2045 ms: Couldn't connect to server I googled the error and it mostly related to firewall, so I disabled the firewall and also made sure port 443 is enabled in & out, but still getting the same error. I've posted this on Reddit, and I was advised to replace ${SHELLY} with my ip. I did that and got 'invalid request' note that I'm able to control the relay using HTTP GET command from the browser, but I just need it to run from CMD. Any thoughts? Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
Heinz Posted October 1 Share Posted October 1 well for curl the command should be curl http://<SHELLY_IP>/relay/0?turn=on if you want it off then curl http://<SHELLY_IP>/relay/0?turn=off Toggle curl http://<SHELLY_IP>/relay/0?turn=toggle where the <SHELLY_IP> is that is what you should replace with the IP address of the device for a .bat file I made and tested this and worked @echo off curl http://<SHELLY_IP> /relay/0?turn=toggle pause Have a try and let me know if that helped Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
lightworx Posted October 2 Author Share Posted October 2 Thanks Heinz, Worked like a charm! not sure why it's not written that way in the Shelly documentation page. Appreciate it Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.