ESP 32 smart swtich

Im having problem in programming of ESP32 dev module
my basic idea is i have i have 2 switches with web servers of sinric.com
i named one as room light and another as room fan
i have 2 sensors dht11 and pir
so my basic output is
automatically opening of light when pir sensor detects motion and automatically opening of fan when dht11 crosses set point
and
its automatic but i want i should also open with amazon alexa and close
when im working with ESP32 either its taking automatic output or alexa output its not taking both
my idea is when i have alexa output high the switch should not take output from sensors and when alexa is low it has to take output from sensors
please help me im hell confused how to program it