Switch Automation Issue

I have a smart light switch that I made an automation that when it is turned on or off does the same to other lights nearby, this is working wonderfully but it has one problem that I can not figure out how to fix. When I turn it on or off in the HA Gui it runs the automation. Basically, I only want the automation to run when the physical switch is clicked but not when it is clicked through the HA GUI.

You need to check the context in a condition to determine if it was the physical switch. See: State.context to UI automation - #24 by mbuscher

I don’t quite understand how to do some of this stuff I see from what you gave. I am a new user to HA so I still don’t know all of the loopholes, can you give an explanation