logo elektroda
logo elektroda
X
logo elektroda

[Solved] Configuring Inverse Switch for Onboard LED with OpenBeken on Deta Switch Plates

rohanb 513 6
ADVERTISEMENT
  • #1 21137156
    rohanb
    Level 2  
    Hi
    I am using Deta Switch plates and in the past have replaced the units with ESP and used Tasmota to achieve my config.

    I have just flashed OpenBeken on my first new one and am super impressed with how it works with no hardware replacement.

    The only thing I cannot work out is with Tasmota for the onboard LED I use the function "Inverse Switch" so basically the LED is on all the time until any button is pressed then it goes off (I use it like a find the wall plate at night)

    Can OpenBeken somehow do this

    Thank You again
  • ADVERTISEMENT
  • #2 21137280
    p.kaczmarek2
    Moderator Smart Home
    Hello, thank you for kind words!
    If I understand correctly, you want to inverse LED state in a relation to the switch?
    Well, assuming that you have LED on channel 1, then LED state will follow channel state. If you want to inverse it, you should use LED_n pin role, which is a negated (inversed) LED.

    Or... are you referring to more advanced behaviour? What is your device config?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21137325
    rohanb
    Level 2  
    Hi
    Sorry I should have given more information
    Current Config is this

    - Button (channel 1) on P14
    - WiFi LED on P1
    - Relay (channel 2) on P26
    - Relay (channel 1) on P8
    - Relay (channel 3) on P24
    - Relay (channel 4) on P7
    - Button (channel 4) on P6
    - Button (channel 3) on P10
    - Button (channel 2) on P9

    What I would like is when ANY switch/relay is activated it turns the LED on P1 off and when no switches/relays are active then P1 LED is on

    Thanks again
  • #4 21138034
    p.kaczmarek2
    Moderator Smart Home
    Move your LED to separate channel and try something like in autoexec.bat:
    
    again:
    // typo fixed
    setChannel 10 $CH1==0&&$CH2==0&&$CH3==0&&$CH4==0
    goto again
    

    LED is on channel 10, and it will be true (1, on) only if all 4 channels are 0

    I didn't test it yet on OBK, but it should work, more or less
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21139725
    rohanb
    Level 2  
    Hi Sorry for delayed reply

    This worked fine except for a small typo in your response ;-)

    Below is working code

    again:
    setChannel 10 $CH1==0&&$CH2==0&&$CH3==0&&$CH4==0
    goto again


    Thanks again for your support
  • ADVERTISEMENT
  • Helpful post
    #6 21139966
    p.kaczmarek2
    Moderator Smart Home
    Now you can optimize this code by using change callbacks:
    
    alias check_led setChannel 10 $CH1==0&&$CH2==0&&$CH3==0&&$CH4==0
    addEventHandler OnChannelChange 1 check_led 
    addEventHandler OnChannelChange 2 check_led 
    addEventHandler OnChannelChange 3 check_led 
    addEventHandler OnChannelChange 4 check_led 
    // do it once on start
    check_led 
    
    Helpful post? Buy me a coffee.
  • #7 21158410
    rohanb
    Level 2  
    This worked perfectly thanks for the help

Topic summary

The discussion revolves around configuring an onboard LED with OpenBeken on Deta Switch plates to achieve an "Inverse Switch" functionality, where the LED remains on until any button is pressed. The user initially used Tasmota for this purpose but is now exploring OpenBeken. After providing their device configuration, they received guidance on moving the LED to a separate channel and using a script in autoexec.bat to control the LED state based on the status of multiple channels. The final solution involved optimizing the code with change callbacks to ensure the LED state updates efficiently when any switch is activated.
Summary generated by the language model.
ADVERTISEMENT