Value 240 if AC in is off Node Red

Thanks to Sean M.Oelofse I got my Node Red function partly working.
If AC in is gone I expected the value to be “0” but it shows “240”, inverter mode. Changing the value in the code to 240 it works.
2 questions: when will “0” being displayed instead of “240”?
Is there a way in the code to set an or function to have either “0” or “240” as values together with an “and” function for SOC level?

The code as it is now"
Cerbo relay.zip (894 Bytes)