Script to change components

This is a section of a script that I think used to work but no longer does.

myLayers = Glyphs.font.selectedLayers
for layer in myLayers:
	pixelatedGlyph = False
	for component in layer.components:
		if in ["_pixel", "_part.smartPixel"]:
			pixelatedGlyph = True
			layer.color = 0 = "_pixel.multi"

/_pixel.multi is a glyph that contains four small circles instead of the one large circle in /_pixel and /_part.smartPixel.
After completing this part of the script, the selected glyph still shows one large circle for each component in the Edit view, even though if I select any of them the Show Info box shows it as “/_pixel.multi” (and in fact if I double click on it it opens up that multi glyph). In other words, the name is updated but the visual representation is not (and thus the decompose that comes right after doesn’t work right).
Is there some kind of update function I can build into the script to make sure the correct component gets operated on? Or is there a better scripting strategy for trading out component references?

Setting should work. Maybe you have some code that disables updates?

Can you run just this part of the script?

The script works as expected with components I add to the glyph using Add Components, but it does not work (error as described above) with components pasted from another Glyphs file.

I think maybe what was throwing Glyphs off was that the original referent was a smart component and the new one was not? Or pasting a smart component from a different file throws things off.