Ok, let me ask a couple of questions.
When connected to grid power everything works perfect, correct?
Then when you change to then other power source, you have issues correct?
Going to ask a dumb question, have you checked the voltage from the grid compared to your other power source?
Your other power source is an inverter drawing its power from a battery bank, correct?
Is the inverter a pure sine wave or modified sine wave?
Are you trying to come straight from a controller to feed power without going through an inverter?
Not taking anything for granted since I am not seeing a lot of info.
If you have checked everything out and you see no problem, have you tried to bypass the rocker switch that you are working on and just connect the wiring with the light directly to your inverter feed without using the switch? If it works then it is your wiring to your switch or the switch itself. If it does not work wired direct, it is something from your power source and does not have anything to do with the switch.