Shelly 4pm - Binding/Interlock of outputs via script

  • I have taken a Shelly 4pm and connected it to 4 x outputs for a heating system:

    (0) Boiler (Feeds a thermal store)

    (1) Central Heating Pump (Rads)

    (2) Underfloor heating Pump

    (3) Plinth heater

    All the outputs and the components they feed can be triggered via a live wire to the inputs on the 4pm.

    I need the Under floor Heating and Plinth channels to be able to trigger the channel (0) Boiler so the thermal store is then heated at all times they are on. No problem, I created two actions to turn Boiler (0) on and off when channels (1, 2, 3) come on. So far so good.

    The issue I have is that when the Boiler (0) output is triggered for Hot water only then another input triggers it say Underfloor Heating (2) if the hot water is turned off and the Boiler input goes off the Boiler channel is turned off.

    I basically need to bind inputs (1) (2) (3) to output (0). So if any of these inputs is on then output (0) Boiler will stay on until they are all off.

    I was really hoping I could solve this by some logic or a script but I'm getting stuck. Maybe I have been starring at it for too long!

    If anyone has any ideas that would be great.

  • Hi there,

    you can definitely do this with a script.

    Feel free to share what you've already done, and I'll try to help you.

    To switch a relay, use Shelly.call('Switch.Set', {on:true, id:0});. 'id:0' for the first relay and 'id:3' for the fourth one.

    Create an event handler to trigger your code with Shelly.addEventHandler(function(events){print(JSON.stringify(events));});.

    And to check the status of other relays, since only one relay switch state is inside an event, you can get the states of the other relays like this: print(Shelly.getComponentStatus('switch', 3).output);.

    Hope this helps you a bit.

  • Thanks a lot for the additional info.

    The truth is I got lost very quickly in the script tool.

    I placed some snippets into the script and got some syntax errors and even caused the 4pm to reboot when the script was running.

    Basically lost on how to format the script and arrange the commands etc. Not something I have done much of until now.

    I might be able to unpick it if I could see a similar script laid out.

  • Like I said, you just need the commands I posted and some logic syntax, so if(x === y){ doStuff;}, try using these commands one at a time to get a good start and feel for Shelly scripts.

    Here is a short Shelly scripting tutorial video:

    How to use scripting in Shelly?
    This is my first try understanding and working on some examples in Shelly scripting. I think I did quite a lot already showing what is possible, but there ar...
    www.youtube.com
  • Einmal editiert, zuletzt von DanHick (5. Oktober 2023 um 18:20) aus folgendem Grund: not in code block

  • Dieses Thema enthält 29 weitere Beiträge, die nur für registrierte Benutzer sichtbar sind, bitte registrieren Sie sich oder melden Sie sich an um diese lesen zu können.