true, 'data' => collect_snapshot(false), ]); } if ($command === 'fan') { $mode = (string)($argv[2] ?? 'auto'); $pwm = max(0, min(255, (int)($argv[3] ?? 120))); if (!in_array($mode, ['auto', 'manual', 'off'], true)) { touch_panel_json([ 'ok' => false, 'error' => 'bad_mode', ], 2); } set_control_state($mode, $pwm); add_fan_action( 'touch_panel_fan_set', $mode, $pwm, 'qt touch panel fan control', true ); touch_panel_json([ 'ok' => true, 'data' => collect_snapshot(false), ]); } touch_panel_json([ 'ok' => false, 'error' => 'unknown_command', ], 2); } catch (Throwable $e) { touch_panel_json([ 'ok' => false, 'error' => 'exception', 'message' => $e->getMessage(), ], 1); }