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://api.codeclimate.com/v1/badges/a99a88d28ad37a79dbf6/maintainability :target: https://codeclimate.com/github/codeclimate/codeclimate/maintainability :alt: Maintainability
.. 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 their local LAN.
💧 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 <http://docs.python-requests.org/en/master/>
_ toaiohttp <https://aiohttp.readthedocs.io/en/stable/>
_ - Changes the entire library to use :code:
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
Regenmaschine starts within an
aiohttp <https://aiohttp.readthedocs.io/en/stable/>
_ :code: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())
A Regenmaschine :code:Client
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 scan from regenmaschine.errors import DiscoveryFailedError
try: client = scan(websession) 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
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 regenmaschine-1.0.1.tar.gz
.
File metadata
- Download URL: regenmaschine-1.0.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3db48fdfa82a0cc39c5cae0e680e3dd4e0da8583471d1f5aa18feb58e4445e48 |
|
MD5 | ee80e46cd555464a84e477b68e8d55a2 |
|
BLAKE2b-256 | 26e1e1d5493a19e6772dbc748cdc846b552f3e543658959e34679202481604ab |
File details
Details for the file regenmaschine-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: regenmaschine-1.0.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7469a3b875a9ff4a98c9caef60f9a3f2d7f0545421ad6d1395f776ef63f35c8 |
|
MD5 | d6cc505f0c9506eb6674cffa8a45158d |
|
BLAKE2b-256 | 5f7d106f6900c9ef51c56815367054e1f05133b9b403fedc18e246baa416808e |