Mesoporous Bragg stacks are able to change color upon infiltration or displacement of liquid compounds inside their porous structure. Reversible switching from transparency to coloration offers additional functionality. Based on Bruggeman's effective medium theory, we derive a transparency master equation, which is valid for bilayers of arbitrary host materials and pore-filling compounds. The transparency condition fixes pore volume fractions such that the effective refractive index is homogenized through the bilayer, hence, through arbitrary layered optical media built from this bilayer. This general concept is applied to the case of switching of hygrochromic coatings made of mesoporous mixed oxide Bragg stacks.