Welcome to Hydrawiser’s documentation!

This is a Python 2 and 3 library for controlling the Hunter (https://www.hunterindustries.com) Pro-HC sprinkler controller.

Warning

Note that this project has no official relationship to Hunter Industries. It was developed using the Hydrawise API (https://support.hydrawise.com/hc/en-us/article_attachments/205632298/Hydrawise_API.pdf). Use at your own risk.

Note

Hydrawise Youtube video: https://youtu.be/raOEK8JjSUA
Hydrawise official site: https://hydrawise.com
Project documentation: https://hydrawiser.readthedocs.io

Usage

The following are examples for using the Hydrawiser library.

from hydrawiser.core import Hydrawiser

# Register with a hydrawise account to obtain an API key.
hw = Hydrawiser('0000-1111-2222-3333')

# List all the controller information.
hw.controller_info
{'boc_topology_desired': {'boc_gateways': []}, . . . .

# Get the controller status.
hw.status
'All good!'

# Get the name of the controller.
hw.name
'Home Controller'

# Get information about the relays on this controller.
hw.relays
[{'relay_id': 987654, 'relay': 1, 'name': 'yard', . . . .

# Get the number of relays on this controller.
hw.num_relays
6

# You can index a specific relay information.
hw.relays[2]  # Return information for the 3rd relay. Relays is zero indexed.

# Get the name of the 1st relay.
hw.relay_info[0, 'name')
'Back yard'

# Suspend all relays for 60 days.
hw.suspend_zone(60)

# Suspend relay 3 for 2 days.
hw.suspend_zone(2, 3)

# Stop all relays.
hw.run_zone(0)

# Run all relays for 15 minutes.
hw.run_zone(15)

# Run relay 5 for 10 minutes.
hw.run_zone(10, 5)

# Refresh the controller attributes.
hw.update_controller_info()

# Test to see if a zone is running.
hw.is_zone_running(3)
True

hw.time_remaining(3)
247

Limitations

  • Only one controller is supported

Developing

hydrawiser package

Submodules

hydrawiser.core module

This is the main library file. It contains the Hydrawiser object, and its methods. To use this library import it, and create an object using the api key for your controller.

See the README.md file for more details on the methods and attributes available.

class hydrawiser.core.Hydrawiser(user_token)[source]

Bases: object

Parameters:user_token (string) – User account API key
Returns:Hydrawiser object.
Return type:object
controller()[source]

Check if multiple controllers are connected.

Returns:Return the controller_id of the active controller.
Return type:string
is_zone_running(zone)[source]

Returns the state of the specified zone.

Parameters:zone (int) – The zone to check.
Returns:Returns True if the zone is currently running, otherwise returns False if the zone is not running.
Return type:boolean
list_running_zones()[source]

Returns the currently active relay.

Returns:Returns the running relay number or None if no relays are active.
Return type:string
relay_info(relay, attribute=None)[source]

Return information about a relay.

Parameters:
  • relay (int) – The relay being queried.
  • attribute (string or None) – The attribute being queried, or all attributes for that relay if None is specified.
Returns:

The attribute being queried or None if not found.

Return type:

string or int

run_zone(minutes, zone=None)[source]

Run or stop a zone or all zones for an amount of time.

Parameters:
  • minutes (int) – The number of minutes to run.
  • zone (int or None) – The zone number to run. If no zone is specified then run all zones.
Returns:

The response from set_zones() or None if there was an error.

Return type:

None or string

suspend_zone(days, zone=None)[source]

Suspend or unsuspend a zone or all zones for an amount of time.

Parameters:
  • days (int) – Number of days to suspend the zone(s)
  • zone (int or None) – The zone to suspend. If no zone is specified then suspend all zones
Returns:

The response from set_zones() or None if there was an error.

Return type:

None or string

time_remaining(zone)[source]

Returns the amount of watering time left in seconds.

Parameters:zone (int) – The zone to check.
Returns:If the zone is not running returns 0. If the zone doesn’t exist returns None. Otherwise returns number of seconds left in the watering cycle.
Return type:None or seconds left in the waterting cycle.
update_controller_info()[source]

Pulls controller information.

Returns:True if successfull, otherwise False.
Return type:boolean

hydrawiser.helpers module

Helper functions to query and send commands to the controller.

hydrawiser.helpers.customer_details(token)[source]

Returns the json string from the Hydrawise server after calling customerdetails.php.

Parameters:token (string) – The users API token.
Returns:The response from the controller. If there was an error returns None.
Return type:string or None.
hydrawiser.helpers.set_zones(token, action, relay=None, time=None)[source]

Controls the zone relays to turn sprinklers on and off.

Parameters:
  • token (string) – The users API token.
  • action (string) – The action to perform. Available actions are: run, runall, stop, stopall, suspend, and suspendall.
  • relay (int or None) – The zone to take action on. If no zone is specified then the action will be on all zones.
  • time (int or None) – The number of seconds to run or unix epoch time to suspend.
Returns:

The response from the controller. If there was an error returns None.

Return type:

string or None

hydrawiser.helpers.status_schedule(token)[source]

Returns the json string from the Hydrawise server after calling statusschedule.php.

Parameters:token (string) – The users API token.
Returns:The response from the controller. If there was an error returns None.
Return type:string or None

Module contents

Copyright (c) 2018 David Ryan

Python library for interfacting with Hunter Industries, Inc. Hydrawise HC and Pro-HC sprinkler controllers.

Indices and tables