Pro 4PM script - if one switch is on, the other must be off

  • I'm really excited by Shelly scripts, but as I am not a programmer I will need some assistance! Essentially my application requires that switch 1 and switch 2 should not be on at the same time. So, if switch 1 is on and switch 2 is switched on, switch 1 goes off. And the opposite: if switch 2 is on and switch 1 is switched on, switch 2 goes off.

  • That's in theory possible via Scripting.

    Question: Do you need a strict interlock between the relais?

    I'm not 100% sure but there's probably a few milliseconds delay if relay0 goes on and relay1 has to be turned off via script, so there's eventually a short time where both relais would be active. It's definetely safer to use a contactor interlock.

    >100 Shellies, darunter so gut wie alles was der Hersteller produziert hat. ;)
    :!: ich beantworte grundsätzlich keine Fragen per persönlicher Nachricht:!:

  • Thanks for your quick response! You make a good point. relay0 and relay1 are powering two heating elements in a water heater - both elements should not be on at the same time. So, if possible the script would need to avoid both relays being active at the same time... overcurrent protection would kick in!

  • this is a quick'n dirty solution, but as said: there's probably a few milliseconds delay.

    Explaination:

    if switch:0 is turned on switch:1 (id: 1) is turned off

    if switch:1 is turned on switch:0 (id 0) is turned off

    It's still possible to turn off both relays

    If you prefer to use the remaining switch 3/4 from the Pro4PM just replace the switch:x and "id": y

    >100 Shellies, darunter so gut wie alles was der Hersteller produziert hat. ;)
    :!: ich beantworte grundsätzlich keine Fragen per persönlicher Nachricht:!:

  • Dieses Thema enthält 12 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind.