Sonoff S31, how to make it turn ON if MQTT connection lost

I have a couple sonoff plugs that are running fairly important items that are responsible for cooling. It is all currently configured through HA, MQTT, and nodered. My issue is if the power goes out then the server may not come back online properly after the power is restored and therefore what needs cooled may not get proper cooling.

Is there a script or something I can add on the sonoff s31 plugs to check for MQTT connection and if not available then turn the sonoff on automatically?

Look for default_state (Power ON state) of the switch on the S31

@lordwizzard Where can I find that? I looked in the tasmota GUI on the switch, but didn’t see anything.

Not sure for tasmota, it is there under SonoffLAN by AlexxIT (HACS) and the eWelink add-on.
Found some stuff at these links:

@lordwizzard Thank you very much for the info. I have found the below information as pertinent to what I want. Please excuse my ignorance, but how can I change the PowerOnState?

Is it as simple as sending the following command in the CLI within the gui?
PowerOnState ON; (not sure I need the semicolon, from documentation).

I’m not a a MQTT/Tasmota user, you will have to experiment on issuing some test commands and see if the action happens as expected.

Thank you. I will do that. I’ll post up here with results so anyone else can use the information as I didn’t come across obvious info regarding this.

That did the trick. I tested it every possible way I could and it powered on immediately after it was plugged in.

Simply put the below command into the command line in the gui. If you want to see what the setting is already then just put PowerOnState and it will tell you.

PowerOnState ON