Zigbee non-reliability

I have a very simple piece of code that turns on and off multiple lights
switchA.on()
or off()

And much of the time the three lights associated with switchA do turn on and off. But not always. Is this an intrinsic problem with the Zigbee protocol? Can I program around it?

I have absolutely no issues with my Hues or GE Links from the Hue bridge’s API, or the Hue apps, and this is the way I prefer to control them.

How far are they from your hub? Is this a communication issue?

At very list it’s an issue with a nonresilient protocol. I have other issues with Hue as it will tell me that a bubl which is not plugged is shining brightly.