Skip to main content

Interface to control NETIO Products devices

Project description

Netio

python 3 Bindings and CLI for communication with NETIO Products devices

Install the latest package from pip

pip install Netio --upgrade

API Interface

Login to your device and enable JSON API

Configure Interface

Import Netio and create new instance with endpoint

from Netio import Netio

n = Netio('http://netio-4ll.local:8080/netio.json', auth_rw=('admin', 'password'))

HTTPS

When using HTTPS, you must provide correct certificate, or disable certificate verification altogether.

  1. Under Settings->Network Configuration enter correct hostname and domain.
  2. Goto Settings->Security Settings and select Generate new certificate
  3. Download the certificate from your browser using browser

If you're accessing Netio wia IP address, set verify=False to disable certificate verification.

Finally add verify parameter with path to downloaded certificate.

n = Netio('http://netio-4ll.local:8080/netio.json', auth_rw=('admin', 'password'), verify='/path/to/cert.pem')

Control

to set the output use either action, or integer value

>>> n.set_output(1, 0)            # Set output 1 off
>>> n.set_output(1, n.ACTION.ON)  # Set output 1 on

To read the states of the outputs

>>> for x in range(4):
>>>    print(n.get_output(x))
Output(ID=1, Name='out_1', State=1, Action=1, Delay=500, Current=0, PowerFactor=0.0, Load=0, Energy=13346833)
Output(ID=2, Name='out_2', State=0, Action=0, Delay=500, Current=0, PowerFactor=0.0, Load=0, Energy=2311032)
Output(ID=3, Name='out_3', State=1, Action=1, Delay=500, Current=8610, PowerFactor=1.0, Load=2062, Energy=11387035)
Output(ID=4, Name='out_4', State=1, Action=1, Delay=500, Current=11540, PowerFactor=1.0, Load=2768, Energy=21077736)

CLI Interface

usage: Netio [-h] [-u U] [-p P] [-C] [-c CFG] [-v] [--no-cert-warning] [--version] DEVICE COMMAND ...

positional arguments:
  DEVICE                Netio device URL or alias from config
  COMMAND               device command
    get (GET, G, g)     GET output state
    set (SET, S, s)     SET output state
    info (INFO, I, i)   show device info

optional arguments:
  -h, --help            show this help message and exit
  -u U, --user U        M2M API username
  -p P, --password P    M2M API password
  -C, --cert            HTTPS Certificate
  -c CFG, --config CFG  Configuration file
  -v, --verbose         increase verbosity
  --no-cert-warning     Disable warnings about certificate's subjectAltName versus commonName
  --version             show program's version number and exit

Commands

Netio CLI supports 3 different commands, here are some examples about how to use them. For more detailed description see Netio device CMD --help

GET

Prints current state of outputs from device. Unless specified otherwise, all are returned

$ NETIO_PASSWORD=secretPass Netio -u read http://netio.local GET
id      State   Action  Delay   Current PFactor Load    Energy  Name
1       1       IGNORED 5000    0       0.0     0       2500    MyNetioOutput12
2       1       IGNORED 5000    127     0.58    17      2363    output_2
3       1       IGNORED 5000    0       0.0     0       0       output_3
4       1       IGNORED 5000    0       0.0     0       1327    Notebook

By default, the header with description is shown, it can be switched off with --no-header. Default delimiter is tab, that can be changed with --delimiter ';' of -d\;

$ NETIO_PASSWORD=secretPass Netio -u read http://netio.local GET --delimiter ';' --no-header
1;1;IGNORED;5000;0;0.0;0;2500;MyNetioOutput12
2;1;IGNORED;5000;79;0.49;9;2364;output_2
3;1;IGNORED;5000;0;0.0;0;0;output_3
4;1;IGNORED;5000;0;0.0;0;1327;Notebook

To request single output just add positional argument with output ID

$ NETIO_PASSWORD=secretPass Netio -u read http://netio.local GET 2
id      State   Action  Delay   Current PFactor Load    Energy  Name
2       1       IGNORED 5000    80      0.49    9       2365    output_2

SET

SET takes positional argument pairs ID - ACTION. At least one pair has to be provided. Non zero value is returned when request does not succeed.

$ NETIO_PASSWORD=secretPass Netio -u write http://netio.local SET 1 ON 2 OFF 3 OFF
$ echo $?
0

To set action of all outputs at once, use ALL as ID.

$ NETIO_PASSWORD=secretPass Netio -u write http://netio.local SET ALL TOGGLE

Warning: When toggling all outputs at once there is no delay in between, with high loads this can cause current spike and trigger your breakers.

INFO

Reports the state of the device

$ Netio -u write -p SecretPass http://netio.local INFO
Agent
   Model               NETIO 4All
   Version             3.4.0
   JSONVer             2.1
   DeviceName          myNetio
   VendorID            0
   OemID               0
   SerialNumber        24:A4:2C:33:27:78
   Uptime              1456245
   Time                2020-06-01T13:15:27+01:00
   NumOutputs          4
GlobalMeasure
   Voltage             230.6
   Frequency           49.9
   TotalCurrent        85
   OverallPowerFactor  0.51
   TotalLoad           10
   TotalEnergy         6195
   EnergyStart         2020-03-31T06:38:11+01:00

Configuration file

You can also use configuration file, specified wia --config netio.ini or wia NETIO_CONFIG environment variable. For explanation and example of the file configuration see examples

Credentials

Specifying credentials wia command line arguments is not prohibited, but it's advised against, as anyone on the system can see your username and password.

You can specify username and password either wia configuration file or wia Environmental variables

  • NETIO_USER for username.
  • NETIO_PASSWORD for password.

Parameter lookup

when supplying for example password, it's looked up in this order:

  1. command line argument
  2. ENV variable
  3. configuration file (if supplied)
    1. special section
    2. DEFAULT section
  4. Default value (if applicable)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netio-1.0.13.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

netio-1.0.13-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file netio-1.0.13.tar.gz.

File metadata

  • Download URL: netio-1.0.13.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/5.10.194-1-MANJARO

File hashes

Hashes for netio-1.0.13.tar.gz
Algorithm Hash digest
SHA256 406e53795e0e08d78d376d5124f2c6f4398a7683e9f90a1dde7a1639849998a6
MD5 24aa1dba71e3f2d0cb96dbfc04c4a2f3
BLAKE2b-256 a1a646e91a808cafa460e0f44e17f4ec5c7dc60f9f93fb977aa50d5090d6f1e7

See more details on using hashes here.

File details

Details for the file netio-1.0.13-py3-none-any.whl.

File metadata

  • Download URL: netio-1.0.13-py3-none-any.whl
  • Upload date:
  • Size: 11.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/5.10.194-1-MANJARO

File hashes

Hashes for netio-1.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 5d26ca4812482d01b52a7f3a785359f1b03646df7809d5e918c8c4290b79c5b9
MD5 17e9507f35f84b380d023423e1ef685c
BLAKE2b-256 fa7729fce0493b89f24acd6866be8c43ac0443e34f813d6eb6d7439a324458e3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page