Last modified at 5/7/2014 6:45 PM by Koen Zomers

Gembird has a small range of products which allow you to control the electricity state of one or more sockets from your computer. For the creative software developer, this offers an unlimited variety of opportunities to control devices from your self written software. Some examples: I once wrote a MSN Messenger and SMS client to turn on the frying pan. Ideal when on the way home from a night out in the city and hungry for some snacks. I'm currently using it to turn on and off my wireless access point so that it will only consume electricity and be on the air when needed. This decreases the attack surface of your wireless network drastically and saves you money on your electricity bill. I can also control garden elements like lights and fountains from the device. As said, a creative mind will offer endless possibilites.

GembirdPowerManager.png

The default software delivered for the Gembird sockets offers a lot of functionality already. It delivers a small and easy application in which you already have a lot of functionality available like setting timers, switching sockets manually, switching sockets based on specific applications being started or stopped or on Windows being started or shut down.

GembirdPowerManagerSettings.png

Next to that, it also offers built in functionality to share the device over your local network so you can not only control it from one machine, but from multiple machines. Downside is that the machine to which the socket is physically connected via USB must always be on for this to work.

GembirdPowerManagerSharing.png

When your creativity exceeds all the features already offered by the standard software (which it does if you want to turn on your frying pan using an SMS like I did), you also have a command line tool available which you can call from your custom software. The exert from the help file describing this is as follows:


Command line interface

To let people switch the sockets from the user applications the following command line interface syntax is supported:
  • pm.exe -[on | off] -device name -socket name
Examples:
  • "C:\Program Files\Gembird\Power Manager\pm.exe" -on -SIS-PM -Socket1
  • "E:\Utils\PM3\pm.exe" -off -My SIS-PM -Table lamp
Execute pm.exe with -info key to get the complete information on current devices states. For each of the connected devices the following information is provided and available from Info.ini file in the PowerManager folder:
  • DeviceName - the user specified device name;
  • Socket#name, where # is replaced by a certain socket number - the user specified socket name;
  • Socket#SwitchState, where # is replaced by a certain socket number - TRUE, when the socket is switched on, FALSE, when the socket is switched off;
  • Socket#VoltageState, where # is replaced by a certain socket number - TRUE, when voltage presence on the socket is detected, FALSE, when there is no voltage on the socket;
Example:
  • pm.exe -info
Note: Each use of this command line option totally overrides the data in Info.ini file.
Note: Power Manager should be launched.


This allows for even further creative thoughts. One important thing that has not been added until the 3.1.1.5 version of the Gembird software is the addition of the pm.exe -info command which outputs the current power state of the sockets. It will output all socket statusses to an Info.ini file:

GembirdInfoIni.png

This would require more complex programming though as you would need to run the command, allow some time (matter of milliseconds) to pass for the Info.ini to be created, open a textreader and parse its contents.
There is an easier alternative available. A guy named Michael Berthold has created a small command line application that does not only allow turning the sockets on and off, but also allows getting the current status of particular sockets.

Since I can not find the application online anymore, but still have it since I'm using it for years already, I decided to write this article and bring it back into the internet. You can download it here:

SisPmCtlWin.exe (68 KB)

It explains itself:

GembirdSisPmCtlWin.png
Using a simple piece of C# .NET code you can trigger the command line application and catch the results via the errorlevels provided:
        /// <summary>
        /// Executes the PowerManager command with the provided arguments
        /// </summary>
        /// <param name="arguments">Arguments to pass to the PowerManager command</param>
        /// <returns>Exit code from the PowerManager command</returns>
        private static int ExecuteSocketCommand(string arguments)
        {
            // Create the new process
            var proc = new Process
            {
                EnableRaisingEvents = false,
                StartInfo =
                {
                    FileName = new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).Directory + "\\SisPmCtlWin.exe",
                    WindowStyle = ProcessWindowStyle.Hidden,
                    UseShellExecute = false,
                    Arguments = arguments
                }
            };

            // Execute the process
            proc.Start();
            proc.WaitForExit();

            // Return the exitcode from the process
            return proc.ExitCode;
        }

There are more tools like this available on the internet only to my findings none of them are this small and simple to use and all others require custom drivers to be installed which causes the Gembird application to no longer function. It is either use the custom tool OR the Gembird application. This tool, however, uses the default drivers and allows BOTH the Gembird AND the tool to be used at the same time. Only downside this tool has that it only supports one Gembird SIS-PMS to be connected to your machine via USB while the Gembird software itself supports multiple of these devices to be connected simultaneously.