WASHINGTON (AP) _ What is it they say about ''the best laid plans?'' The power outage in Washington is another illustration that they don't always work.

Millions have been spent on new security devices at major public buildings around Washington in the past year, enough to frustrate any terrorist planning an attack.

That is, when they are working.

They didn't work at the U.S. Capitol on Tuesday because the power was out for more than an hour, and all those complex metal detectors and X-ray machines at the building entrances depend on electric power.

The Senate met under the dim light of a single electric bulb connected to emergency power. The session was called to order not by a bell, but by a clerk banging on a waste basket. It was almost like the old days; so was the security, which is not connected to emergency power.

The government's security forces are taking prudent steps to prevent terrorism, even though such attacks within the borders of the United States have been virtually non-existent, compared with most nations.

The most serious terrorist acts in Washington in the last 40 years were the attempt by Puerto Rican pro-independence terrorists to assassinate President Truman in 1950 at Blair House and their shooting attack on Congress from a House balcony in 1954 in which five congressmen were injured.

The last major terrorist attack in Washington was the bomb that exploded near the Senate chamber in November 1983. There was major damage, but no injuries. That attack brought a new set of security devices.

There was a major terrorist scare in 1982 when the Reagan administration said Libyan leader Moammar Khadafy had sent hit squads to assassinate U.S. officials. Sketches of the would-be assassins were even posted at border installations. But the threat proved to be a hoax.

Fear of terrorists in the wake of the American experience in Lebanon has caused the authorities to surround White House and State Department entrances with imposing cement barricades. Security officials also have given consideration to closing off Pennsylvania Avenue in front of the White House. Earlier this year, traffic was barred from near the Capitol.

But the security measures are not impenetrable.

In June, for example, a man with a rifle walked past State Department security guards and went to the seventh floor where he shot and killed his mother, a secretary working just a few dozen yards from the office of Secretary of State George P. Shultz - while Shultz was there. The young man then shot himself.

On Jan. 20 of this year, Inauguration Day, 45-year-old Robert Latta walked into the White House with members of the U.S. Marine Orchestra, despite extreme security, and wandered around the floor just below the Reagans' living quarters before he was spotted.

In 1983, despite all sorts of measures aimed at curbing spies and foreign intelligence operations, a filing cabinet full of Shultz' current and top- secret papers was accidentally taken by movers to a nearby prison. Although months went by, the State Department didn't even know the cabinet was missing until the papers turned up in the hands of inmates.

Reagan was shot in 1981 at a Washington hotel, not by a terrorist, but by a deranged youth.

On occasion, the security appears sorely misdirected and even ludicrous. For example, during Reagan's 1984 trip to China, American reporters accompanying him were required by U.S. Secret Service agents to walk thorugh metal detectors everytime they came near to a function attended by Reagan.

But in the world's largest communist nation, with a population of more than one billion, the Chinese were never checked.

At the Capitol, reporters and the public are required to pass through metal detectors before entering the building. Employees are not. But even though metal detectors weren't working during the power outage, reporters were admitted just the same, although the public was not.

---

EDITOR'S NOTE - R. Gregory Nokes writes on diplomatic affairs and security issues for The Associated Press.