A simple API for RainMachine sprinkler controllers
Project description
💧 Regenmaschine: A Simple Python Library for RainMachine™
regenmaschine
(German for "rain machine") is a simple, clean, well-tested Python
library for interacting with
RainMachine™ smart sprinkler controllers.
It gives developers an easy API to manage their
controllers over their local LAN.
PLEASE READ: Version 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
pip install regenmaschine
Example
regenmaschine
starts within an
aiohttp ClientSession
:
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:
# YOUR CODE HERE
asyncio.get_event_loop().run_until_complete(main())
A regenmaschine
Client
can be created manually:
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:
client = Client('192.168.1.100', websession, port=9999)
asyncio.get_event_loop().run_until_complete(main())
...or you can attempt to discover one on your local network:
import asyncio
from aiohttp import ClientSession
from regenmaschine import Client, scan
from regenmaschine.errors import DiscoveryFailedError
async def main() -> None:
"""Create the aiohttp session and run the example."""
async with ClientSession() as websession:
try:
client = scan(websession)
except DiscoveryFailedError:
print("Couldn't find a valid RainMachine unit via discovery")
asyncio.get_event_loop().run_until_complete(main())
Once you have a client, authenticate it by using your RainMachine password and get to work:
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:
client = Client('192.168.1.100', websession, port=9999)
# Authenticate using your password:
await client.authenticate('my_password_123')
# Print some client properties:
print('Name: {0}'.format(client.name))
print('Host: {0}'.format(client.host))
print('MAC Address: {0}'.format(client.mac))
# 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:
await client.programs.start(1)
await 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 = await client.stats.upcoming(details=True):
# Get info on various watering activities not already covered:
log_2_day = await 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()
asyncio.get_event_loop().run_until_complete(main())
Check out example.py
, the tests, and the source files themselves for method
signatures and more examples.
Contributing
- Check for open features/bugs or initiate a discussion on one.
- Fork the repository.
- Install the dev environment:
make init
. - Enter the virtual environment:
pipenv shell
- Code your new feature or bug fix.
- Write a test that covers your new functionality.
- Run tests and ensure 100% code coverage:
make coverage
- Add yourself to
AUTHORS.md
. - 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.3.tar.gz
.
File metadata
- Download URL: regenmaschine-1.0.3.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 123e69e8b889040bba4c7652321f0ac867d13bd3fb6444edc69b4a6be20bf4cd |
|
MD5 | 688b22d09c4fc30378bcb1a3f2214d29 |
|
BLAKE2b-256 | 25bd8d6fec944b91ba107b430fe5b8783bd4b60f62c4eb7b9096c0199a4d49bc |
File details
Details for the file regenmaschine-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: regenmaschine-1.0.3-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eb504f7c4c7f3c85f3afdb91d8ec8666db79f9db68375627e4e6c6ddbafc67c |
|
MD5 | 65e8ee22a1398a0d285d17e8a12bc55e |
|
BLAKE2b-256 | 74fce9d5f081aef9df791a967c8101cc15ffb9b9fdadaab5574d1f522006556b |