Skip to main content

sainsmart contains code for working with sainsmart products.

Project description

sainsmart

https://img.shields.io/pypi/v/sainsmart.svg https://img.shields.io/travis/vicyap/sainsmart.svg Documentation Status Updates https://coveralls.io/repos/github/vicyap/sainsmart/badge.svg?branch=master

sainsmart contains code for working with sainsmart products.

Usage

To use EthernetRelay in a project:

from sainsmart import sainsmart

relay = sainsmart.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 sainsmart

relay = sainsmart.EthernetRelay('http://192.168.44.100/30000')

Example

Here is an example with a real device:

>>> from sainsmart import sainsmart
>>> relay = sainsmart.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.1.0 (2017-06-12)

  • First release on PyPI.

0.1.1 (2017-06-12)

  • Update usage and docs

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

sainsmart-0.1.2.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

sainsmart-0.1.2-py2.py3-none-any.whl (5.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file sainsmart-0.1.2.tar.gz.

File metadata

  • Download URL: sainsmart-0.1.2.tar.gz
  • Upload date:
  • Size: 21.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sainsmart-0.1.2.tar.gz
Algorithm Hash digest
SHA256 70e2f9c1fbd3b91d60dd50f8f647317d569ce1f8a29324f5b1f1b60ff9415170
MD5 ddad40b71a356e4cb5232f09d4c6915c
BLAKE2b-256 8fb3a0a2aac2129948c61ea1df67c05cbcdc2a4b3e03233017ff2a2498341b32

See more details on using hashes here.

File details

Details for the file sainsmart-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sainsmart-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 79fdbf9ab1068fdf484f84681d698bdcc674eec88efb6b20563d0c140b971192
MD5 44c06f0d724c2a4b11a98aeb53870c7c
BLAKE2b-256 8c31b7a181b8864b8e5eb779e1d434814d89461e6ba16782ee07d6f13bcb72ce

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