Skip to main content

A simple API for RainMachine sprinkler controllers

Project description

💧 Regenmaschine: A Simple Python Library for RainMachine™

Travis CI PyPi Version License Code Coverage Maintainability Say Thanks

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.

Python Versions

regenmaschine is currently supported on:

  • Python 3.5
  • Python 3.6
  • Python 3.7

However, running the test suite currently requires Python 3.6 or higher; tests run on Python 3.5 will fail.

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())

To create a regenmaschine Client :

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 = await Client.authenticate_via_password(
        '192.168.1.100', '<PASSWORD'>, websession, port=8080, ssl=True)


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

Once you have a client, 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 = await Client.authenticate_via_password(
        '192.168.1.100', '<PASSWORD'>, websession, port=8080, ssl=True)

      # Print some client properties:
      print('Name: {0}'.format(client.name))
      print('Host: {0}'.format(client.host))
      print('MAC Address: {0}'.format(client.mac))
      print('API Version: {0}'.format(client.api_version))
      print('Software Version: {0}'.format(client.software_version))
      print('Hardware Version: {0}'.format(client.hardware_version))

      # 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

  1. Check for open features/bugs or initiate a discussion on one.
  2. Fork the repository.
  3. Install the dev environment: make init.
  4. Enter the virtual environment: pipenv shell
  5. Code your new feature or bug fix.
  6. Write a test that covers your new functionality.
  7. Update README.md with any new documentation.
  8. Run tests and ensure 100% code coverage: make coverage
  9. Ensure you have no linting errors: make lint
  10. Ensure you have no typed your code correctly: make typing
  11. Add yourself to AUTHORS.md.
  12. 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

regenmaschine-1.1.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

regenmaschine-1.1.0-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: regenmaschine-1.1.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for regenmaschine-1.1.0.tar.gz
Algorithm Hash digest
SHA256 73cbf08a38756f1db7e6963a1025bebb89c05d2e4913933078b6f9cfa2b9c3d0
MD5 00e8896e288aea1c30251d0fcc72d7df
BLAKE2b-256 155743946654481c915a545dfb328e4b943f7593874f6bd4d60d96d0bcb813b4

See more details on using hashes here.

File details

Details for the file regenmaschine-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: regenmaschine-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for regenmaschine-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95edf44ad2e15802ac2199298a9e94035c5f2ce72213e5d02dbf90b2b194d30e
MD5 a1b2e7fdee753a15dc9a34b8c4212a6d
BLAKE2b-256 e26fd69c048ebf1b093eafd04f9677d71cae121be29ef862bc9f64b6f5dd9b8d

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