Struggling with a script on a 1PM Gen3.

Die Verwendung von Skripten liegt im eigenen Ermessen des Benutzers. Unterstützung für Skripte wird vom Autor des Skripts bereitgestellt.
  • I have a device on my network that allows me to turn it on and off via a web service and I would like to do that when the power reading on the shelly reaches zero. My issue is I keep getting an invalid request from the Shelly.call command. I was hoping someone could give me a suggestion.

    I was able to get a web call to work in Postman and also in Home Assistant using these parameters.

    Code
    url: "http://<INTERNAL_IP>/php/controls.php"
    method: POST
    payload: "makeup=false&filtration=false&iaq=false&whf=false&cooling=false&heating=false&heater=true&manual=false"
    content_type: "application/x-www-form-urlencoded"


    But when I translated that to a Shelly script I cannot seam to get it to work. Here is the script and output.


    ********** Output ************

    Code
    Makeup Air On
    Power: 13
    {"url":"http://<INTERNAL_IP>/php/controls.php","Content-Type":"application/x-www-form-urlencoded","body":"makeup=true&filtration
    =false&iaq=false&whf=false&cooling=false&heating=false&heater=true&manual=false"}
    processing response
    response.code : 200
    "\n\n\nInvalid request."


    If anyone can offer any insight/help it would be most appreciated.

  • The property for the content type in the HTTP.POST RPC is named content_type, not Content-Type - this could already be the solution for this:

    JavaScript
    let parms = {
          "url": "http://<INTERNAL_IP>/php/controls.php",
          "content_type":"application/x-www-form-urlencoded",
          "body": body
        };