Skip to main content

sainsmart

PyPi Travis Build Documentation Status Updates Coverage Windows Build

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]

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.3.0 (2017-06-14)

  • add python 3.4 support

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.

Metadata

Release files for sainsmart 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sainsmart 0.3.1
File Size Uploaded Provenance Actions
sainsmart-0.3.1.tar.gz 14.9 kB Without provenance Details for sainsmart-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sainsmart 0.3.1
File Interpreter ABI Platform Actions
sainsmart-0.3.1-py2.py3-none-any.whl Python 2, Python 3 none any Details for sainsmart-0.3.1-py2.py3-none-any.whl

Total release size: 20.9 kB

Release files / sainsmart-0.3.1.tar.gz

Download URL sainsmart-0.3.1.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
11fe83dc07f1a4dee3963ad4f9e3fd762279d9686991cb74665c3f0768913d49
BLAKE2b-256 checksum
How to use checksums
a77141011538adf851ebdb8e8cbcc53fd84f05ea9a502733936776c735a386c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / sainsmart-0.3.1-py2.py3-none-any.whl

Download URL sainsmart-0.3.1-py2.py3-none-any.whl
Size 6.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d91c21fc16bff4431d6ef0da119eea0adb536c1c8b9cf9300e115c2413a38d29
BLAKE2b-256 checksum
How to use checksums
3572ef04deb04c60b9ff1c8f221d4de0951b4a61870c59c5e32490e19e6acf60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for sainsmart 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page