Jump to content
🌟 NOTIFICATION/Benachrichtigung: Welcome to our New Store! - shelly.com 🌟 ×

Search for Shelly pro3 Script Programmer


flejur

Recommended Posts

I am looking for a programmer for a fee who can write me a shelly script for the following requirement:

if boolean:200 true then switch out 1 and out 3
if s2 on then switch out 2 and 3 on
if virtualSwitchId = 200 false and s2 on then switch out 1
if virtualSwitchId = 200 false and s2 off then turn off out 3
if s2 off and virtualSwitchId = 200 true then turn out 2 off
if s2 off and virtualSwitchId = 200 false then turn out 3 off

Thank You

Link to comment
Share on other sites

Hello @If_then_else

her my anser:

if boolean:200 true then switch on out 1 and out 3
if s2 on then switch on out 2 and 3 on
if virtualSwitchId = 200 false and s2 on then switch  turn off out 1
if virtualSwitchId = 200 false and s2 off then turn off out 3
if s2 off and virtualSwitchId = 200 true then turn off out 2 off
if s2 off and virtualSwitchId = 200 false then turn off out 3 off

Ok

Thank You

 

 

 

Link to comment
Share on other sites

@flejur

With your new information the situation looks a little different.

Screenshot2024-10-14213428.png.e913c223374872cdc85272bc60e69fb5.png

I think you can understand the matrix and adapt the script - code below yourself.

/// Decode Inputs to Outputs V1.0
////////////////////////////////////////////////////////////////////////////////////////////
///
/// Created by if_then_else or HighFive © 2024
///
////////////////////////////////////////////////////////////////////////////////////////////
let log = 1; // If no console log needed please set log to "0"
let inputStateOld = -1;
////////////////////////////////////////////////////////////////////////////////////////////
function timerHandler() {
    let inputState = 0;
    ////////////////////////////////////////////////////////////////////////////////////////////
    /// Read all input
    //////////////////////////////////////////////////////////////////////////////////////////// 
    if (Shelly.getComponentStatus('input:0').state === true) {
        inputState = inputState + 1;
    };
    ////////////////////////////////////////////////////////////////////////////////////////////
    if (Shelly.getComponentStatus('input:1').state === true) {
        inputState = inputState + 2;
    };
    ////////////////////////////////////////////////////////////////////////////////////////////
    if (Shelly.getComponentStatus('input:2').state === true) {
        inputState = inputState + 4;
    };
    ////////////////////////////////////////////////////////////////////////////////////////////
    if (Shelly.getComponentStatus('boolean:200').value === true) {
        inputState = inputState + 8;
    };
    ////////////////////////////////////////////////////////////////////////////////////////////
    /// Set Output relays
    ////////////////////////////////////////////////////////////////////////////////////////////    
    Shelly.call("Switch.set", {
        'id': 0,
        'on': (inputState == 08) || (inputState == 09) || (inputState == 10) || (inputState == 11) ||
            (inputState == 12) || (inputState == 13) || (inputState == 14) || (inputState == 15)
    });
    ////////////////////////////////////////////////////////////////////////////////////////////    
    Shelly.call("Switch.set", {
        'id': 1,
        'on': (inputState == 02) || (inputState == 03) || (inputState == 06) || (inputState == 07)
    });
    ////////////////////////////////////////////////////////////////////////////////////////////    
    Shelly.call("Switch.set", {
        'id': 2,
        'on': (inputState == 02) || (inputState == 03) || (inputState == 06) || (inputState == 07) ||
            (inputState == 08) || (inputState == 09) || (inputState == 10) || (inputState == 11) ||
            (inputState == 12) || (inputState == 13) || (inputState == 14) || (inputState == 15)
    });
    ////////////////////////////////////////////////////////////////////////////////////////////
    /// Print all input and relay states to console window 
    //////////////////////////////////////////////////////////////////////////////////////////// 
    if ((log != 0) && (inputState != inputStateOld)) {
        print('Input number: ' + inputState +
            ' | Virtual input {bool:200}: ' + (Shelly.getComponentStatus('boolean:200')).value +
            ' | s1: ' + Shelly.getComponentStatus('input:0').state +
            ' | s2: ' + Shelly.getComponentStatus('input:1').state +
            ' | s3: ' + Shelly.getComponentStatus('input:2').state +
            ' | OUT1: ' + Shelly.getComponentStatus('switch', 0).output +
            ' | OUT2: ' + Shelly.getComponentStatus('switch', 1).output +
            ' | OUT3: ' + Shelly.getComponentStatus('switch', 2).output);
    };
    inputStateOld = inputState;
};
////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////////////// 
Timer.set(1000, true, timerHandler, null);
////////////////////////////////////////////////////////////////////////////////////////////

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Erstelle neue...