logo elektroda
logo elektroda
X
logo elektroda

Turning Off LED on Tuya AU LSPA9 Smart Socket After Successful Openbeken Flash

ciknururko 3972 57
ADVERTISEMENT
  • #1 20795936
    ciknururko
    Level 3  

    White smart plug with Ozone logo and blue LED, next to a smartphone.

    Flashed the above plug successfully with openbeken and with profile "Tuya AU LSPA9? Smart Socket: Energy Monitoring"

    Now the plug is getting turned on and off, energy, power figures are showing.

    How to turn off the LED on the plug when the plug is turned off? The LED on the power button on the switch always stays ON.

    Kindly guide.
  • ADVERTISEMENT
  • #2 20795962
    p.kaczmarek2
    Moderator Smart Home
    Hello, have you tried to do GPIO extraction to figure out which GPIO is used for LED?
    https://www.youtube.com/watch?v=WunlqIMAdgw&ab_channel=Elektrodacom
    Please post extracted JSON here.
    Helpful post? Buy me a coffee.
  • #3 20796024
    ciknururko
    Level 3  
    Code: JSON
    Log in, to see the code
  • #4 20796031
    p.kaczmarek2
    Moderator Smart Home
    Now you can use:
    https://openbekeniot.github.io/webapp/templateImporter.html
    I can see that it can decode following GPIOs:
    
    Device seems to be using CB2S module, which is BK7231N chip.
    - Relay (channel 1) on P26
    - WiFi LED on P8
    - Button (channel 1) on P10
    - BL0937 ELE on P7
    - BL0937 VI on P6
    - BL0937 SEL on P24
    

    Is the LED you are referring to on P8?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20796043
    ciknururko
    Level 3  

    Yes (Changed WiFi LED on P8 to LED_N on P8) which is now toggling the LED.

    Also, the device is not remembering the last state... Kindly help how to fix this?
  • #6 20796260
    p.kaczmarek2
    Moderator Smart Home
    You can configure "Remember last state" in startup options, set it to -1 to remember the state before reboot
    Helpful post? Buy me a coffee.
  • #7 20796323
    ciknururko
    Level 3  
    Where exactly is this option? Kindly share a screenshot.

    Also plz guide how to set "inching" time for the switch..
  • #8 20796861
    p.kaczmarek2
    Moderator Smart Home
    Config -> Configure Startup - > enter -1 in field for relay channel

    What do you mean with inching, do you want it to open itself back when it's closed?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #9 20797236
    ciknururko
    Level 3  
    Screenshot showing the Inching feature settings, allowing automatic device shutdown.

    Like shown in the screenshot. I have another WiFi plug (same model) which I haven't flashed with OpenBeken yet. So there is an option for inching as described in the screenshot. Can the same functionality be achieved with OpenBeken?

    Kindly guide.


    Added after 1 [hours] 27 [minutes]:

    >>20796861
    Please guide how to auto turn off the switch after N number of minutes.

    Eg if I turn on the switch, then it should automatically turn off after 20 minutes.

    How to do this via openbeken??

    Kindly guide
  • #10 20797359
    p.kaczmarek2
    Moderator Smart Home
    Here is a simplest script that will watch for the channel 1 change to state 1 (relay on) and turn it off back to 0 (relay open) after 10 seconds:
    
    
    // This aliased command will turn off relay on CH1 after 10 seconds
    // addRepeatingEvent	[IntervalSeconds][RepeatsOr-1][CommandToRun]
    alias turn_off_after_time addRepeatingEvent 10 1 setChannel 1 0
    // this will run the turn off command every time that CH1 becomes 1
    addChangeHandler Channel1 == 1 turn_off_after_time 
    

    Following script needs to be put in autoexec.bat in LittleFS. Make sure to check if you are using the correct channel, some people are using Channel 0 instead of 1.

    Also remember to change the time (value 10 in the script) to suit your needs. The following value is in seconds.
    Helpful post? Buy me a coffee.
  • #11 20797375
    ciknururko
    Level 3  

    It worked, but now the button is turning on automatically. It's not remembering the last state. How to fix this?

    Kindly guide.
  • #12 20797388
    p.kaczmarek2
    Moderator Smart Home
    What do you mean by "turning on" automatically?

    The countdown timer is not kept after reboot. If you want countdown timer to be kept after reboot, you most likely need to use a channel as a variable.
    Helpful post? Buy me a coffee.
  • #13 20797399
    ciknururko
    Level 3  

    I mean if the switch is turned off by me and then the power goes. Now after power comes, the switch should be in the off state but now it's getting turned on.

    In startup options, I have already given -1.

    Before the script, it was working fine. After using the script, it's not remembering the last state.

    Also, now I have deleted the script, restarted the plug, but it's not remembering the last state.

    What do I do now so that the plug remembers the last state? (In startup options, I have already given -1)

    Also, if you are using a mobile, then there is no way to give -1 as it only shows a numeric keyboard.
  • #14 20797440
    p.kaczmarek2
    Moderator Smart Home
    You must have a configuration error. Maybe wrong startup value. It worked for me.

    Still, here is a script that tries to remember the countdown value between reboots and displays timer on gui:
    Screenshot of the OpenBK7231T interface showing relay status and a timer countdown set to 27 seconds.
    
    
    // display seconds timer
    setChannelType 2 TimerSeconds
    // set start values as "remember in flash"
    SetStartValue 1 -1
    SetStartValue 2 -1
    
    // channel 2 is timer
    // channel 1 is relay
    
    // here is countdown value in seconds - 30
    alias turn_off_after_time backlog setChannel 2 30
    alias on_turned_off setChannel 2 0
    alias turn_off_relay setChannel 1 0
    alias do_check if $CH2==0 then turn_off_relay 
    alias do_tick backlog addChannel 2 -1; do_check
    
    // this will run the turn off command every time that CH1 becomes 1
    addChangeHandler Channel1 == 1 turn_off_after_time 
    // this will run the turn off command every time that CH1 becomes 0
    addChangeHandler Channel1 == 0 on_turned_off
    
    
    again:
    
    if $CH2!=0 then do_tick
    delay_s 1
    goto again
    

    It uses channel 1 as a relay and channel 2 as a timer variable
    Helpful post? Buy me a coffee.
  • #15 20797454
    ciknururko
    Level 3  

    Thank you for the script.

    How to fix the configuration error? The switch is still not remembering the last state? Do I have to reset the switch?
  • #16 20797488
    p.kaczmarek2
    Moderator Smart Home
    If your switch is still not remembering the last state, then you have to show me your full device configuration, screenshots from the pages, from startup, etc, from pins, and your current script.

    I have a LSPA-like socket at hand and it remembers the relay state:
    Screenshot of the OpenBK7231T device control panel displaying OFF status.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #17 20797512
    ciknururko
    Level 3  

    I have reset the switch, now it's remembering the last state.

    The next time, if it does not remember the last state, I will give you the screenshots you asked for.

    I think I am ready to flash my other plugs now. But before that, I have a few questions:

    1. Can I switch between Esphome and openbeken?
    2. Can I go back to the original tuya firmware if I ever want to?
    3. How do I take a backup of settings, etc., so that it can be restored if I ever want to reset the switch?

    Really, thank you for your patience and time. I really appreciate your help and cooperation.
  • #18 20797521
    p.kaczmarek2
    Moderator Smart Home
    1. They have created some strange OTA format so going to BK is problematic, so I would not recommend that. It's possible, but problematic
    2. You can do that easily if you flash 2MB backup back with UART programmer wires
    3. In the Web App, you can either:
    - copy device template as text and autoexec as text
    - download full CFG partition (that will also contain your ssid, etc, much more info than just device template)
    Helpful post? Buy me a coffee.
  • #20 20797988
    p.kaczmarek2
    Moderator Smart Home
    Keep in mind that autoexec.bat is not in the CFG partition, so make sure to store it as well.
    Helpful post? Buy me a coffee.
  • #21 20798855
    ciknururko
    Level 3  

    Ok. Thank you again for your kind help and cooperation.
  • #22 20800122
    ciknururko
    Level 3  

    I flashed one more plug of the same model. But this time I chose "Cut from cloud". I can control the plug using tinytuya. Is there any Android app by which I can control the plug?

    Kindly reply.
  • #23 20800222
    p.kaczmarek2
    Moderator Smart Home
    I think the Tasmota Control and similiar apps should work for you.

    See example here:


    Helpful post? Buy me a coffee.
  • #24 20800249
    ciknururko
    Level 3  
    If flashed with openbeken firmware then "Tasmota Control" app works.

    I was asking if we choose only to "Cut from Cloud" then is there any android app available that can control such plugs ?
  • #25 20800338
    p.kaczmarek2
    Moderator Smart Home
    Sorry, I don't know much about the "cut from cloud" option, I heard that it's possible to use Tuya Local HASS integration for that, but not many people are using that.
    Helpful post? Buy me a coffee.
  • #27 20801662
    ciknururko
    Level 3  

    Hello,

    Need a little guidance,

    This is the script that you posted

    // This aliased command will turn off relay on CH1 after 10 seconds
    // addRepeatingEvent [IntervalSeconds][RepeatsOr-1][CommandToRun]
    alias turn_off_after_time addRepeatingEvent 10 1 setChannel 1 0
    // this will run the turn off command every time that CH1 becomes 1
    addChangeHandler Channel1 == 1 turn_off_after_time


    Instead of hardcoding the time e.g. 10 seconds in the auto exec.bat file, can we have a TEXTFIELD on the main GUI page to enter the time in seconds and have a button like SET to save the entered time for inching.

    Something like in the screenshot.
    Screenshot showing a text field with the value 0 and a button labeled Set.

    If the value in the TEXTFIELD is zero, then inching is disabled and the plug will turn off when the user turns it off manually. If there is a value in the TEXTFIELD, then the plug will turn off after that many seconds which is entered in the TEXTFIELD.

    This will help many users like me.

    Kindly help.
  • #28 20801729
    p.kaczmarek2
    Moderator Smart Home
    Well, then you need to choose a channel, let's say $CH5, set it to TextField, and then, in the timer code, change the constant 10 to $CH5, which means "current value of channel 5".
    Helpful post? Buy me a coffee.
  • #29 20801795
    ciknururko
    Level 3  

    alias turn_off_after_time addRepeatingEvent $CH15 1 setChannel 1 0
    addChangeHandler Channel1 == 1 turn_off_after_time

    Don't like above. But what if the value in TEXTFIELD is zero, then the switch just turns on and then off. Yes because the value is zero. So how can I just disable the alias "turn_off_after_time" if the value in TEXTFIELD is zero and in such a case the switch has to be manually switched off.

    Kindly guide
  • #30 20801960
    p.kaczmarek2
    Moderator Smart Home
    Here are our examples:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    You can base your code on that line:
    
    alias do_check if $CH2==0 then turn_off_relay 
    

    Just change the variables and condition, use:

    instead of equality check.
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the Tuya AU LSPA9 Smart Socket, which was successfully flashed with OpenBeken firmware. The main issue addressed is how to turn off the LED indicator on the device when it is powered off. Users explored GPIO extraction to identify the LED control pin and confirmed that the LED is connected to GPIO P8. Solutions were proposed to configure the device to remember its last state after reboot and to implement a countdown timer for automatic shutoff after a specified duration. Users also discussed integrating the device with Home Assistant for remote control and setting inching timers via a GUI. Additionally, there were inquiries about switching between firmware versions and backing up settings.
Summary generated by the language model.
ADVERTISEMENT