There is no need to shout (please don't write in capitals!)
Without seeing the contents of your function and switches it is difficult to know what you are doing. Please export your flow and paste it in this thread in between ``` so it formats it correctly
But where I guess you are going wrong is that Node-RED doesn't remember the contents of old messages. So you need to save the value of PIR0 so when PIR1 changes it remembers what state PIR0 is ( and save PIR1 so that when ...)
You can read about how to do this
https://nodered.org/docs/writing-functions#storing-data
and can do it with a change node (eg set flow.pir1 to msg.payload)