Skip to main content

A simple API for RainMachine sprinkler controllers

Project description

💧 Regenmaschine: A Simple Python Library for RainMachine™

.. image:: https://travis-ci.org/bachya/regenmaschine.svg?branch=master :target: https://travis-ci.org/bachya/regenmaschine

.. image:: https://img.shields.io/pypi/v/regenmaschine.svg :target: https://pypi.python.org/pypi/regenmaschine

.. image:: https://img.shields.io/pypi/pyversions/Regenmaschine.svg :target: https://pypi.python.org/pypi/regenmaschine

.. image:: https://img.shields.io/pypi/l/Regenmaschine.svg :target: https://github.com/bachya/regenmaschine/blob/master/LICENSE

.. image:: https://codecov.io/gh/bachya/regenmaschine/branch/master/graph/badge.svg :target: https://codecov.io/gh/bachya/regenmaschine

.. image:: https://img.shields.io/codeclimate/github/bachya/regenmaschine.svg :target: https://codeclimate.com/github/bachya/regenmaschine

.. image:: https://img.shields.io/badge/SayThanks-!-1EAEDB.svg :target: https://saythanks.io/to/bachya

Regenmaschine (German for "rain machine") is a simple, clean, well-tested Python library for interacting with RainMachine™ smart sprinkler controllers <http://www.rainmachine.com/>_. It gives developers an easy API to manage their controllers over a LAN or via RainMachine™'s cloud.

💧 PLEASE READ: 1.0.0 and Beyond

Version 1.0.0 of Regenmaschine makes several breaking, but necessary changes:

  • Moves the underlying library from Requests to aiohttp
  • Changes the entire library to use asyncio
  • Makes 3.6 the minimum version of Python required

If you wish to continue using the previous, synchronous version of Regenmaschine, make sure to pin version 0.4.2.

💧 Installation

.. code-block:: bash

$ pip install regenmaschine

💧 Example

Every utilization of Regenmaschine starts within an aiohttp ClientSession:

.. code-block:: python

import asyncio

from aiohttp import ClientSession

from regenmaschine import Client

async def main() -> None: """Create the aiohttp session and run the example.""" async with ClientSession() as websession: await run(websession)

async def run(websession): """Run.""" # YOUR CODE HERE

asyncio.get_event_loop().run_until_complete(main())

Clients can be created manually:

.. code-block:: python

client = Client('192.168.1.100', websession, port=9999)

...or you can attempt to discover one on your local network:

.. code-block:: python

from regenmaschine import DiscoveryFailedError

try: client = Client('192.168.1.100', websession, port=9999) except DiscoveryFailedError: print("Couldn't find a valid RainMachine unit via discovery")

Once you have a client, authenticate it by using your RainMachine password:

.. code-block:: python

await client.authenticate('my_password_123')

You can now get some properties with your authenticated client:

.. code-block:: python

print('Name: {0}'.format(client.name)) print('Host: {0}'.format(client.host)) print('MAC Address: {0}'.format(client.mac))

...and get to work controlling your RainMachine!

.. code-block:: python

Get all diagnostic information:

diagnostics = await client.diagnostics.current()

Get all weather parsers:

parsers = await client.parsers.current():

Get all programs:

programs = await client.programs.all():

Get a specific program:

program_1 = await client.programs.get(1)

Get the next run time for all programs:

runs = await client.programs.next()

Get all running programs:

programs = await client.programs.running()

Start and stop a program:

client.programs.start(1) client.programs.stop(1)

Get the device name:

name = await client.provisioning.device_name

Get all provisioning settings:

settings = await client.provisioning.settings()

Get all networking info related to the device:

wifi = await client.provisioning.wifi()

Get various types of active watering restrictions:

current = await client.restrictions.current() universal = await client.restrictions.universal() hourly = await client.restrictions.hourly(): raindelay = await client.restrictions.raindelay()

Get watering stats:

today = await client.stats.on_date(date=datetime.date.today()) upcoming_days = client.stats.upcoming(details=True):

Get info on various watering activities not already covered:

log_2_day = client.watering.log(date=datetime.date.today(), 2): queue = await client.watering.queue() runs = await client.watering.runs(date=datetime.date.today())

Stop all watering activities:

await client.watering.stop_all()

Check out example.py, the tests, and the source files themselves for method signatures and more examples.

💧 Contributing

#. Check for open features/bugs <https://github.com/bachya/regenmaschine/issues>_ or initiate a discussion on one <https://github.com/bachya/regenmaschine/issues/new>. #. Fork the repository <https://github.com/bachya/regenmaschine/fork>. #. Install the dev environment: :code:make init. #. Enter the virtual environment: :code:pipenv shell #. Code your new feature or bug fix. #. Write a test that covers your new functionality. #. Run tests: :code:make test #. Build new docs: :code:make docs #. Add yourself to AUTHORS.rst. #. Submit a pull request!

Project details


Release history Release notifications | RSS feed

This version

1.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

regenmaschine-1.0.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

regenmaschine-1.0.0-py2-none-any.whl (12.8 kB view details)

Uploaded Python 2

File details

Details for the file regenmaschine-1.0.0.tar.gz.

File metadata

File hashes

Hashes for regenmaschine-1.0.0.tar.gz
Algorithm Hash digest
SHA256 edf1dea3c410632f47d94d6ed8b5f8eac49ae0b753f6f908c6618a0b11e5ff1b
MD5 196134a89ab71153f2c1ffb0425c9a97
BLAKE2b-256 95559fcc82c7075cc49b6d1b1035c1240f582aabfd38bf1ac30b6db75e5187c1

See more details on using hashes here.

File details

Details for the file regenmaschine-1.0.0-py2-none-any.whl.

File metadata

File hashes

Hashes for regenmaschine-1.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 11f1d0d8dc3297119141ed64df4e74f93847f33ddcc9dc06d51bf29bbcd780c4
MD5 a31cc5f06e86a9f1451344245821283b
BLAKE2b-256 a56146f2e30bd164bd430b09d57205d157b24cef48fcb02abb9ba42a21e6215d

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