I wrote a simple perl script to clean the filter. I could not find a way to control the pump relay with the ‘public’ API, so used the web API instead. If you have a similar issue (or any application that requires running a zone with the pump disabled), it should be easy to adapt this to your needs. On most local or cloud Linux servers, or on a Mac, the pre-installed perl should be compatible, without installing any prerequisites. On Windows, if you don’t have perl, a default installation from http://strawberryperl.com/ should be fine. Before running this script, edit the values of $user and $pass, as well as zones, duration, etc. as needed by your system. Let me know of any issues.
#!/usr/bin/perl
use LWP::UserAgent;
use JSON;
$user = 'rme@mydomain.com'; # replace with the email address for your Rachio account
$pass = 'sUper-s3cr3t'; # replace with your Rachio account password
$flushzone = 14; # zone connected to filter flush port
$dummyzone = 4; # zone with no irrigation valve, used to repressurize system
sub doreq { # print error and exit if request unsuccessful
my ($name, $resp) = @_;
return $resp->content if $resp->is_success;
my $err = $resp->content;
print "Request for $name failed: $err\n";
exit(1);
}
sub run1 { # args are pumpon (true or false), zone number, duration in seconds
my ($pumpon, $zone, $duration) = @_;
my $putdata = "{id: \"$devid\", master_valve: $pumpon, wellpump_delay_active: $pumpon}";
my $resp = doreq('pump on or off', $ua->put("$cfg->{API_URL}/device/updateIrrigationController",
'Authorization' => "Bearer $token", 'Content-Type' => 'application/json', 'Content' => $putdata));
return unless $duration;
$putdata = "{device_id: \"$devid\", runs: [{duration: $duration, zone_number: $zone}]}";
$resp = doreq('run zone', $ua->post("$cfg->{API_URL}/device/setManualSchedule",
'Authorization' => "Bearer $token", 'Content-Type' => 'application/json', 'Content' => $putdata));
sleep($duration + 5); # wait for completion
}
$ua = LWP::UserAgent->new();
#$ua->proxy(['http', 'https'], 'http://127.0.0.1:8888/');
# get config data
$cfg = decode_json(doreq('config', $ua->get('https://app.rach.io/env.json')));
# log in and get access token
$token = decode_json(doreq('login', $ua->post("$cfg->{AUTH_SERVICE_URL}/token",
[ 'grant_type' => 'password', 'username' => $user, 'password' => $pass,
'client_id' => $cfg->{CLIENT_ID}, 'client_secret' => $cfg->{CLIENT_SECRET} ])))->{access_token};
# get first device associated with this account
$devid = decode_json(doreq('device', $ua->get("$cfg->{API_URL}/location/listLocations/true", 'Authorization' => "Bearer $token")))
->{locationSummary}->[0]->{location}->{deviceId}->[0];
# do the real work
run1('true', $flushzone, 40); # run 'flush' zone to ensure pump is primed
for ($cnt = 0; $cnt < 3; ++$cnt) { # do 3 flush cycles
run1('false', $flushzone, 10); # backflush filter
run1('true', $dummyzone, 10); # repressurize
}