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

Search for Shelly pro3 Script Programmer


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

  • 3 weeks later...
  • Members

Hi

I am looking for help with a similar program

I have 3 rooms each has a separate  shelly unit which turns the  boiler D on and off

I have no issue with turning the boiler D on

When each room goes to turns off the boiler

Room A  only turn the boiler off if B and C are off

Room B  only turn the boiler off if A and C are off

Room C  only turn the boiler off if A and B are off

 

Thanks

 

Link to comment
Share on other sites

  • Members

I have 3 different rooms each with a Wall Display switching a Shelly Plus 1 pm

Calling each of these Shelly Plus 1 pm A, B, C.

We also have a 4th Shelly Plus 1 pm which switches the boiler on and off called D.

A, B, C. when turned on by Each Wall display they turn on D.

When A is turned off by the Wall Display if B or C are on it takes no action

if both B and C are off it turns D off.

When B is turned off by the Wall Display if A or C are on it takes no action

if both A and C are off it turns D off.

When C is turned off by the Wall Display if A or B are on it takes no action

if both A and B are off it turns D off.

 

image.png.7f7281b839ef054b519670a2896208ca.png

 

Many Thanks

Link to comment
Share on other sites

@PJM

Hello,

I spent a long time with your rather complex function description.

My conclusion at the end was that you have a very simple function (A or B or C = D).

I put this into the script below.

The script installation must take place in room "D" and then you have to enter the 3 IP addresses of rooms A..C in lines 13..15.

/// Read status of Room "A" + "B" + "C" and if any is "ON" then set also Room "D" V1.0
/// Script is only running on Room "D"
////////////////////////////////////////////////////////////////////////////////////////////
///
/// Created by HighFive (if then else) © 2024
///
/// Email: highfive@smartshome.work 
/// Email: if_then_else@smartshome.work
///
////////////////////////////////////////////////////////////////////////////////////////////
/// *** User values ***
////////////////////////////////////////////////////////////////////////////////////////////
let IP_Room_A = '192.168.xxx.xxx'; // Set IP address for room "A"
let IP_Room_B = '192.168.xxx.xxx'; // Set IP address for this "B"
let IP_Room_C = '192.168.xxx.xxx'; // Set IP address for this "C"
//
let log = 1; /// If no console log needed please set log to "0"
////////////////////////////////////////////////////////////////////////////////////////////
/// *** End ***
////////////////////////////////////////////////////////////////////////////////////////////
/// *** internal ***
////////////////////////////////////////////////////////////////////////////////////////////
let stateSwitches = [false, false, false];
let timer = 0;
////////////////////////////////////////////////////////////////////////////////////////////
/// *** End ***
////////////////////////////////////////////////////////////////////////////////////////////
function timerHandler() {
    switch (timer) {
        case 0:
            Shelly.call('http.get', {
                    url: 'http://' + IP_Room_A + '/rpc/switch.getstatus?id=0'
                },
                function(response) {
                    stateSwitches[0] = (JSON.parse(response.body).output === true);
                }
            );
            break;
        case 1:
            Shelly.call('http.get', {
                    url: 'http://' + IP_Room_B + '/rpc/switch.getstatus?id=0'
                },
                function(response) {
                    stateSwitches[1] = (JSON.parse(response.body).output === true);
                }
            );
            break;
        case 2:
            Shelly.call('http.get', {
                    url: 'http://' + IP_Room_C + '/rpc/switch.getstatus?id=0'
                },
                function(response) {
                    stateSwitches[2] = (JSON.parse(response.body).output === true);
                }
            );
            break;
        default:
            timer = 0;
            break;
    };
    ///
    Shelly.call('Switch.set', {
        'id': 0,
        'on': stateSwitches[0] || stateSwitches[1] || stateSwitches[2]
    });
    ///
    if (log != 0) {
        print('INPUT Room A: ' + state_to_ON_OFF(stateSwitches[0]) +
            ' || INPUT Room B: ' + state_to_ON_OFF(stateSwitches[1]) +
            ' || INPUT Room C: ' + state_to_ON_OFF(stateSwitches[2]) +
            ' || OUTPUT Room D: ' + state_to_ON_OFF(Shelly.getComponentStatus('switch', 0).output))
    };
    ///
    timer++;
};
////////////////////////////////////////////////////////////////////////////////////////////
Timer.set(1000, true, timerHandler, null);
////////////////////////////////////////////////////////////////////////////////////////////
function state_to_ON_OFF(state) {
    if (state === true) {
        return 'ON'
    } else {
        return 'OFF'
    };
};
////////////////////////////////////////////////////////////////////////////////////////////
///
////////////////////////////////////////////////////////////////////////////////////////////

 

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.

×
×
  • Create New...