logo elektroda
logo elektroda
X
logo elektroda

[BK7231N/CB2S] KMC Smart Tap Mini Teardown and configuration

mjspez 4941 54
ADVERTISEMENT
  • #31 20847898
    omniron
    Level 10  
    Got it, didn't know this has to be done by autoexec.bat, thought changes had to be done inside the firmware or via "app".

    I tried
    "Question: How do I setup single button to control two relays (first on click, second on double click)?
    A: If you set a pin role to 'Button', you will get a second textbox after saving pins. First checkbox is a channel to toggle on single click, and second textbox is a channel to toggle on double click."
    under
    Web Application, Pin Settings:
    Here you can configure your device. "
    Could not find 'Button' in the drop down list (is it Btn??)
    Even Btn did not offer the toggle, just numbers.

    Since the switch of this unit is at RXD1
    https://www.elektroda.com/rtvforum/topic3958242.html#20836512
    would this be correct?

    setChannelType 1 toggle
    setChannelType 2 toggle
    setChannelType 3 toggle
    // Btn_ScriptOnly is set on RXD1
    addEventHandler OnClick RXD1 ToggleChannel 1
    addEventHandler OnDblClick RXD1 ToggleChannel 2
    addEventHandler On3Click RXD1 ToggleChannel 3

    Aaaah CCtr meaning CloudCutter, got it. I was looking for OTA.

    With 2 second delay I meant the time the switch is pressed. If I press it for ca 2 seconds and release, nothing happens.
    I believe this is mostly due to the fact that it changes AFTER releasing the button, not like with another unit I have, right away-ish.
    So I am trying to hold thinking it needs time to get that I'm pressing the switch...
    thanks

    Added after 2 [hours] 30 [minutes]:

    Tried
    setChannelType 1 toggle
    setChannelType 2 toggle
    setChannelType 3 toggle
    // Btn_ScriptOnly is set on RXD1
    addEventHandler OnClick RXD1 ToggleChannel 1
    addEventHandler OnDblClick RXD1 ToggleChannel 2
    addEventHandler On3Click RXD1 ToggleChannel 3

    didn't work, bummer (did reboot etc)

    View of script editor in autoexec.bat file with button configuration on a device.


    Tried USART_ , nogo
    Looked up what pin RXD1 is (10)
    used this:

    setChannelType 1 toggle
    setChannelType 2 toggle
    setChannelType 3 toggle
    // Btn_ScriptOnly is set on 10
    addEventHandler OnClick 10 ToggleChannel 1
    addEventHandler OnDblClick 10 ToggleChannel 2
    addEventHandler On3Click 10 ToggleChannel 3

    Now:
    1 click does nothing (there is a faint click, as if one of the relays wants to turn on but is stopped right immediately)
    when on, 1 click turns all off,

    2 clicks turn all on,
    2 clicks turn all off,

    3 clicks turn 3 on,
    3 clicks turn 3 off

    What am I doing wrong here?
  • ADVERTISEMENT
  • #33 20848822
    p.kaczmarek2
    Moderator Smart Home
    omniron wrote:

    "Question: How do I setup single button to control two relays (first on click, second on double click)?
    A: If you set a pin role to 'Button', you will get a second textbox after saving pins. First checkbox is a channel to toggle on single click, and second textbox is a channel to toggle on double click."
    under
    Web Application, Pin Settings:
    Here you can configure your device. "
    Could not find 'Button' in the drop down list (is it Btn??)
    Even Btn did not offer the toggle, just numbers.

    Btn, once saved, will show two text fields, where you can enter indexes of first and second channel.

    omniron wrote:

    Since the switch of this unit is at RXD1
    https://www.elektroda.com/rtvforum/topic3958242.html#20836512
    would this be correct?

    setChannelType 1 toggle
    setChannelType 2 toggle
    setChannelType 3 toggle
    // Btn_ScriptOnly is set on RXD1
    addEventHandler OnClick RXD1 ToggleChannel 1
    addEventHandler OnDblClick RXD1 ToggleChannel 2
    addEventHandler On3Click RXD1 ToggleChannel 3

    This will not work because command expects a P index, so it should be a number. Look up RXD1 in documentation to know which Px is it. Write P index in script without P.





    omniron wrote:

    Looked up what pin RXD1 is (10)
    used this:

    setChannelType 1 toggle
    setChannelType 2 toggle
    setChannelType 3 toggle
    // Btn_ScriptOnly is set on 10
    addEventHandler OnClick 10 ToggleChannel 1
    addEventHandler OnDblClick 10 ToggleChannel 2
    addEventHandler On3Click 10 ToggleChannel 3

    Now:
    1 click does nothing (there is a faint click, as if one of the relays wants to turn on but is stopped right immediately)
    when on, 1 click turns all off,

    2 clicks turn all on,
    2 clicks turn all off,

    3 clicks turn 3 on,
    3 clicks turn 3 off

    What am I doing wrong here?

    Have you set P10 (RXD1) to Btn_ScriptOnly?
    Or have you configured both classic Button and script at the same time?
    If you configured them at the same time, then they will cancel each other and break stuff.
    If you want to script buttons in autoexec.bat, change Btn role to Btn_ScriptOnly.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #34 20848855
    omniron
    Level 10  
    THAT was it!
    Screenshot showing sample script code and part of a conversation on a tech forum.

    I just added the autoexec.bat like you suggested, didn't know about scripts or btn script only stuff.
    Probably buried in some documentation, sorry.
    Thank you again!
  • #35 20848903
    p.kaczmarek2
    Moderator Smart Home
    Well, it's logical, if Btn (Button) toggles the first channel on single trick, and second channel on double click, and if you also, futhermore, script it to toggle the same channel on single click in autoexec.bat, then it will toggle it two times, effectively canceling the toggle. This is what you yourself said:
    Quote:

    1 click does nothing (there is a faint click, as if one of the relays wants to turn on but is stopped right immediately)

    When I have read that message, I already suspected what's going on.
    Helpful post? Buy me a coffee.
  • #36 20850161
    omniron
    Level 10  
    Quote:
    Well, it's logical,

    Only if one knows what the logic is.
    I never installed any of these scripts, didn't know that that particular script has to be disabled before exercising your autoexec.bat.
    Would have been nice if you had told me to look out for this instead of banging my head.

    Here is another logic issue:
    The time from click to relay is really short now, so short that instead of selecting the second relay it thinks I'm switching relay1 off right away.
    I found
    // SetButtonTimes [ValLongPress] [ValShortPress] [ValRepeat]
    // Each value is times 100ms, so: SetButtonTimes 2 1 1 means 200ms long press, 100ms short and 100ms repeat

    Where can I look up what the current time is set to in this 30407T?

    I learned that tuya sets some of these units up so they are croocked from the getgo. Customers are then forced to install an app on their phones. Only then can they update the unit and with that update the right function is also delivered.
    Very shady tactic from tuya and/or their attached companies, to spread their apps on people's phones.

    Quote:
    When I have read that message, I already suspected what's going on.

    I try my best to give you all the information I can gather. I have been in your shoes.

    I really recommend to include some info about the issue of parallel functions in the Autoexec headers.
    In my case:
    // If you want to implement a different function/task for the switch(es), you must first remove the original function/task from that switch via ...(flag?) in (here and here).

    I will work on the howto of installing OTA.
    Some of the pitfalls were severe, I hope cloudcutter will be open to some changes in their guides.

    Bottom line, my gratitude to your energy and knowledge, keep it up please, you are doing a really great job!!
  • #37 20850243
    p.kaczmarek2
    Moderator Smart Home
    omniron wrote:

    The time from click to relay is really short now, so short that instead of selecting the second relay it thinks I'm switching relay1 off right away.

    First of all, do you have "instant button reaction" flag enabled? This will break double click event, etc.
    [BK7231N/CB2S] KMC Smart Tap Mini Teardown and configuration
    Helpful post? Buy me a coffee.
  • #38 20850755
    omniron
    Level 10  
    I did not set that instant button flag because you informed me:
    Quote:
    It's a known problem, you can make button react faster but it will break click and double click events.


    I had tried to save the current condition/settings, how do I do that?
    It says
    Quote:
    It is better to just download only config partition and LittleFS TAR

    but could not find a "config partition" or "LittleFS TAR", sorry.
  • #40 20850804
    omniron
    Level 10  
    The range of these cbs2 Tuya-chip 30407T is really abysmal.
    I have an ESP based KMC 30608 with TYWE3S which is nearly 2x as far AND behind 3 walls and it works great.
    When I place the cbs2 Tuya-chip 30407T unit at the same location it doesn't even register, tried 3 units, different position etc.
    Wow

    Added after 12 [minutes]:

    Yes, I checked that of course, there is no config partition, just a read RF config and OBK config.
    Considering that I did not configure the switch timing, I think the OBK config is useless?
    And it probably has nothing to do with RF config?
    Should I zip the contens of OBK config?
    Or is the config partition here: "read tuya GPIO config from 0X1EE000"?
  • #42 20852326
    p.kaczmarek2
    Moderator Smart Home
    Please edit the attachment and remove OBK config binary data. It contains your SSID and password. If you want to share template with other users, just go to Web App and copy JSON from there.

    OBK config data is useful if you are making a backup for yourself.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #43 20852771
    omniron
    Level 10  
    It's ok, I'm aware of that since beginning, it's a temporary AP and credentials.
    Sadly, none of these tuya chip units work with my actual IOT router.
    ALL of the different ESP units run with that IOT router since their beginning and for quite a while now.
    So I just set up something to get these tuya chips going.

    I simply wanted to provide you with information of my unit, so you could kindly maybe help me set the switch timings right please.

    But as mentioned here
    https://www.elektroda.com/rtvforum/topic3958242-30.html#20850755
    I could not find any "config partition" or "LittleFS TAR", so I copied what I could for you.

    Where can I look up what the current time is set to in this 30407T?
    I need to change it to something workable.
    Right now even a fast 2x click is interpreted as relay1onrelay1off.
  • #44 20854639
    omniron
    Level 10  
    Hi, could you find out where the (short) timing of the current "relays" is?
    I shiver in anticippppation...
    Spoiler:



    thanks!
  • #45 20854725
    p.kaczmarek2
    Moderator Smart Home
    You need to use SetButtonTimes command and make sure that your BTN role is Btn_ScriptOnly.
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    
    setButtonTimes	[ValLongPress][ValShortPress][ValRepeat]	Each value is times 100ms, so: SetButtonTimes 2 1 1 means 200ms long press, 100ms short and 100ms repeat.
    

    I'd suggest first using:
    
     SetButtonTimes 2 1 1 
    

    and then adjusting values to suit your needs
    Helpful post? Buy me a coffee.
  • #46 20856237
    omniron
    Level 10  
    I had tried that, but thought it didn't work since no change.
    Thought it's similar to the
    Btn/Btn_ScriptOnly/Btn_Tgl_All
    issue, where
    Btn_Tgl_All
    had to be removed explicitly before
    setChannelType 1 toggle
    and
    addEventHandler OnClick 10 ToggleChannel 1
    could work.
    So I thought we first need to remove the timing from the old setting to be able to use the new setting.
    Now I tried it with even longer times
    SetButtonTimes 6 4 4
    and that's close to the Tasmota settings of my other switches.
    Here is the autoexec.bat file:

    // this is for the dreaded tuya-chip version of the 30407T, version 1.17.334
    // you must change the switch (button) role for this to work
    // on your unit's webpage/IP, select "Launch web Application"
    // select "Config"
    // under "Pin Settings:"
    // find "10" and change "Btn_Tgl_All" to "Btn_ScriptOnly"
    // click "Save Pins" at the bottom
    // select "File System"
    // select "Creat File"
    // type "autoexec.bat" (depending on your browser confirm with "ok")
    // click on new "autoexec.bat"
    // copy and paste below and click "Save"
    // back at unit's webpage/IP, click "Restart" 
    
    // new roles of the channels (relays)
    setChannelType 1 toggle
    setChannelType 2 toggle
    setChannelType 3 toggle
    // switch (button) is at Pin 10
    addEventHandler OnClick 10 ToggleChannel 1
    addEventHandler OnDblClick 10 ToggleChannel 2
    addEventHandler On3Click 10 ToggleChannel 3
    // press, release and hold times to toggle relays via unit's switch (button)
    SetButtonTimes 6 4 4
    

    Thank you!
  • #47 20860450
    omniron
    Level 10  
    Hi,
    this is about the first unit I tried to OTA (and messed up a bit)
    5x on/off gets me to save mode, fast LED blink.
    Save mode WiFi works.
    Filled pin assignments and WiFi SSID and PW, they stick.
    Can switch relays on etc.

    Then I try Web App but it's blank.
    Then Config/OTA
    Copied OpenBK7231N_1.17.335.rbl (rbl file as you suggested) to each servers' directory,
    Tried both Apache and nmap, the file is there.

    I enter the links in "URL for new bin file", f.i.
    127.0.0.1(or 192.168.4.1)/OpenBK7231N_1.17.335.rbl

    The relays turn off and LED now blinks slow for a while and then goes off completely (until next 5x on/off).
    Hotspot vanishes,
    Unit does not connect to WiFi (yes, tried static IP, also)
    Relays work again.
    When power cycled, LED blinks a few times and goes off again and stays off.
    Relays still work.

    Pressing long won't get into save mode (neither fast or slow blinking save mode)

    Is the unit toast or can you save it with some of your magic please?
    without soldering, thanks!
  • #48 20860546
    p.kaczmarek2
    Moderator Smart Home
    Why web app was blank? It should not be blank as long as you have device on your network as your WiFi client and can reach internet. Web App is downloaded from official Github, it's open source VUE app.
    Helpful post? Buy me a coffee.
  • #49 20860783
    omniron
    Level 10  
    That's exactly the problem, "30407t does not connect to WiFi (yes, tried static IP, also)".
    30407t works only with it's own WiFi Save mode, i.e I can connect to it only that way.
    I do program my WiFi SSID and pw, and 30407t retains them after reboots/reset, but it does not use them to connect to my WiFi.
    This 30407t is messed up, I probably wrote over some sections during my OTA experiments.
  • ADVERTISEMENT
  • #50 20860795
    p.kaczmarek2
    Moderator Smart Home
    Maybe you've erased MAC and must restore Tuya RF partition? Is your MAC address ending with 00 00?

    Router will not handle correctly two clients having the same MAC address.
    Helpful post? Buy me a coffee.
  • #51 20861781
    omniron
    Level 10  
    It works!
    MAC was there, hooked up wireshark and it was requesting a weird DNS.
    Changed my router to that (public,hardwired) IP and was then able to reroute.
    Flashed to newest FW, added pins and Autoexec .
    Can all those items (FW, pin template and Autoexec) be saved/flashed in one go?
    Or do I have to make the changes one by one, for each 30407t?
    Thanks again for getting these tuya chip units to work with your fine software and help!!
  • #52 20861894
    p.kaczmarek2
    Moderator Smart Home
    What kind of weird DNS? Can you provide more information? If that's a bug, then I need to fix it
    Helpful post? Buy me a coffee.
  • #53 20862020
    omniron
    Level 10  
    I don't think it is a bug, it was because I messed up during installation (still have to write that experience up).
    It was non-sensical and didn't resolve, there was no DNS server at that address.
    It was strange since I reroute DNS requests (53) to my router's DNS, but now think that this option does not exist for guest WiFi.
    Anyhow, all good, thanks again!
    Is there a way to "superflash" your nice firmware + pin template + Autoexec all at once?
    Or can I just use the image of an existing unit the 30407t from this thread) to clone the next (exactly similar HW of course)?
    Sans RF/Network section (like MAC, sensitivity etc)
    That woud be great!
  • #54 21239701
    hartzell
    Level 7  
    @omniron -- Did you ever do a writeup of what it took to get your KMC plugs flashed? I'm looking to do the same thing....
  • #55 21240170
    omniron
    Level 10  
    sorry, no, whatever is here, that's it.
    The Tasmota KMC-30407 were much better devices than these mini taps.
    Gifted most of these away.

Topic summary

The discussion revolves around the teardown and configuration of the KMC Smart Tap Mini (model KMC-30407) featuring the CB2S chip and BK7231N module. Users share their experiences with the device's flashing process, highlighting issues with OTA (Over-The-Air) updates and the challenges posed by the CB2S chip. Several users express frustration over the device's inability to connect to WiFi after flashing, and the need for proper pin assignments to control relays individually. Solutions include using the Tuya-cloudcutter tool for flashing and configuring the device through scripts in the autoexec.bat file. Users also discuss the importance of ensuring correct timing settings for button presses to avoid misinterpretation of relay commands. The conversation emphasizes the need for reliable documentation and user experiences to facilitate successful flashing and configuration of these devices.
Summary generated by the language model.
ADVERTISEMENT