Mechanical stresses upon hydrogen induced optical switching in thin films