Psu control plugin and easy esp

Hello,
I have a sonoff switch with easy esp installed.
I have set psucontrol with
curl http://192.168.0.20/control?cmd=GPIO,12,1
to start psu, same with 0 to stop.

My problem is with reading the state of the sonoff relay.
curl -s 'http://192.168.0.20/control?cmd=status,GPIO,12'|grep state|awk '{ print $2 }'
works when sonoff is on, but if i turn it off the lightning is always on, it never turns off.
(The command gives me 0)

Thank you for your responses.

System command works based on the exit code. 0=on,1=off.

Still looking for a solution

.octoprint/scripts/sonoff.sh

#!/bin/bash                                                                                                                                                           
Test=$(curl -s 'http://192.168.0.20/control?cmd=status,GPIO,12'|grep state|awk '{ print $2 }')                                                                        
if [ $Test -eq 0 ]                                                                                                                                                    
then                                                                                                                                                                  
        exit 1                                                                                                                                                        
else                                                                                                                                                                  
        exit 0                                                                                                                                                        
fi