설명 없음

Martijn Dierckx de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전
.gitignore bb6d4f6202 Upgrade to using Node 6 engine and removing babel prebuild processes 9 년 전
HydrawiseCommandException.js de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전
HydrawiseController.js de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전
HydrawiseZone.js de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전
README.md de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전
index.js de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전
package-lock.json de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전
package.json de326a8b2b v1.0.0: Rewrite + Added local API binding 5 년 전

README.md

Hydrawise API

Build Status

This is a client for the Hydrawise API. Hydrawise is an internet-controlled home irrigation system.

On a very basic level, it allows you to do:

For all possibilities, have a look at the inline code documentation

Getting started

When possible use a local connection to your controller since it's not rate limited (HTTP error 429) and suffers no delays when trying to run commands on zones.

Setup for a cloud connection

const Hydrawise = require('hydrawise-api');
const myHydrawise = Hydrawise({ type:'CLOUD', key:'YOUR_API_KEY' });

You can obtain your API key from the "Account Details" screen on the Hydrawise platform

Setup for a local connection

const Hydrawise = require('hydrawise-api');
const myHydrawise = Hydrawise({ type:'LOCAL', host:'HOSTNAME_OR_IP_ADDRESS', password:'YOUR_CONTROLLER_PASSWORD' });

You can also provide a user parameter, but this should be 'admin' in most cases.

Basic usage

Get Zones

Get all zones and see their status.

myHydrawise.getZones()
  .then(zones => console.log(zones))
  .catch(error => console.log(error));

This will return an array of HydrawiseZone objects containing the following info:

`{Number} relayID` - The unique relay number known to the Hydrawise cloud
`{Number} zone` - The local zone/relay number
`{String} name` - The name of the zone
`{Date} nextRunAt` - The date & time of the next scheduled run 
`{Number} nextRunDuration` - Run time in seconds of the next run defined by nextRunAt
`{Boolean} isSuspended` - Returns true when the zoneis currently suspended
`{Boolean} isRunning` - Returns true when the zone is actively running
`{Number} remainingRunningTime` - Remaining run time in seconds when isRunning = true

By default only the active zones are returned, you can change this behaviour by calling getZones(false) instead.

Run a command on a zone

You can execute a couple of basic commands on each zone: run(), suspend() or stop()

myHydrawise.getZones()
  .then(zones => {
    zone[0].run().then((info) => {
      console.log('success');
    }).catch(error => console.log(error));
  }).catch(error => console.log(error));

For the run & suspend commands you are able to provide a custom duration in seconds: run(600) (for 10 mins). If no custom duration was provided, the default run time configured for the zone will be used.

Zones can also be commanded directly from the Hydrawise object:

`myHydrawise.runZone(1)` - Run by local zone number (only. for local bindings)
`myHydrawise.runZone(123123)` - Run by unique relay ID (only. for cloud bindings)
`myHydrawise.runZone(myHydrawiseZoneObject)` - Run by the HydrawiseZone object returned by `getZones()`

Command all zones at once

It's also possible to command all zones at the same time:

myHydrawise.runAllZones()
  .then(info => {
     console.log('success');
  }).catch(error => console.log(error));

Here as well, you are able to provide a custom duration: runAllZones(600) (for 10 mins).


Contributors

  • Martijn Dierckx - Complete rewrite to service both the cloud & local API binding
  • Paul Molluzzo) - Initial 0.1.0 version containing the cloud binding

Tested on a configuration with a single HC6 controller. If you have multiple controllers in your configuration and you run into problems, you're free to create an issue or contribute yourself :-)

MIT license