sainsmart contains code for working with sainsmart products.
Project description
sainsmart
sainsmart contains code for working with sainsmart products.
Install
pip install sainsmart
Usage
To use EthernetRelay in a project:
from sainsmart import devices relay = devices.EthernetRelay() # Access the state of the relays # relay.state() is a list of bools relay_state = relay.state() # Turn on the relay at index 0. relay.turn_on(0) # Turn off the relay at index 0. relay.turn_off(0) # Toggle the state of relay 0. relay.toggle(0) # Turn on all relays. relay.all_on() # Turn off all relays. relay.all_off()
The SainSmart Ethernet Relay defaults ip address: 192.168.1.4/30000. This can be changed through their web interface.
To use EthernetRelay with a different IP address:
from sainsmart import devices relay = devices.EthernetRelay('http://192.168.44.100/30000')
Example
Here is an example with a real device:
>>> from sainsmart import devices >>> relay = devices.EthernetRelay() >>> relay.state() [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] >>> relay.turn_on(0) >>> relay.state() [True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] >>> relay.toggle(0) >>> relay.state() [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False] >>> relay.all_on() >>> relay.state() [True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True] >>> relay.turn_off(0) >>> relay.state() [False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True] >>> relay.all_off() >>> relay.state() [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False]
Free software: MIT license
Documentation: https://sainsmart.readthedocs.io.
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.2.1 (2017-06-14)
add install section to README
fix coverage badge in README
0.2.0 (2017-06-14)
python2.7 support
renamed sainsmart.py to devices.py
0.1.1 (2017-06-12)
Update usage and docs
0.1.0 (2017-06-12)
First release on PyPI.
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
Built Distribution
File details
Details for the file sainsmart-0.2.1.tar.gz
.
File metadata
- Download URL: sainsmart-0.2.1.tar.gz
- Upload date:
- Size: 14.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8939ee29ffddcd47158adf8a5b1ecab27fa5f7738c32efb52303ca0d5a2888a |
|
MD5 | e3c504dfd8e90a4562da018b5eb8399d |
|
BLAKE2b-256 | dc3d407dc5343f02909ce687b86820c146d3d2b67efbbc9cc672cce570812ef7 |
File details
Details for the file sainsmart-0.2.1-py2.py3-none-any.whl
.
File metadata
- Download URL: sainsmart-0.2.1-py2.py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18af9cdc6dc8f65076c7cdf2badb9c82cca5821612c6a9525552b34e759151a8 |
|
MD5 | 0237399f65c65886be5c15d3dcdd3cc9 |
|
BLAKE2b-256 | 83f08638b3c7cc83f7b344b21370366c787f8f04a3c0f7e2e3b2caffe3b368e0 |