A simple client to interact with the Rachio irrigation control system. See http://rachio.readme.io/v1.0/docs/.
This package is compliant with PSR-2 and PSR-4.
This SDK requires PHP >= 5.5.0.
The Rachio SDK may be installed through Composer.
composer require etelford/rachio
Make sure you're using Composer's autoload:
require_once('vendor/autoload.php');
First, import the class.
use ETelford\Rachio;
Next, create a new instance of Rachio
and pass in your API key.
$rachio = new Rachio('your-api-key');
With a Rachio
object created, you can do a number of things.
$id = $rachio->personId();
This is merely a more friendly way of retrieving the authorized user from a
Rachio
instance. It is identical to doing:
$rachio = new Rachio('your-api-key');
$id = $rachio->personId;
$person = $rachio->person();
$devices = $rachio->devices();
This method can accept a device id
.
$devices = $rachio->devices();
$device = $rachio->device($devices[0]->id);
Since many people will have just a single Rachio system, the SDK will automatically use the first device in your account if you don't pass an id.
$device = $rachio->device();
$schedule = $rachio->currentSchedule($deviceId);
Or, use the default device.
$schedule = $rachio->currentSchedule();
Note: If the Rachio system isn't running, this will return null
.
$schedule = $rachio->upcomingSchedule($deviceId);
Again, for the default device:
$schedule = $rachio->upcomingSchedule();