flejur Posted October 11 Share Posted October 11 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 Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
If_then_else Posted October 11 Share Posted October 11 @flejur I would like to create an example script for you, but an analysis of your information raised some questions. Check my summary and let me know what is wrong, especially with the red fields. 1 Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
flejur Posted October 14 Author Share Posted October 14 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    Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
If_then_else Posted October 14 Share Posted October 14 @flejur With your new information the situation looks a little different. 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); ////////////////////////////////////////////////////////////////////////////////////////////  Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
Members PJM Posted October 29 Members Share Posted October 29 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  Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
If_then_else Posted October 29 Share Posted October 29 @PJM I would like to help you, but I need detailed information. Which Shelly device. What does Room A, B, C mean? (Shelly does not have any terminals with this name) A drawing of how the wiring is. A "matrix" like the example below. Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
Members PJM Posted October 29 Members Share Posted October 29 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.   Many Thanks Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
If_then_else Posted Friday at 11:39 AM Share Posted Friday at 11:39 AM @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' }; }; //////////////////////////////////////////////////////////////////////////////////////////// /// ////////////////////////////////////////////////////////////////////////////////////////////  Quote Translate Revert translation? English (American) Finnish French German Italian Portuguese (European) Spanish Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.