mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-06-23 04:59:37 -04:00
Add a CanLight control capability rendering a single status-aware Light toggle button. The ADC2W white light is driven via CoaxialControlIO.control (Type 1, numeric IO); the button queries live state and reflects it (amber when on). To get device state to the browser, add an opt-in two-way response path to the control protocol: zmcontrol writes a JSON result back only when a request sets wants_response (fire-and-forget commands unchanged, SIGPIPE-safe); Monitor::sendControlCommandWithResponse and ajax/control.php return it. Also adds get_config/set_config/probe to Dahua_RPC for characterising cameras, the CanLight column (migration zm_update-1.39.12.sql), edit-UI checkbox, and a config unit test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
34 lines
902 B
PHP
34 lines
902 B
PHP
<?php
|
|
require_once('includes/control_functions.php');
|
|
require_once('includes/Monitor.php');
|
|
|
|
// Monitor control actions, require a monitor id and control view permissions for that monitor
|
|
if ( empty($_REQUEST['id']) )
|
|
ajaxError('No monitor id supplied');
|
|
|
|
if ( canView('Control', $_REQUEST['id']) ) {
|
|
$monitor = new ZM\Monitor($_REQUEST['id']);
|
|
|
|
$ctrlCommand = buildControlCommand($monitor);
|
|
|
|
if ( !$ctrlCommand ) {
|
|
ajaxError('No command received');
|
|
return;
|
|
}
|
|
|
|
// Opt-in query: return the daemon's reply (e.g. light status) to the browser.
|
|
if ( !empty($_REQUEST['response']) ) {
|
|
ajaxResponse(array('status' => $monitor->sendControlCommandWithResponse($ctrlCommand)));
|
|
return;
|
|
}
|
|
|
|
if ( $monitor->sendControlCommand($ctrlCommand) ) {
|
|
ajaxResponse('Success');
|
|
} else {
|
|
ajaxError('Failed');
|
|
}
|
|
}
|
|
|
|
ajaxError('Unrecognised action or insufficient permissions');
|
|
?>
|