How to 'AND' function on Shelly Pro 3

There are 8 replies in this Thread which has previously been viewed 411 times. The latest Post (April 4, 2024 at 12:57 AM) was by eiche.

  • Hi all,

    Pretty new on the Shelly devices and even more on scripting.. (i'm a newbie)

    Device 'x' = Shelly Pro 1
    Device 'y' = Shelly Pro 3

    I have this device 'x' of which i'm switching ON the relay '0'
    But... can you tell me on device 'y' how to 'AND' all 3 incoming switches and reset relay '0' from device 'x'?
    Like:
    If Sw1 AND Sw2 AND Sw3 (device 'y') are OFF then switch off Relay '0' from device 'x'

    Thank you for your help in advance

    Michiel

  • This may be implemented by an event handler in a script at device y. This handler receives any change of an input, store the status (off vs. on) in a variable and checks the three values like this:

    if(in1===off && in2===off && in3===off) Shelly.call("HTTP.Get", {url:"http://<IP address of device x>/rpc/Switch.Set?id=0&on=false"});

    respectively

    if(!in1 && !in2 && !in3) Shellly.call("HTTP.Get", {url:"http://<IP address of device x>/rpc/Switch.Set?id=0&on=false"});
    In the second variant the values of in1, in2, in3 must be of type boolean.

    An Cloud-/Szenen-Benutzer (insbesondere für Regelungen): Was erwartest du, wenn Internet oder Cloud sabotiert werden? Nicht nur dafür meine kleine Skripteinführung  8)

    Die einzig existierende Konstante ist der Wandel. Oft liegt die größte Schwierigkeit darin, das Anliegen des Klienten zu verstehen.

    Edited once, last by eiche (April 3, 2024 at 8:18 AM).

  • Thank you Eiche, for helping out here.

    I have absolutely no experience with scripting so..
    i've punched in the line as you described, but it gives an '-3 reference_error'
    if(in1===off && in2===off && in3===off) Shelly.call("HTTP.Get", {url:"http://192.168.1.200/rpc/Switch.Set?id=0&on=false"});

    i think i need the full script from start to finish

    Device 'x' = Shelly Pro 1 (192.168.1.200)
    Device 'y' = Shelly Pro 3 (192.168.1.202)

    tx
    Michiel

  • Sorry, there was a mistake in my variant 2 above which now I have corrected.

    Unfortunately I don't have any Shelly Pro 3, but Shelly pro 2 and of corse Shelly Plus 1 ... So I can't test such a script. But it will works.

    My first variant above just shows the principle.

    But the incoming event has an input state which is a boolean value (true or false). Therefore my variant 2 works if you store the state of input:0 to variable in1, of input:1 to variable in2, of input:2 to variable in3.

    Ok, I understood, you need a complete script. Maybe I'll program a little script for you today or tomorrow ...

    An Cloud-/Szenen-Benutzer (insbesondere für Regelungen): Was erwartest du, wenn Internet oder Cloud sabotiert werden? Nicht nur dafür meine kleine Skripteinführung  8)

    Die einzig existierende Konstante ist der Wandel. Oft liegt die größte Schwierigkeit darin, das Anliegen des Klienten zu verstehen.

  • i've spent the whole day figuring this out, GPT is not helping either.
    Another solution to me would be similair like:
    If input-1 OR input-2 OR input-3 is ON then Output-x is ON

  • This threads contains 4 more posts that have been hidden for guests, please register yourself or log-in to continue reading.