A small Http modules example package
Project description
Python API for Numato HTTP Expanders
This Python API can be used to control Numato HTTP Relay expanders and Numato HTTP GPIO Pluggable expanders.
- Controlling the Relays "On" or "Off" state
- Configure ports as input or output port
- Write to output ports
- Read from input ports
- Read integer values from ADC input ports
numato-http allows to control relay modules (ON or OFF) states and gpio states. This module is compatible with all Numato ethernet pluggable and PoE series.
Requirement
The module requires the minimum configuration :
- Windows-10(64 bits) and later
- Linux 64-bits
- Python3.6 and later
License
This API is licensed under the GNU Lesser General Public License v3.0. See LICENSE for full license text.
Installation
Install the latest release:
pip install numato_http
Usage CLI
Expected output:
Linux :
❯ python3 -m numato_http.io --ip=<ip> --username=<username> --password=<password> --gpios=16
Ip: 192.168.10.5 | id: 00000000 | ver: A0M01.01 | ports: 16
Windows :
❯ python -m numato_http.io --ip=<ip> --username=<username> --password=<password> --gpios=16
Ip: 192.168.10.5 | id: 00000000 | ver: A0M01.01 | ports: 16
How to use it
The command line to drive relays are :
Windows :
python -m numato_http.io --ip=<ip> --username=<username> --password=<password> --cmd=<string to drive relays> --relays=8
Linux :
python3 -m numato_http.io --ip=<ip> --username=<username> --password=<password> --cmd=<string to drive relays> --relays=8
Note : For all CLI commands use python3 when using in Linux Systems and python in Windows Systems.
Parameters are :
--ip : the ip (default is 192.168.1.0) to connect the module
--username : the username (default is admin)
--password : the password (default is admin)
--cmd : the command to drive individual relays (default is "x")- the number of relays to drive (default is 4)
--relays : the number of relays to drive (default is 4)
--gpios : the number of gpios (default is 8, if the module is gpio module)
A relay can receive two types of orders (OFF or ON). The order in the module is encoding by an ASCII character such as :
"c" : close the relay (OFF state)
"o" : open the relay (ON state)
"x" : do not change the current state of the relay
For example consider a 8 channel PoE Relay module :
- 8 available relays : 0, 1, 2, 3, 4, 5, 6, 7 and 8
- ip is 192.168.10.5
- username and password is admin
command pattern examples for 8 channel PoE Relay module is given here,
To turn on all relays, string command is oooooooo and the command line is :
python -m numato_http.io --ip=192.168.10.5 --username=admin --password=admin --cmd="oooooooo" --relays=8
To turn off all relays, string command is cccccccc and the command line is :
python -m numato_http.io --deviceIP=192.168.10.5 --username=admin --password=admin --cmd="cccccccc" --relays=8
To turn on the relay 0,1,2,3 and it does not matter about other ones, string command is ooooxxxx and the command line is :
python -m numato_http.io --deviceIP=192.168.10.5 --username=admin --password=admin --cmd="ooooxxxx" --relays=8
To turn on the relays 1, 3, 5 and 7 and it does not matter about other ones, string command is xoxoxoxo and the command line is :
python -m numato_http.io --deviceIP=192.168.10.5 --username=admin --password=admin --cmd="xoxoxoxo" --relays=8
Note : There is no CLI command to control gpios.
List of Commands
- ver()
- info()
- idget()
- usrget()
- passget()
- id("x")
- settings("x","x")
- reset()
- relay_on("x")
- relay_off("x")
- relay_read("x")
- relay_readall()
- relay_writeall("x")
- gpio_set("x")
- gpio_clear("x")
- gpio_read("x")
- gpio_status("x")
- gpio_iomask("x")
- gpio_iodir("x")
- gpio_writeall("x")
- gpio_readall()
- adc_read()
- modulereboot()
Note: "x" is the parameter to be passed in the commands, please refer the "HTTP Command set" in the documentation for sending the right arguement and to understand the functioning of each command. Relay commands and some of the gpio commands are module specific.
Usage API
The API can be used like:
from numato_http.io import Http_Module
# Please change the number of Relays/Gpios and credentials (ipaddress, username, password) accordingly.
Device = Http_Module(ip="192.168.10.5", username="admin", password="admin", numberRelays=8)
# To get the version of the module
version = Device.ver()
print(version)
# To get the Device Id
Device.idget()
#To set the Id
Device.id("12345678")
# To turn on all relays
Device.relay_writeall("fF")
# To set a single Gpio & read the status
Device.gpio_set("000")
Device.gpio_read("000")
Device.gpio_clear("000")
Device.gpio_status("000")
#To turn on a single relay
Device.relay_on("006")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file numato_http-0.0.1.tar.gz.
File metadata
- Download URL: numato_http-0.0.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a8a0056256bd1092b91cbafa9a00fd5042d8042746aa07063762309839ff05c
|
|
| MD5 |
ed8e5a8a65ee913dec7a7189aa2d8a75
|
|
| BLAKE2b-256 |
917eb0ed17408c4303b704e2494892c8bd8d9cddc15730e9045abbe3bea7a8d9
|
File details
Details for the file numato_http-0.0.1-py3-none-any.whl.
File metadata
- Download URL: numato_http-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ddcc56884e0638ef4586ac5042067a20f9460a6e1c61167c5d742fe4ce0e997
|
|
| MD5 |
c67ac8016683e700eaf8b3bd4831f7ec
|
|
| BLAKE2b-256 |
c0d76cdb96c62836e04b45ffbe7cfda6fd81e826ad7633310fa36a109e49ab29
|