outandwild Posted June 19 Share Posted June 19 I have created a tiny little script which would cycle through states of a Wall Dimmer itself and the other device like a socket. Everything works pretty ok but there is an issue which i would like to overcome. The Wall Dimmer is actually labeled as light and also it doesn't have an option to "separate" the input on switch from the controller itself. And that makes it impossible to control another device with it unless you actually cycle through it's states in the same way. In other words, once you press on, your desired state in the script must be also on, once you press off, also. Etc. And in between you can do something else. Practically what this script do is turning on/off the device it self even though it would do it anyway. And in between, controlling the socket. What makes quite an issue is that the changing the dimmer level is also registered as a change that triggers the change in the script. Questions, is there any way to disconnect the inputs from switch? Is it possible to ignore triggers if those are intensity level change? (there is no distinguished event for that and i would have to track the switch status before and now in order to determine that.) This is the script: const setups = { 1: { light: true, switch: 'false' }, 2: { light: false, switch: 'true' }, 3: { light: true, switch: 'true' }, 4: { light: false, switch: 'false' }, }; let currentSetup = 1; Shelly.addStatusHandler(function(event, userData) { // Set the Wall Dimmer print(event); if(event.component === 'light:0' && event.delta.source == 'ui'){ print('currentSetup: '+currentSetup); print(JSON.stringify(setups[currentSetup].switch)) // Set the remote Shelly socket let switchUrl = 'http://192.168.1.177/rpc/Switch.Set?id=0&on='+setups[currentSetup].switch; print(switchUrl); Shelly.call( "HTTP.GET", { url: switchUrl }, function(res, error_code, error_msg) { // Handle potential errors (optional) }, null ); Shelly.call("Light.Set", { id: 0, on: setups[currentSetup].light, brightness: event.delta.brightness, }); currentSetup++; if (currentSetup == 5) currentSetup = 1; } }); 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.