Node Red - Shelly Pro 3 , read status switch

Hello,

Background:
will head with heating rod. The heating rod can be L1=2000 / L1+L2=4000 & L1+L2+L3 = 6000 Watt.
I want to switch it via a Shelly Pro 3
Second point is to charge the battery more slowly and reduce the midday peak.

Function:

if (msg.soc >= 50)
    {
               if(msg.battery >= 9000 || msg.grid <= -9000) {
        msg.payload=6050;
        } else if(msg.battery >= 7000 || msg.grid <= -7000) {
        msg.payload=4050;
        } else if(msg.battery >= 5000 || msg.grid <= -5000) {
        msg.payload=2050;
        } else {
        msg.payload=50;
        }
    }
else if (msg.soc >= 60)
    {
               if(msg.battery >= 8500 || msg.grid <= -8500) {
        msg.payload=6060;
        } else if(msg.battery >= 6500 || msg.grid <= -6500) {
        msg.payload=4060;
        } else if(msg.battery >= 4500 || msg.grid <= -4500) {
        msg.payload=2060;
        } else {
        msg.payload=60;
        }
    }
else if (msg.soc >= 70)
    {
               if(msg.battery >= 8000 || msg.grid <= -8000) {
        msg.payload=6070;
        } else if(msg.battery >= 6000 || msg.grid <= -6000) {
        msg.payload=4070;
        } else if(msg.battery >= 4000 || msg.grid <= -4000) {
        msg.payload=2070;
        } else {
        msg.payload=70;
        }
    }
else if(msg.soc >= 80)
    {
               if(msg.battery >= 7500 || msg.grid <= -7500) {
        msg.payload=6080;
        } else if(msg.battery >= 5500 || msg.grid <= -5500) {
        msg.payload=4080;
        } else if(msg.battery >= 3500 || msg.grid <= -3500) {
        msg.payload=2080;
        } else {
        msg.payload=80;
        }
    }
else if(msg.soc >= 90)
    {
               if(msg.battery >= 7000 || msg.grid <= -7000) {
        msg.payload=6090;
        } else if(msg.battery >= 5000 || msg.grid <= -5000) {
        msg.payload=4090;
        } else if(msg.battery >= 3000 || msg.grid <= -3000) {
        msg.payload=2090;
        } else {
        msg.payload=90;
        }
    }
else if(msg.soc >= 95)
    {
               if(msg.battery >= 6500 || msg.grid <= -6500) {
        msg.payload=6095;
        } else if(msg.battery >= 4500 || msg.grid <= -4500) {
        msg.payload=4095;
        } else if(msg.battery >= 2500 || msg.grid <= -2500) {
        msg.payload=2095;
        } else {
        msg.payload=95;
        }
    }
else { msg.payload=0; }

return msg;

If the heating rod Start to work losing charging energy from Grid or Battery.
I try to use the feedback from Shelly 3 Pro to compensate for this.

the point is now,
in the debug_note with “msg.status.switch:0.output” get the output true or false back. this is good.

But if i will set it with a change note to other msg.valve it get no output.

Thank you for having a look
Roberto

now it work… i don^t know why not dirkt.