Tags: 
User library

AN37 shows how to create a .bat file to set the outputs of several NETIO devices using the PyNetio utility. JSON API, which is enabled by default, is used for the communication. AN37 incudes sample .bat files for various configurations of outputs.

 

Do you have any questions?

Supported devices: NETIO PowerPDU 4C, PowerPDU 4PS, PowerPDU 8QS, PowerBOX 3Px, PowerBOX 4Kx, PowerCable REST 101x, PowerDIN 4PZ

 

AN37 is typically used to change the scene in a recording studio, which involves changing the lighting, activating specific audio equipment, and so on. When an icon on the MS Windows desktop is clicked, a .bat file calls the PyNetio utility to set the outputs of all defined NETIO devices to the desired states.

The advantage of PyNetio is that it supports the JSON protocol, which is enabled by default in NETIO devices. The user does not need to configure the device in any way besides connecting it to the network.

For easier use, there is also a form for identifying individual NETIO devices. Use the following link to download the PyNetio.exe utility, the form and 3 sample .bat files that show how to toggle output 1, switch all outputs on, and switch all outputs off. All sample files use the default JSON configuration (port 80, username: netio, password: netio). The IP address of the NETIO device must be changed.

 

 

Enabling JSON API in the NETIO device

For NETIO devices with the default configuration, this section can be skipped.


In the web interface, go to M2M API Protocols - JSON API and check Enable JSON API to enable it. Optionally, the port can be changed using the Use custom M2M HTTP(S) port setting (the default is 80). Then, check Enable READ-WRITE and fill in the Username and the Password. These values will need to be entered in the control strings. Click Save Changes to save all the settings.


 

After saving, a green dot appears next to the JSON API tab (see the picture).

 

PyNetio utility

PyNetio.exe is a project at wiki.netio-products.com where it is available as a Python source code. Here it is available for download as a compiled .exe in a package for AN37.

After downloading, the PyNetio.exe file needs to be in the same folder with the .bat files that control the NETIO devices.

 

Caution: Some antivirus scanners regard PyNetio.exe as a potentially harmful file. In that case, configure an exception for PyNetio.exe or un-quarantine it in the antivirus software.


 

Creating a .bat file

A file with the .bat extension can be created using Notepad. The file contains one control command for each device.

 

For example:

PyNetio http://192.168.178.54:80 -u write -p jsonWRITE set 1 1 2 1 3 1 4 1

Switches on (sets to 1) outputs 1 to 4 at the NETIO device with IP address 192.168.178.54.

 

There can be multiple icons (.bat files) on the Windows desktop to set all local NETIO outputs to different desired combinations.

 

PyNetio - control commands

Commands have the following structure:

PyNetio http://<IP_ADDRESS>:PORT -u USERNAME -p PASSWORD COMMAND

 

  1. IP_ADRESS
  • IP address of the NETIO device
  • Example: 192.168.178.54
  1. PORT
  • Port number, as set in the M2M API Protocols section
  • If not specified, the default port (80) is used
  • Example (port 81): 192.168.178.54:81
  1. USERNAME
  • Username for READ-WRITE access, as set in the M2M API Protocols section
  • Example – if the username is “write”: -u write
  1. PASSWORD
  • Password for READ-WRITE access, as set in the M2M API Protocols section
  • Example – if the password is jsonWRITE: -p jsonWRITE
  1. COMMAND
  • Action to perform with the device’s outputs
  • Three commands are available: info, get, set
  • The set command controls the outputs
  • The set command must be followed by the number of the output and the number of the action to perform with that output
  • List of actions:
    • 0 - turns the output off
    • 1 - turns the output on
    • 2 - turns the output off for a short time and then on (Short Off)
    • 3 - turns the output on for a short time and then off (Short On)
    • 4 - toggles the output state (Toggle)
    • 5 - leaves the output state unchanged
  • Actions for multiple outputs can be specified in a sequence
  • Example – to turn off output 1 and turn on output 3: set 1 0 3 1

 

Examples of commands:.

Switch on output 1

PyNETIO http://192.168.178.54:81 -u write -p jsonWRITE set 1 1

 

Power-cycle outputs 2 and 4 (Short off)

PyNETIO http://192.168.178.54:81 -u write -p jsonWRITE set 2 2 4 2

 

Toggle the states of all outputs:

PyNETIO http://192.168.178.54:81 -u write -p jsonWRITE set 1 4 2 4 3 4 4 4

 

 

Saving the file

When saving the file, the .bat extension must be added (see the picture).

 

After saving, a file with the cogwheels icon appears in the folder. Double-click the file to activate the command (the PyNETIO file must be in the same folder).

 

FAQ:

  1. No command is executed when double-clicking the .bat file

Make sure that the folder with the .bat file also contains the PyNETIO.exe file. Also, the command format could be incorrect. Check the command syntax according to the PyNetio control commands section.
The IP address of the device could be incorrect, or the http JSON protocol disabled. Double-check the NETIO device settings.

 

  1. Is it possible to specify several commands with delays in between them in the .bat file?

Yes, delays can be inserted in between successive PyNETIO calls with the Windows timeout command.

 

Supported FW versions:

PowerPDU 4C - 3.3.1 and higher

PowerBOX 3Px, 4Kx - 3.1.3 and higher

PowerPDU 4PS, 8QS - 3.1.3 and higher

PowerDIN 4PZ - 3.1.3 and higher

 

Firmware archive

Ask for a price or technical parameters

For device testing use name/password demo/demo