logo elektroda
logo elektroda
X
logo elektroda

BK7231T Feit Smart Wifi Dimmer: TuyaMCU, Programming & 3-Way Mode Tips (Amazon Purchase)

bleeblak8 8490 59
ADVERTISEMENT
  • #31 20483757
    wesduda
    Level 5  
    I was pretty much able to make it work but.....

    ...as you can see in my video, I can toggle the switch in the MQTT server
    and it does change the state of the OpenBeken button, but does not change the actual
    load (light-bulb) connected to the wall-switch.
    On the other hand, if I click on the OpenBeken interface, it does switch the light on/off
    but is not reflecting the state of the MQTT broker sliders...

    Can someone show me a sample yaml script for my application?

    ...any advice?

    Thanks, wd




  • ADVERTISEMENT
  • #32 20485168
    mattj
    Level 9  
    Not sure the issue you're facing, but sharing my working config (across a number of these devices).

    No pins configured...

    /autoexec.bat
    startDriver TuyaMCU
    setChannelType 1 toggle
    setChannelType 2 dimmer
    setChannelType 4 OffDimBright
    tuyaMcu_setDimmerRange 0 1000
    linkTuyaMCUOutputToChannel 1 bool 1
    linkTuyaMCUOutputToChannel 2 val 2
    linkTuyaMCUOutputToChannel 3 val 3
    linkTuyaMCUOutputToChannel 101 enum 4

    ^ on bulbs which are unable to dim too low, I increase the lower setDimmerRange value.
    Home Assistant MQTT YAML
    light:
      - unique_id: "xxx_ceiling_light"
        name: "XXX - Ceiling Light"
        state_topic: "light_XXX/1/get"
        command_topic: "light_XXX/1/set"
        brightness_command_topic: "light_XXX/2/set"
        brightness_state_topic: "light_XXX/2/get"
        brightness_scale: 99
        qos: 1
        payload_on: 1
        payload_off: 0
        retain: true
        optimistic: true


    Side note: I think HA Discovery for TuyaMCU devices would be a great priority feature - would enable using these OpenBeken models as a "Device" in Home Assistant, and would make the platform more approachable for new folks. :)
  • #33 20485890
    wesduda
    Level 5  
    Thanks mattj,
    ...is this the place to write the yaml script? (see the picture)

    BK7231T Feit Smart Wifi Dimmer: TuyaMCU, Programming & 3-Way Mode Tips (Amazon Purchase)
  • #34 20485960
    p.kaczmarek2
    Moderator Smart Home
    No, scripts are placed in Launch Web Application -> LittleFS -> create new file (autoexec.bat) and save.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #36 20486202
    p.kaczmarek2
    Moderator Smart Home
    mattj wrote:

    Side note: I think HA Discovery for TuyaMCU devices would be a great priority feature - would enable using these OpenBeken models as a "Device" in Home Assistant, and would make the platform more approachable for new folks. :)

    I will try to look into that, which channel types for TuyaMCU should have top priority?

    btw it seems that your request just boils down to "make custom channel types discoverable" because the OBK frontend is not aware about TuyaMCU and channel values are seamlessly mapped to TuyaMCU dpIDs.... which TuyaMCu devices do you have in mind with those request? There may be a slight issue with TuyaMCU dimmers because we have Toggle and Dimmer as separate channels and the Discovery would have to pair them somehow... but I will try to figure it out, at least for the common types of devices.

    @mattj do you also think that old Hass yaml generator can be removed and instead we can allow copying out the discovery yaml and also modification on that? I think we spoke about that about a month ago
    Helpful post? Buy me a coffee.
  • #37 20487017
    wesduda
    Level 5  
    ...how can I delete these startup commands from this line?

    BK7231T Feit Smart Wifi Dimmer: TuyaMCU, Programming & 3-Way Mode Tips (Amazon Purchase)

    I think this may be my issue...
  • #38 20487117
    p.kaczmarek2
    Moderator Smart Home
    Is there some kind of problem with removing startup command?
    It seems to work for me with 1.15.591 build:
    BK7231T Feit Smart Wifi Dimmer: TuyaMCU, Programming & 3-Way Mode Tips (Amazon Purchase)
    Helpful post? Buy me a coffee.
  • #39 20491408
    wesduda
    Level 5  
    ...if I select everything in the box and delete it, click "Submit" and the whole string reappears in the dialog box.
    Should it be like that?

    ...I note that there are two drivers running, should it be like that?

    BK7231T Feit Smart Wifi Dimmer: TuyaMCU, Programming & 3-Way Mode Tips (Amazon Purchase)

    Added after 44 [minutes]:

    What am I doing wrong?
    BK7231T Feit Smart Wifi Dimmer: TuyaMCU, Programming & 3-Way Mode Tips (Amazon Purchase)

    BK7231T Feit Smart Wifi Dimmer: TuyaMCU, Programming & 3-Way Mode Tips (Amazon Purchase)


    Can you direct me somewhere, perhaps there is a different group where newbies like myself ask questions like this???
  • #40 20491560
    p.kaczmarek2
    Moderator Smart Home
    You can ask here, I will try to help.

    You have TuyaMCU enabled and DGR (Device Groups), did you set something in Config->Device Groups panel?
    Screenshot of the BK7231T_FourRelays control panel showing connection status and configuration.

    Why do you have a Power channel? Is it measuring energy? Maybe you need to clear role of one of unused channels, that you have left over from previous experiments?
    User interface displaying information about the BK7231T_FourRelays device


    wesduda wrote:
    ...if I select everting in the box and delete it, click "Submit" and the whole string reappear in the dialog box.
    Should it be like that?

    It must be a bug, you can try entering anything like "sagasgs" random string, but I don't know how do you manage to get that bug.
    User interface with a command input field for BK7231T_FourRelays startup commands.
    Helpful post? Buy me a coffee.
  • #41 20492692
    mattj
    Level 9  
    >>20491408

    @p.kaczmarek2 is the man for all things OpenBK.

    But in addition to his post above, I noticed your Home Assistant config is missing an item.

    Source docs: https://www.home-assistant.io/integrations/light.mqtt/

    You need to have both “MQTT” AND “Light”… like this:

    # Example configuration.yaml entry
    mqtt:
      light:
        - command_topic: "office/rgb1/light/switch"


    MQTT defines the integration, then you can have components (e.g., light, switch, etc.) within MQTT.
  • #42 20493348
    michael6
    Level 2  
    For what it's worth, I pulled together all the various tidbits in this thread into one comprehensive guide on how to update the FEIT Electric Smart WiFi Dimmer switch with OpenBK7231T: feit-electric-dimmer-openbk7231t-conversion.md. This document describes what I have done (based on the comments here) to update a number of these dimmer switches. If I missed anything or could improve the explanation, please tell me and I will update the guide.
  • #43 20493351
    mattj
    Level 9  
    Awesome guide @michael6! very easy to follow, and matches the config I used.

    Couple minor notes, (on Windows, at least) using the latest flashing tool works like a charm. Even has the ability to download the latest version automatically. I think the UART method is considered obsolete.

    https://github.com/openshwprojects/BK7231GUIFlashTool
  • #44 20493353
    michael6
    Level 2  
    mattj wrote:

    Couple minor notes, (on Windows, at least) using the latest flashing tool works like a charm. Even has the ability to download the latest version automatically. I think the UART method is considered obsolete.

    https://github.com/openshwprojects/BK7231GUIFlashTool


    Hmmm ... I will have to check that out. I am using a Mac so clearly running a Windows application is not a desirable path. Running a Python script is operating system agnostic hence the method I gravitated to. However I see that this flashing tool claims to be runnable using mono. While I would much rather install Python to run a script (because any hacker usually has Python installed already) than install mono to run a Windows app, I will test it out to see if I can get that path working on my Mac.

    Thanks!
  • #45 20493361
    wesduda
    Level 5  
    Thanks for all help, there is a lot of progress in my knowledge of the subject. :)
    ....but as per Murphy's law, I was trying to do the firmware update ota
    and I chose the wrong file....I will take the switch apart tomorrow, and flush the right firmware
    and follow michael6's guide to tweak this dimmer sw. to work with mqtt.
    For many years, I'm an electrician by trade, and I believe those dimmers are well manufactured,
    solid and unbelievably cheap, at least in my area.
    The open source firmware makes the switch so attractive :)

    Thanks again, wd
  • ADVERTISEMENT
  • #46 20540219
    mattj
    Level 9  
    I have a follow-up question. Is there any way to enable additional actions? e.g., double click or “hold” actions on the main button. Or is that an issue with the TuyaMCU?

    Ideally would love the ability to present those actions via MQTT.
  • #47 20540244
    p.kaczmarek2
    Moderator Smart Home
    There are currently examples in docs for button actions for normal buttons:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md

    However, they are not possible in TuyaMCU because TuyaMCU only reports new relay states as booleans so there is no way to tell if the button is pressed now or not.

    One thing you could do is to cut off the buttons from TuyaMCU and manually route a wire from button to WiFi module unused GPIOs.
    Helpful post? Buy me a coffee.
  • #48 20540315
    mattj
    Level 9  
    Thanks - that does make sense (I had a sneaking suspicion that the TuyaMCU would get in the way). Not going to chance significant hardware mods on a mains-powered switch - not that ambitious :)

    Side note: for others who might be in the same boat - I have ~30 of these running now, been pretty solid. I ended up creating an MQTT group topic for these specific switches which enable me to batch update, and also batch change the state of things like the LED off/dim/bright state. This guide here was super helpful: https://www.elektroda.com/rtvforum/topic3947241.html
  • #49 20637768
    mattj
    Level 9  

    I had a few follow-up questions. First off - let me say that these switches have been pretty rock solid if anyone ends up reading this and is looking to buy. Still the best "true" (dimmers on both ends) three-way HA-compatible dimmers I could find.

    1) The Off/Dim/Bright toggle for the LED indicator - is there any way to expose this via MQTT (and HA Discovery)? It works via the webUI and via MQTT group commands - but I'd love to add it in as a toggle on Home Assistant.

    2) Any idea if transition times would be enabled at some point in the future? MQTT Light appears to support them with the JSON & template schemas. This would be a helpful add for all Beken lights. (Does this work in Tasmota compatible API? - I haven't checked yet.)

    3) I assume that the TuyaMCU handles the dimming function.... Adjusting the "SetDimmerRange" lower bound works from the WebUI/MQTT, but if you use the physical controls, it still dims lower. I figure this is outside of the BK-chip controls, but thought I'd ask if anyone knew.

    Thanks all!
  • #50 20909905
    bios2k
    Level 1  

    Hello all,
    I just bought the Feit Dimmer from Amazon.ca and got the new version.
    The old version had a chip soldered on it. I was used to unsoldering and resoldering an ESP8266 with Tasmota...

    Now, I need to work with OpenBK. It was the first time, and I was able to make the switch work and control it with OpenHab.
    That being said, I tweaked the autoexec.bat file to map the LED status to the state of the power.
    I like to have the DIM status LED when the light is off and the status OFF when the light is ON.
    This helps to find the switch when it's dark in the room.

    Here is the Autoexec.bat:

    startDriver TuyaMCU
    setChannelType 1 toggle
    setChannelType 2 dimmer
    setChannelType 4 OffDimBright
    tuyaMcu_setDimmerRange 0 1000
    linkTuyaMCUOutputToChannel 1 bool 1
    linkTuyaMCUOutputToChannel 2 val 2
    linkTuyaMCUOutputToChannel 3 val 3
    linkTuyaMCUOutputToChannel 101 enum 4
    AddChangeHandler Channel1 == 0 SetChannel 4 1
    AddChangeHandler Channel1 == 1 SetChannel 4 0

  • Helpful post
    #51 21030177
    GoofySpeed
    Level 6  
    I am not sure if this information will help anyone at this point since it only adds a second dimmer for the ability to set the minimum brightness for use with the physical dimmer buttons only.

    User interface of the Test_Switch app with brightness adjustment sliders.

    First, a word of caution: when separating the two halves of the switch, make sure you lift the top halve straight up from the bottom halve because header pins connect the electronic circuit board in the white button halve to the mechanical portion in the black halve, and you don’t want to bend or break them.

    Separate parts of an electrical switch on a blue background.

    To flash, I used a CH341A serial programmer with male DuPont cables that I had just pushed into each via hole for the 3V, GND, TX1, RX1 and touched CEN to GND to start the programming. After programming, you can move from using TX1/RX1 to TX2/TX2 if you would like to read the UART output. If you try to flash with a CH341A using its supplied 3.3V output, first check to make sure that it actually outputs 3.3V. Most of the black and yellow versions on the market actually incorrectly output 5V on the 3.3V pin, and 5V might damage the FEIT circuit board. A number of CH341A voltage fix how-tos on the internet to fix it.

    Circuit board with pin labels: TX1, RX1, CEN, 3V, GND.

    When I issued the command “startDriver TuyaMCU”, followed by “tuyaMcu_sendQueryState” on the logs screen of the web app, I get the following response:
    Debug:CMD:cmd [tuyaMcu_sendQueryState]
    Info:CMD:[WebApp Cmd 'tuyaMcu_sendQueryState' Result] OK
    Info:TuyaMCU:Received: 55 AA 03 07 00 05 01 01 00 01 00 11 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 12
    Info:TuyaMCU:ParseState: id 1 type 1-bool len 1
    Info:TuyaMCU:ParseState: byte 0
    Debug:TuyaMCU:ApplyMapping: id 1 (val 0) not mapped
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 02 02 00 04 00 00 03 E8 04 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 2 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 1000
    Debug:TuyaMCU:ApplyMapping: id 2 (val 1000) not mapped
    Info:TuyaMCU:Received: 55 AA 03 07 00 08 03 02 00 04 00 00 00 0A 24 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 15
    Info:TuyaMCU:ParseState: id 3 type 2-val len 4
    Info:TuyaMCU:ParseState: int32 10
    Debug:TuyaMCU:ApplyMapping: id 3 (val 10) not mapped
    Info:TuyaMCU:Received: 55 AA 03 07 00 05 65 04 00 01 00 78 
    Info:TuyaMCU:ProcessIncoming[v=3]: cmd 7 (State) len 12
    Info:TuyaMCU:ParseState: id 101 type 4-enum len 1
    Info:TuyaMCU:ParseState: byte 2
    Debug:TuyaMCU:ApplyMapping: id 101 (val 2) not mapped
    

    This tells us that the switch has the following IDs: id 1 type 1-bool, id 2 type 2-val, id 3 type 2-val, and id 101 type 4-enum that aren't currently mapped. It also gives us the maximum brightness of 1000 on id 2 and factory minimum brightness of 10 id 3.

    With that information the following is the autoexec.bat file that I generated to utilize all of the functions of the switch along with descriptions of what each command is doing so that others might learn for themselves.
    # Activates the TuyaMCU Driver
    startDriver TuyaMCU
    # Sets channel 1 to be a toggle to turn device ON/OFF
    setChannelType 1 toggle
    # Sets channel 2 to be a dimmer to dim the light(s)
    setChannelType 2 dimmer
    # Sets channel 3 to be a dimmer to set the minimum brightness (This dimmer will allow you to set the minimum brightness level to fix light flicker, premature turning off of light, when using the physical dimmer buttons only)
    setChannelType 3 dimmer
    # Sets channel 4 to a selector to set the LED indicator brightness level on the switch from Off/Dim/Bright
    setChannelType 4 OffDimBright
    # Sets the dimmer range from minimum brightness of 10 and max brightness of 1000 (Adjust the minimum brightness level here to fix light flicker, premature turning off of lights, when adjusting brightness from MQTT or in GUI only)
    tuyaMcu_setDimmerRange 10 1000
    # Links dpId 1 with a boolean(1) variable type to channel 1 to toggle device ON/OFF
    linkTuyaMCUOutputToChannel 1 1 1
    # Links dpId 2 with a integer value(2) variable type to channel 2 to dim the light(s)
    linkTuyaMCUOutputToChannel 2 2 2 
    # Links dpId 3 with a integer value(2) variable type to channel 3 to set minimum brightness when using physical dimmer buttons on switch
    linkTuyaMCUOutputToChannel 3 2 3 
    # Links dpid 101 with a enum(4) variable type to channel 4 to adjust the LED indicator on the switch from Off/Dim/Bright
    linkTuyaMCUOutputToChannel 101 4 4
    
  • #52 21149733
    GikOnFlik
    Level 1  
    First, let me say thank you very much for all your contributions. So much useful information.

    I have 5 of these switches with bK7231N. Looks like I did something wrong, because out of 5 only 1 shows up in Home Assistant with ability to control light. The other 4 do show up as well, but only have diagnostic info. I’m using MQTT Mosquitto broker, maybe this is my problem and I should just go with hands-on approach and do it in YAML? Home Assistant app interface displaying device information for BK7231N with lighting control. BK7231N device screen with diagnostic information in the Home Assistant app.
  • #53 21150588
    p.kaczmarek2
    Moderator Smart Home
    You need to do Home Assistant Discovery after you configure the device.
    [youtube]
    https://www.youtube.com/watch?v=pkcspey25V4
    [/youtube]
    Helpful post? Buy me a coffee.
  • #54 21272408
    hughhallhh56
    Level 1  
    Many thanks to all. I have to this point only used TASMOTA and was fortunate that all the globe bulbs and CE Home switches let me install Tasmota OTA. Well I thought I would get some more switches and automate my vacation property. I was at a store called the Big Box Outlet the other day and what would I see but boxes of Feit 3 way switches for the price of $9 CDN for a box of 3. All the items that are returned to Costco usually end up at this store and there were 40 boxes. Couldn't help myself....

    So this was my first attempt at opening a device and replacing the binary. I am just wrapping up for the evening and am so grateful for all the content posted here by everyone. In under 3 hours I managed to open the switch, load the current binary (my Feit had the BK7231N version), and install two of them into my house wiring lab. They are working like a charm. Tomorrow I will move on to getting them into Home Assistant.

    I am going to miss Tasmota.
  • #55 21272497
    p.kaczmarek2
    Moderator Smart Home
    Thank you and good luck. Btw, you can also try enabling PowerSave on your device, and keep it on if there are no drawbacks. Just add "PowerSave" in separate line in autoexec.bat. This will reduce power usage and stress on the power supply.
    Helpful post? Buy me a coffee.
  • #56 21327933
    hans109h
    Level 1  
    I don't have a need for dimmer control with my switch. Is it possible to use the physical dimmer buttons to publish MQTT messages instead?

    Thanks,

    Hans
  • ADVERTISEMENT
  • #57 21327936
    p.kaczmarek2
    Moderator Smart Home
    Sure, what would you like to publish? Do you want to attach a button to existing device directly, or do you want to script button to publish something?

    Have you seen our autoexec.bat samples?
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    Helpful post? Buy me a coffee.
  • #58 21327958
    hans109h
    Level 1  
    >>21327936 Thank you for pointing me in the right direction, "Simple example showing how to do MQTT publish on button event (double click, etc). It also includes button hold event to adjust dimmer."

    My current devices for this use case either came with or converted to ESP8266 and flashed with Tasmota, but if I pick up some more I'm happy to know that it would work.

    Hans
  • #59 21362064
    olidel001
    Level 1  
    Thank you for this thread. It has helped me to switch to OpenBeken with those Feit smart switches. However, it took me a long long time to find the proper recipe. This is what I can say related to the initial setup to flash those switches.

    - I have done the steps below on 3 different Feit switches. I believe from memory that they had the version 1.23 written on the electronic board.
    - To be able to flash the latest OpenBeken firmware, I just soldered a wire on the NRST indicated by the previous post. However, I didn't try to use the CEN connector as described above by GoofySpeed, so this one may also work so you can avoid soldering something. So, I have used only the following connection points: 3V, GND, TX1, RX1, and NRST.
    - For the remaining of the 4 physical connections (3V, GND, TX1, RX1) I just used simple jump wires to connect everything to a UART to USB device. Of course, the NRST wire had to be shortened with ground at the start of the Feit device to be able to flash the switch.
    - To flash I have used the "ltchiptool" tool, that you can find here: Link. However, you need to be aware that this is a python module and so you install it with pip. It is worth noting that I have done this flash process with Ubuntu. All the other tools such as "BK7231 GUI Flash Tool" (Link) or some other python applications did not work. "ltchiptool" was the only tool that worked reliably. By the way, I have tried those other tools under Windows or Linux without any success. Also, "ltchiptool" worked fine with the CLI version of it. I was unable to make it work under Linux with the GUI interface but this is probably due to something that I did not do correctly with the wxpython python module.
    - Finally, to flash the device I have used the following command.

    1- to make a backup of the currently original firmware:
    python3 -m ltchiptool flash read BK7231N firmware.bin
    Note that I didn't try to reinstall this "firmware.bin" firmware, so I don't know if this file is really a good backup.
    2- to flash the device:
    python3 -m ltchiptool flash write OpenBK7231N_QIO_1.17.772.bin
    Note that I'm seeing an error at the end of the flash process but it seems to be without consequences. Also, as long as the flash process was ongoing I had to keep the NRST connection grounded. It takes roughly a minute to have the process completely done and you have a "progress bar" that gives you an idea of how far the process is.

    Basically that's it. Hope this will help somebody.
  • #60 21378804
    edwarddoty
    Level 1  
    I picked up 8 of these 4 with the TYWE3S and 4 with the 7231T chips. So far I have only worked with the 7231T models. I was able to flash them easily with cloud cutter and got the autoexec.bat file working.

    My first question is on device groups. I have set a group "patiolights" on both switches but, when I toggle either switch the other does nothing. I did check the send and receive check boxes. I used the web app to test and from either switch's web app it will toggle the other switch but not the local switch. I see send and receive counts on the two devices home pages. Am I doing something wrong?

    Second, to flash the TYWE3S, Confirm I need to desolder and flash via the GUI tool?

Topic summary

The discussion revolves around the BK7231T Feit Smart WiFi Dimmer, focusing on programming challenges and solutions related to the TuyaMCU. Users shared experiences with flashing the device using various methods, including grounding the NRST pad and using FTDI USB to TTL chips. Several users reported success in configuring the dimmer for 3-way switching and controlling the LED indicator. Issues with Home Assistant integration and MQTT configuration were also addressed, with suggestions for writing the autoexec.bat script and YAML configurations. The conversation highlighted the importance of using reliable power supplies and provided insights into troubleshooting common problems encountered during setup.
Summary generated by the language model.
ADVERTISEMENT