Onmyodo was an office of state before it was anything else. The court established a Bureau of Yin and Yang, staffed by salaried officials responsible for the calendar, for astronomical observation, for timekeeping and for determining which days and directions were safe for the emperor and the aristocracy. Its practitioners were civil servants, and their work touched the daily conduct of the court continuously: journeys were rerouted, appointments deferred and buildings sited on their advice.
The most famous of them, Abe no Seimei, became a legendary figure within a century or two of his death and has remained one, appearing in tale collections, in theatre and in modern film and comics. The historical official is much harder to see behind the legend.
Hereditary control of the office consolidated in two families, one of them descended from Seimei, and the resulting lineage held authority over practitioners across the country into the early modern period, licensing them and taking a share of their fees.
The Meiji government abolished the whole apparatus in 1870, as part of the same programme of rationalisation that separated kami from buddhas. What had been a branch of government became, at a stroke, a private and somewhat disreputable practice.
It survives now in folk practice, in the almanac conventions of lucky and unlucky days that remain in ordinary Japanese use, and in an extensive popular culture that has made a courtier of the tenth century into a recurring hero.