Commit c70021bb authored by Mike Hibler's avatar Mike Hibler

Double check that off commands are really effective

parent 689de108
......@@ -132,6 +132,41 @@ sub rpc27ctrl {
my $status;
for my $try (1..$ntries) {
$status = syncandsend($controller, $TIP, $command, undef);
#
# Double check that an off command really turned the outlet(s)
# off. We assume reliable power off in our security environment
# and we have seen cases where powering off doesn't.
#
if ($status == 0 && $cmd eq "off") {
my %stathash;
for my $stry (1..$ntries) {
$status = syncandsend($controller, $TIP, "status",
\%stathash);
last
if $status >= 0;
}
if ($status == 0) {
my @noutlets = ();
for my $o (split(",", $outlet)) {
if (!defined($stathash{"outlet$o"}) ||
$stathash{"outlet$o"} !~ /^off$/i) {
push(@noutlets, $o);
}
}
if (@noutlets != 0) {
$outlet = join(",", @noutlets);
$command = "$RPC27_CMD{$cmd} $outlet";
$status = -1;
if ($try == $ntries) {
print STDERR
"*** Failed to turn off $controller $outlet\n";
}
}
} elsif ($status > 0) {
print STDERR
"*** Post-off status command failed on $controller\n";
}
}
last
if $status >= 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment