Netio


NameNetio JSON
Version 1.0.13 PyPI version JSON
download
home_pagehttps://github.com/netioproducts/PyNetio
SummaryInterface to control NETIO Products devices
upload_time2023-09-21 15:26:00
maintainer
docs_urlNone
authorAdam Verner
requires_python>=3.11,<4.0
licenseMIT
keywords netio netio products power control power management power monitoring power metering power switching power switching device power switching devices power switching products power switching products
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Netio

python 3 Bindings and CLI for communication with NETIO Products devices

Install the latest package from pip
```bash
pip install Netio --upgrade
```
# API Interface

Login to your device and enable JSON API

![Configure Interface](docs/NetioIface.png)

Import Netio and create new instance with endpoint
```python
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](https://docs.digicert.com/manage-certificates/client-certificates-guide/manage-your-personal-id-certificate/windows-export-your-personal-id-certificate/) 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.
```pydocstring
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
```pydocstring
>>> 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
```pydocstring
>>> 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](examples/netio.example.ini)

## 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)
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/netioproducts/PyNetio",
    "name": "Netio",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11,<4.0",
    "maintainer_email": "",
    "keywords": "netio,netio products,power control,power management,power monitoring,power metering,power switching,power switching device,power switching devices,power switching products,power switching products",
    "author": "Adam Verner",
    "author_email": "averner@netio.eu",
    "download_url": "https://files.pythonhosted.org/packages/a1/a6/46e91a808cafa460e0f44e17f4ec5c7dc60f9f93fb977aa50d5090d6f1e7/netio-1.0.13.tar.gz",
    "platform": null,
    "description": "# Netio\n\npython 3 Bindings and CLI for communication with NETIO Products devices\n\nInstall the latest package from pip\n```bash\npip install Netio --upgrade\n```\n# API Interface\n\nLogin to your device and enable JSON API\n\n![Configure Interface](docs/NetioIface.png)\n\nImport Netio and create new instance with endpoint\n```python\nfrom Netio import Netio\n\nn = Netio('http://netio-4ll.local:8080/netio.json', auth_rw=('admin', 'password'))\n```\n\n## HTTPS\nWhen using HTTPS, you must provide correct certificate, or disable certificate verification altogether.\n\n 1. Under `Settings->Network Configuration` enter correct hostname and domain. \n 2. Goto `Settings->Security Settings` and select *Generate new certificate*\n 3. [Download](https://docs.digicert.com/manage-certificates/client-certificates-guide/manage-your-personal-id-certificate/windows-export-your-personal-id-certificate/) the certificate from your browser using browser\n\nIf you're accessing Netio wia IP address, set `verify=False` to disable certificate verification. \n\nFinally add `verify` parameter with path to downloaded certificate.\n```pydocstring\nn = Netio('http://netio-4ll.local:8080/netio.json', auth_rw=('admin', 'password'), verify='/path/to/cert.pem')\n```\n\n\n## Control\nto set the output use either action, or integer value\n```pydocstring\n>>> n.set_output(1, 0)            # Set output 1 off\n>>> n.set_output(1, n.ACTION.ON)  # Set output 1 on\n```\n\nTo read the states of the outputs\n```pydocstring\n>>> for x in range(4):\n>>>    print(n.get_output(x))\nOutput(ID=1, Name='out_1', State=1, Action=1, Delay=500, Current=0, PowerFactor=0.0, Load=0, Energy=13346833)\nOutput(ID=2, Name='out_2', State=0, Action=0, Delay=500, Current=0, PowerFactor=0.0, Load=0, Energy=2311032)\nOutput(ID=3, Name='out_3', State=1, Action=1, Delay=500, Current=8610, PowerFactor=1.0, Load=2062, Energy=11387035)\nOutput(ID=4, Name='out_4', State=1, Action=1, Delay=500, Current=11540, PowerFactor=1.0, Load=2768, Energy=21077736)\n```\n\n# CLI Interface\n```\nusage: Netio [-h] [-u U] [-p P] [-C] [-c CFG] [-v] [--no-cert-warning] [--version] DEVICE COMMAND ...\n\npositional arguments:\n  DEVICE                Netio device URL or alias from config\n  COMMAND               device command\n    get (GET, G, g)     GET output state\n    set (SET, S, s)     SET output state\n    info (INFO, I, i)   show device info\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -u U, --user U        M2M API username\n  -p P, --password P    M2M API password\n  -C, --cert            HTTPS Certificate\n  -c CFG, --config CFG  Configuration file\n  -v, --verbose         increase verbosity\n  --no-cert-warning     Disable warnings about certificate's subjectAltName versus commonName\n  --version             show program's version number and exit\n```\n\n## Commands\n\nNetio CLI supports 3 different commands, here are some examples about how to use them. \nFor more detailed description see `Netio device CMD --help`\n\n\n### GET\nPrints current state of outputs from device. Unless specified otherwise, all are returned\n\n```\n$ NETIO_PASSWORD=secretPass Netio -u read http://netio.local GET\nid      State   Action  Delay   Current PFactor Load    Energy  Name\n1       1       IGNORED 5000    0       0.0     0       2500    MyNetioOutput12\n2       1       IGNORED 5000    127     0.58    17      2363    output_2\n3       1       IGNORED 5000    0       0.0     0       0       output_3\n4       1       IGNORED 5000    0       0.0     0       1327    Notebook\n```\n\nBy default, the header with description is shown, it can be switched off with `--no-header`.\nDefault delimiter is tab, that can be changed with `--delimiter ';'` of `-d\\;`\n\n```\n$ NETIO_PASSWORD=secretPass Netio -u read http://netio.local GET --delimiter ';' --no-header\n1;1;IGNORED;5000;0;0.0;0;2500;MyNetioOutput12\n2;1;IGNORED;5000;79;0.49;9;2364;output_2\n3;1;IGNORED;5000;0;0.0;0;0;output_3\n4;1;IGNORED;5000;0;0.0;0;1327;Notebook\n```\n\nTo request single output just add positional argument with output ID\n\n```\n$ NETIO_PASSWORD=secretPass Netio -u read http://netio.local GET 2\nid      State   Action  Delay   Current PFactor Load    Energy  Name\n2       1       IGNORED 5000    80      0.49    9       2365    output_2\n```\n\n### SET\n\nSET takes positional argument pairs ID - ACTION. At least one pair has to be provided.\nNon zero value is returned when request does not succeed.\n\n```\n$ NETIO_PASSWORD=secretPass Netio -u write http://netio.local SET 1 ON 2 OFF 3 OFF\n$ echo $?\n0\n```\n\nTo set action of all outputs at once, use `ALL` as ID.\n\n```\n$ NETIO_PASSWORD=secretPass Netio -u write http://netio.local SET ALL TOGGLE\n```\n\n\n**Warning**: When toggling all outputs at once there is no delay in between, with high loads this can cause current\n spike\n and trigger your breakers.\n\n\n### INFO\nReports the state of the device\n\n```\n$ Netio -u write -p SecretPass http://netio.local INFO\nAgent\n   Model               NETIO 4All\n   Version             3.4.0\n   JSONVer             2.1\n   DeviceName          myNetio\n   VendorID            0\n   OemID               0\n   SerialNumber        24:A4:2C:33:27:78\n   Uptime              1456245\n   Time                2020-06-01T13:15:27+01:00\n   NumOutputs          4\nGlobalMeasure\n   Voltage             230.6\n   Frequency           49.9\n   TotalCurrent        85\n   OverallPowerFactor  0.51\n   TotalLoad           10\n   TotalEnergy         6195\n   EnergyStart         2020-03-31T06:38:11+01:00\n```\n\n## Configuration file\n \nYou can also use configuration file, specified wia `--config netio.ini` or wia `NETIO_CONFIG` environment variable.\nFor explanation and example of the file configuration see [examples](examples/netio.example.ini)\n\n## Credentials\n\nSpecifying credentials wia command line arguments is not prohibited, but it's advised against, \nas anyone on the system can see your username and password.\n\nYou can specify username and password either wia configuration file or wia Environmental variables\n\n - `NETIO_USER` for username.\n - `NETIO_PASSWORD` for password.\n\n\n### Parameter lookup\nwhen supplying for example password, it's looked up in this order:\n  1. command line argument\n  2. ENV variable\n  3. configuration file (if supplied)\n     1. special section\n     2. DEFAULT section\n  4. Default value (if applicable)",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Interface to control NETIO Products devices",
    "version": "1.0.13",
    "project_urls": {
        "Homepage": "https://github.com/netioproducts/PyNetio",
        "Repository": "https://github.com/netioproducts/PyNetio"
    },
    "split_keywords": [
        "netio",
        "netio products",
        "power control",
        "power management",
        "power monitoring",
        "power metering",
        "power switching",
        "power switching device",
        "power switching devices",
        "power switching products",
        "power switching products"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa7729fce0493b89f24acd6866be8c43ac0443e34f813d6eb6d7439a324458e3",
                "md5": "17e9507f35f84b380d023423e1ef685c",
                "sha256": "5d26ca4812482d01b52a7f3a785359f1b03646df7809d5e918c8c4290b79c5b9"
            },
            "downloads": -1,
            "filename": "netio-1.0.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "17e9507f35f84b380d023423e1ef685c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11,<4.0",
            "size": 11679,
            "upload_time": "2023-09-21T15:25:58",
            "upload_time_iso_8601": "2023-09-21T15:25:58.814101Z",
            "url": "https://files.pythonhosted.org/packages/fa/77/29fce0493b89f24acd6866be8c43ac0443e34f813d6eb6d7439a324458e3/netio-1.0.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a1a646e91a808cafa460e0f44e17f4ec5c7dc60f9f93fb977aa50d5090d6f1e7",
                "md5": "24aa1dba71e3f2d0cb96dbfc04c4a2f3",
                "sha256": "406e53795e0e08d78d376d5124f2c6f4398a7683e9f90a1dde7a1639849998a6"
            },
            "downloads": -1,
            "filename": "netio-1.0.13.tar.gz",
            "has_sig": false,
            "md5_digest": "24aa1dba71e3f2d0cb96dbfc04c4a2f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11,<4.0",
            "size": 10217,
            "upload_time": "2023-09-21T15:26:00",
            "upload_time_iso_8601": "2023-09-21T15:26:00.075829Z",
            "url": "https://files.pythonhosted.org/packages/a1/a6/46e91a808cafa460e0f44e17f4ec5c7dc60f9f93fb977aa50d5090d6f1e7/netio-1.0.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-21 15:26:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "netioproducts",
    "github_project": "PyNetio",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "netio"
}
        
Elapsed time: 0.23856s