Skip to content

Commit

Permalink
Improve logging, include event_id in TriggerOff
Browse files Browse the repository at this point in the history
  • Loading branch information
IPC committed Oct 1, 2024
1 parent 8592187 commit df5f76f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions web/ajax/trigger.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,28 @@
}
$monitor->TriggerEventOn($score, $cause, $text);
if ($showtext) $monitor->TriggerShowtext($showtext);
ZM\Info("Trigger '$action' '$cause'");
ZM\Info("Trigger action:'$action' cause:'$cause'");

# Because we aren't a persistent daemon here, we can't handle delays
#if ( $delay ) {
#my $action_text = $id.'|cancel';
#handleDelay($delay, $connection, $action_text);
#}
} else if ($action == 'off') {
$last_event = $monitor->GetLastEvent();
$last_event_id = $monitor->GetLastEventId();
$monitor->TriggerEventOff();
if ($showtext) $monitor->TriggerShowtext($showtext);
ZM\Info("Trigger '$action'");
# Wait til it's finished
while ($monitor->InAlarm() && ($last_event == $monitor->GetLastEventId())) {
while ($monitor->InAlarm() && ($last_event_id == $monitor->GetLastEventId())) {
# Tenth of a second
usleep(100000);
}
$monitor->TriggerEventCancel();
ajaxResponse(['event_id'=>$last_event_id]);
} else {
ZM\Warning("Invalid action $action");
ajaxError("Invalid action $action");
}

ajaxResponse();
Expand Down

0 comments on commit df5f76f

Please sign in to comment.