shelly-tools / shelly-script-examples

Shelly mJS Scripting examples
GNU Affero General Public License v3.0
73 stars 21 forks source link

idea/friendly request: Use i4 with switch and button 1 to control dimmer 2 #16

Closed GRNspz closed 1 year ago

GRNspz commented 1 year ago

In my bedroom I have a wall switch near the door, a Shelly Button 1 on the night table and a dimmer 2 behind the lamp (permanently powered). I want to be able to toggle the dimmer 2 from the button (I have scenes for that) and from the switch (yes, it's a switch, not a button).

My current setup is one scene for ON and one for OFF. The scene for ON is configured like this: Trigger:

Action:

As you might already see, the problem is that the action triggers the third trigger option of the OFF scene (which looks basically the same with inverted states) if I switch the light on via wall switch and want to switch it off via Button 1 because I cannot get the dimmer's state as a condition without using it as a trigger.

What I actually need is an "edge switch" relay type behaviour for the i4 but since it is not a relay that is not an option in the device settings. Would you please try to write a script that does just that?

eurich commented 1 year ago

Sorry, I don't write custom scripts for special use cases but from what I understand you'd need a simple toggle for both the button and the I4? If this is the case: cloud based szenes are just overcomplicating things a lot.

A simple action (button1 -> button short press url) and two webhooks on the I4 (input toggled on and input toggled off) should do that: http://<shelly-dimmer-ip>/light/0?turn=toggle

GRNspz commented 1 year ago

Well that sounds like an even better solution. Thank you! Sorry for the inconveniences.