flejur Posted Friday at 07:10 Share Posted Friday at 07:10 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 Friday at 13:18 Share Posted Friday at 13:18 @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 Monday at 10:38 Author Share Posted Monday at 10:38 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 Monday at 19:36 Share Posted Monday at 19:36 @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...
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.