No internet connection
  1. Home
  2. How to

Surgex power conditioner control

By Sreejesh Nair @Sreejesh_Nair
    2025-02-06 09:08:32.175Z

    Hi. I have a Surgex defender series+ power conditioner that can be controlled over network using api.

    https://www.ametekesp.de/-/media/ametekesp/downloads/manuals/squid/api-definition-squid-rev-b.pdf

    This is the documentation for that. I’m looking to get. Way to get status of a power outlet and toggle its power using SoundFlow. I’m not very knowledgeable on using rest api. Is it possible to do this from SoundFlow based on the above documentation?

    Solved in post #6, click to view
    • 6 replies
    1. D
      danielkassulke @danielkassulke
        2025-02-06 09:24:39.050Z

        oooooh if possible, would love to see this turned into a vid - i am also a bit uncertain on how to implement REST APIs

        1. In reply toSreejesh_Nair:
          Kitch Membery @Kitch2025-02-06 20:20:41.818Z

          Hi @Sreejesh_Nair & @danielkassulke,

          I have a good example I can walk you through in a video early next week of how to use Rest API's. :-)

          Rock on!

          1. In reply toSreejesh_Nair:
            Kitch Membery @Kitch2025-02-07 21:15:07.343Z

            Hi @Sreejesh_Nair

            Unfortunately, I don't have a Surgex power conditioner to provide an exact solution for you, but hopefully, my demonstration of how I control my Elgato Key Lights using the REST APIs "GET" and "PUT" methods will help you work it out.

            Here is a video. :-)

            FYI: the documentation you provided shows that authorization may need to be provided in the URL to allow the outlets to be controlled.

            Here is the final script from the video...

            const keyLightLeftIpAddress = "192.168.1.216";
            const keyLightRightIpAddress = "192.168.1.217";
            
            function getKeyLightInfo(ipAddress) {
                const info = sf.net.httpRequest({
                    method: "GET",
                    url: `http://${ipAddress}:9123/elgato/lights`,
                }).asJson();
            
                return info;
            }
            
            function setKeyLightInfo({ ipAddress, data }) {
                sf.net.httpRequest({
                    method: "PUT",
                    url: `http://${ipAddress}:9123/elgato/lights`,
                    data
                });
            }
            
            const oldKeyLightInfo = getKeyLightInfo(keyLightLeftIpAddress);
            
            const newKeyLightInfo = { ...oldKeyLightInfo };
            
            newKeyLightInfo.lights[0].on = newKeyLightInfo.lights[0].on === 1 ? 0 : 1;
            
            setKeyLightInfo({
                ipAddress: keyLightLeftIpAddress,
                data: newKeyLightInfo,
            });
            
            setKeyLightInfo({
                ipAddress: keyLightRightIpAddress,
                data: newKeyLightInfo,
            });
            

            I hope that helps. Let me know if you have any questions. :-)
            Rock on!

            CC @danielkassulke

            1. SSreejesh Nair @Sreejesh_Nair
                2025-02-08 04:41:04.840Z

                Thank you!! I’ll definitely use this idea and go ahead.

              • S
                In reply toSreejesh_Nair:
                Sreejesh Nair @Sreejesh_Nair
                  2025-03-28 08:02:51.050Z

                  @Kitch the below code is what worked for me finally! Thanks a lot for your video! The base64 hash of the username password can be obtained by running the below in terminal

                  echo -n "username:password" | base64
                  

                  Code:

                  const ipAddress1 = "your_surgex_ip_address";
                  const outletID = 1;
                  const outlet = 1
                  const auth = "base64hash of your username password"; 
                  
                  //This has 8 ports to control
                  for (let outlet = 1; outlet <= 8; outlet++) {
                      const response = sf.net.httpRequest({
                          method: "POST",
                          url: `http://${ipAddress1}:80/api/v1/${outletID}/${outlet}/PowerOff`,
                          headers: {
                              Authorization: `Basic ${auth}`,
                          },
                          contentType: "Json",
                          data: {},
                  
                      });
                      const success = response.success
                      const error = response.error
                      if (success) log(`Outlet ${outlet}: Success`)
                      else log(`Outlet ${outlet}; Failed - Error: ${error}`)
                  }
                  
                  Reply1 LikeSolution
                  1. Kitch Membery @Kitch2025-03-28 17:06:34.863Z

                    Wonderful! I'm glad you got it working @Sreejesh_Nair!