Elektroda.com
Elektroda.com
X

[BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

p.kaczmarek2 89280 1198
This content has been translated flag-pl » flag-en View the original version here.
  • azavialov
    Level 1  
    @p.kaczmarek2 Let me make a small correction to your project.
    
    --- hal_wifi_bk7231.c.orig	2022-10-30 08:24:59.000000000 +0300
    +++ hal_wifi_bk7231.c	2022-10-30 12:14:00.186536100 +0300
    @@ -308,6 +308,8 @@
     
     	wNetConfig.wifi_mode = SOFT_AP;
     	wNetConfig.dhcp_mode = DHCP_SERVER;
    +	os_strncpy((char*)wNetConfig.gateway_ip_addr, (char*)APP_DRONE_DEF_NET_GW, sizeof(wNetConfig.gateway_ip_addr));
    +	os_strncpy((char*)wNetConfig.dns_server_ip_addr, (char*)APP_DRONE_DEF_NET_GW, sizeof(wNetConfig.dns_server_ip_addr));
     	wNetConfig.wifi_retry_interval = 100;
     
     	if (1)
    

    This will allow you to get an IP address via DHCP during the initial configuration of the device on more operating systems, including Windows 10.

    Otherwise, the DHCP Server issues:
    Option (3) default router 255.255.255.255
    Option (6) DNS 255.255.255.255
    What some OS don't like

    Thanks.
  • botioni
    Level 11  
    @p.kaczmarek2 thx put sensor projact on hold until battery (sleep function add draining battery fast).
    new project ldv bulb RGBCW with drv_bp1658cj pinout is gpio8 is data and gpio24 is clock
    but not working dosent do anything some driver isu or somthing did maping to 1 0 2 3 4 any help apriciated.
  • p.kaczmarek2
    Moderator Smart Home
    @azavialov I am not at home right now and I can't check your fix, but at least one of your setting seems to be duplicated:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    @botioni did you enable "force show rgbcw controller" flag?
  • botioni
    Level 11  
    Yes flag 4 and 12 enabled ther is a therdown of a hama gu10 bulb on forum I folowd it but pinuts are not the same I configured it acording what is in the bulb I have one open thet is was broken and 1 thet is flashed with tcc the broken I can see pinout and IC
  • ns_ripper
    Level 1  
    Hi, I'm running firmware 1.14.93.
    This plug is using a BL0937.
    It is constantly reporting pulses of 1.2W even when it's in the off state.

    Log:
    Info:MQTT:Publishing val 0.000000 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 233.526138 to Droogkast/voltage/get retain=0
    Info:MQTT:Publishing val 1.294118 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 0.000000 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 1.294118 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 0.000000 to Droogkast/current/get retain=0
    Info:MQTT:Publishing val 0.000000 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 1037.111084 to Droogkast/energycounter/get retain=0
    Info:MQTT:Publishing val 0.000000 to Droogkast/energycounter_last_hour/get retain=0
    Info:MQTT:Publishing val 1.294118 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 0.000000 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 1.294118 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 234.010132 to Droogkast/voltage/get retain=0
    Info:MQTT:Publishing val 0.000000 to Droogkast/power/get retain=0
    Info:MQTT:Publishing val 1.294118 to Droogkast/power/get retain=0
  • ferbulous
    Level 15  
    @p.kaczmarek2
    Hi, looking at scripting example 3,
    Could I do something like this? Select different brightness command for each hold button action?

    addEventHandler OnHold 8
    
    DGR_SendBrightness lamps 90
    DGR_SendBrightness lamps 50
    DGR_SendBrightness lamps 10


    Is it possible to store previous variable then just select the next action?
  • botioni
    Level 11  
    is ther any way to flash back original firmware from openBK terminal ?
  • ferbulous
    Level 15  
    botioni wrote:
    is ther any way to flash back original firmware from openBK terminal ?


    No, you’ll need to use serial method to perform that.
    This instruction is taken from libretuya’s developer. I haven’t try this yet though

    
    Do this:
    - take the full dump (2 MiB / 2,097,152 bytes)
    - cut the middle of it - starting at 0x11000, all the way to i.e. 0x132000 (so it results in a bit more than 1 MiB)
    - flash it to offset 0x11000
    
    ^ this method will work for both T and N. 
    Flashing to 0x0 on T is impossible. On N it's unnecessary and causes flash wear-out. So don't ever flash to 0x0 at all.
    
  • MotoSpeed
    Level 3  
    Can I request an additional channel type? I would like to see an OffLowHigh channel type with the heading "Power indicator LED:." I've been testing with a dimmer switch that has a power indicator LED that is controlled by the TuyaMCU. The three functions are Off (0), Low (1), High (2). Currently, I have been using channel type LowMidHigh, which works, but the heading reads "Select speed:," and the three options are Low, Mid, High. I edited the webpage HTML to give an example:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • _leming_
    Level 11  
    Hello dear,

    I have two smart bays for which I cannot install the software for using them outside the cloud,
    one GOSUND SP1-C, the other AWP08L,
    After disassembling them in AWP08L, I found the BK7231T chip and this seems to be supported by software prepared by @ p.kaczmarek2,
    in the second there is a module that I cannot identify
    I am asking for information and help,
    Is it possible to reprogram AWP08L without connecting via RSp-TTL, and whether the second socket also gives a similar possibility
    Below are photos of these devices, if there is a need to do a flash dump, I will be able to do it with a little help
    Thank you in advance for any help

    greetings


    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • ExploWare
    Level 10  
    p.kaczmarek2 wrote:
    @exploware all of that shall work.
    Option to remember LED state:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    pins config CW:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    gui for CW:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I will update comment on the Relay saving page.


    Indeed, this works, I just confirmed it in my setup. Thanks!
  • p.kaczmarek2
    Moderator Smart Home
    MQTT stability will improve today. LWIP updated to latest version. Now even 20 publishes per seconds will be possible.

    MotoSpeed wrote:
    Can I request an additional channel type? I would like to see an OffLowHigh channel type with the heading "Power indicator LED:." I've been testing with a dimmer switch that has a power indicator LED that is controlled by the TuyaMCU. The three functions are Off (0), Low (1), High (2). Currently, I have been using channel type LowMidHigh, which works, but the heading reads "Select speed:," and the three options are Low, Mid, High. I edited the webpage HTML to give an example:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    I can add it for you, but what about simply adding an option to set any user-defined heading for a given channel? Would that work good for you?

    ns_ripper wrote:
    Hi, I'm running firmware 1.14.93.
    This plug is using a BL0937.
    It is constantly reporting pulses of 1.2W even when it's in the off state.

    Was the plug calibrated?

    I can add an options to always report 0 power consumption if relay is in off state, if that's needed.


    ferbulous wrote:
    @p.kaczmarek2
    Hi, looking at scripting example 3,
    Could I do something like this? Select different brightness command for each hold button action?

    addEventHandler OnHold 8
    
    DGR_SendBrightness lamps 90
    DGR_SendBrightness lamps 50
    DGR_SendBrightness lamps 10


    Maybe we could try catching both first press of button and setting a variable to 0 there, then catch each hold and increase variable on each hold. But that would send a lot of packets. I will try it for you, wait...
    but what are you trying to achieve? Why not simply two buttons, one for brightness up and second for down?



    ExploWare wrote:

    Indeed, this works, I just confirmed it in my setup. Thanks!

    Thank you, that comment saying "LED saving state not supported yet" was a left over on our part, we have also updated this comment.
  • ferbulous
    Level 15  
    p.kaczmarek2 wrote:
    Maybe we could try catching both first press of button and setting a variable to 0 there, then catch each hold and increase variable on each hold. But that would send a lot of packets. I will try it for you, wait...
    but what are you trying to achieve? Why not simply two buttons, one for brightness up and second for down?


    Indeed, that's a better solution for wall switch with more than 2 buttons.
    How does that work? Does it mean the longer I hold, the higher the variable increases,
    i) It sends brightness variable after I release button or
    ii) It keeps sending the brightness variable as I keep holding the button

    What I was trying to achieve was for 1 button wall switch.
    My nodered flows is this:
    Click - toggle lights on/off
    Double Click - toggle between cold & warm light
    Hold - Cycle between 20%, 50%, 90% brightness <-- using hold action to just cycle different brightness. using input helper,the flow retains the last brightness toggled, so if it was 90%, another hold action cycles/reset back to 20%. Next hold is 50% and so forth.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    https://pastebin.com/nmfPHqcB

    Added after 23 [minutes]:

    @_leming_

    For the one with bk7231t, you could try tuyacloudcutter to flash via ota

    As for the other unidentified module, it could be CB2L (bk7231n). Could you try opening the metal case to be sure?
  • p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

    How does that work? Does it mean the longer I hold, the higher the variable increases,
    i) It sends brightness variable after I release button or
    ii) It keeps sending the brightness variable as I keep holding the button

    It will require again firmware update (but maybe wait one day, because @btsimonh is investigating something in LFS update), but it works for me, tested right now, although you might change the added value from 2 to larger because its slow:

    
    
    // Button OnHoldStart and OnHold demo
    // Requires a button on pin 20
    // Channel 10 is used as variable
    // When button hold start happens, channel 10 is set 0
    // When a button is held, the value is added to channel 10 repeatedly.
    // Also, when adding, the channel 10 is used as a brightness for Tasmota Devices Group
    
    
    startDriver DGR
    // generate repeat after 100 ms - yes, unit here is times 100ms
    // so 1 means every 100ms
    // 2 means every 200ms
    setButtonHoldRepeat 1
    // when Hold starts, zero the variable
    addEventHandler OnHoldStart 20 SetChannel 10 0
    // when Hold repeats, add a 10 value as a step
    // AddChannelSyntax: channelindex delta minValue maxValue
    // the 0 255 is needed so we clamp the value to 255 
    addEventHandler OnHold 20 backlog AddChannel 10 2 0 255; DGR_SendBrightness roomLEDstrips $CH10
    


    also it's possible that doing startDriver DGR in autoexec.bat might be too quick, if so, we will add a delay...
  • ferbulous
    Level 15  
    @p.kaczmarek2 Thanks! it's quite amazing that you can use hold action to mimic dimming, I will try it for next update
    How would I configure it to reduce brightness? Do i just replace with negative value
  • MotoSpeed
    Level 3  
    p.kaczmarek2 wrote:


    MotoSpeed wrote:
    Can I request an additional channel type? I would like to see an OffLowHigh channel type with the heading "Power indicator LED:." I've been testing with a dimmer switch that has a power indicator LED that is controlled by the TuyaMCU. The three functions are Off (0), Low (1), High (2). Currently, I have been using channel type LowMidHigh, which works, but the heading reads "Select speed:," and the three options are Low, Mid, High. I edited the webpage HTML to give an example:

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant


    I can add it for you, but what about simply adding an option to set any user-defined heading for a given channel? Would that work good for you?


    @p.kaczmarek2 Yes, that should work. Thank you.
  • botioni
    Level 11  
    Is ther any compiling tutorial for openbk?
    I will end up writing code for it I think to recover mine bulb with the bp1658cj driver i think .
  • Sergio127
    Level 4  
    Hi, can you help me with the new device?
    I have a lamp - https://www.aliexpress.com/item/1005004319893210.html
    BL602c20 has inside, I flashed OpenBL602_1.14.90, the controller started, but the control of the lamps turned out to be through UCS1912S led driver chip. And I don't know what to do next.
    I have already identified all GPIOs.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • p.kaczmarek2
    Moderator Smart Home
    @ferbulous it is possible to use both positive and negative values for arguments.
    For the floating point or integer arguments, the math expression syntax also is supported (but don't update yet, it's early stage).
    So the following will work:
    
    // sets channel 1 to channel 2 value + 2
    setChannel 1 2+$CH2
    

    
    // sets channel 1 to channel 2 value * 2
    setChannel 1 2*$CH2
    

    
    // sets channel 1 to the logical value of MQTTOn
    setChannel 1 MQTTOn
    



    @botioni the tutorial for compiling is here:
    https://www.elektroda.com/rtvforum/topic3850712.html
    but for OBK there is one step more - read our readme - just checkout APP repository into the SDK repository for chosen platform

    @Sergio127 wow, that's a good job, you even drawn a schematic! This deserves a separate topic. Can you please post it here:
    https://www.elektroda.com/rtvforum/topic3912748.html#google_vignette but also include screenshots from the seller link (because links tends to expire) so we can add it to our online devices database?
    https://openbekeniot.github.io/webapp/devicesList.html
    Regarding your question: here is a datasheet of UCS1912S :
    UCS1912...pdf Download (187.72 kB)
    As you may see, it will require a simple driver written in C code. I can write one for you, but would you be able to test it somehow? Do you have C knowledge to help?
  • Sergio127
    Level 4  
    @p.kaczmarek2
    Quote:
    wow, that's a good job, you even drawn a schematic! This deserves a separate topic. Can you please post it here:
    https://www.elektroda.com/rtvforum/topic3912748.html#google_vignette but also include screenshots from the seller link (because links tends to expire) so we can add it to our online devices database?
    https://openbekeniot.github.io/webapp/devicesList.html
    Regarding your question: here is a datasheet of UCS1912S :

    As you may see, it will require a simple driver written in C code. I can write one for you, but would you be able to test it somehow? Do you have C knowledge to help?


    I have published a post - https://www.elektroda.com/rtvforum/viewtopic.php?p=20264437#20264437.
    I hope for your help in writing the driver, I am not a programmer myself, but I am ready to test it.
  • yonnit
    Level 2  
    Hi,

    a while ago, I purchased these fairy lights:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    I successfully flashed them with OpenBeken, but I had no luck configuring them so far and was hoping I could get some help here :)

    My device looks pretty similar to that one here: https://www.elektroda.com/rtvforum/viewtopic.php?p=19932845#19932845
    But instead of having 3 outputs for R G B mine only has one labeled LED. I think because they are individually addressable LEDs.

    I tried tracing the connection labeled LED with a multimeter and marked the pin on the WB8 chip on the attached picture.

    Here are some pictures:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Please let me know if I can provide any additional information or pictures that could help!
  • p.kaczmarek2
    Moderator Smart Home
    @yonnit I can get a driver for you for that device, but are you able to determine what kind of LEDs are used there, or at least tell us if they were able to have different colors (each LED different color) with Tuya firmware?
    I'd suspect they are ws2812b.
  • ferbulous
    Level 15  
    @p.kaczmarek2 hi, there's this odd thing happening when I'm choosing colors, the brightness keep changing.
    As for the warm & cold lights, changing the brightness also changes the rgb bulb color icon (not actual warm & cold lights) for some reason.
    Anything else I need to enable in the general settings to fix this?





    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Btw, I just reset one of my switch and 1 bulb and both are getting the same mac id:
    Device MAC: C8:47:8C:00:00:00
    I tried changing the switch mac id by grabbing random mac address from mac generator but now it's no longer connecting to wifi.
  • p.kaczmarek2
    Moderator Smart Home
    As for colors, you can open a new issue on git. Was it always like it?

    As per MAC, there is already a tool for that. Go to Web App, go to Flash tab, and press "Restore RF Config". It will create a correct RF partition if you have lost your one. It should work on both T and N.

    That option will restore MAC partition and also add a random mac to it.

    Warning: if you don't have access to easy way of emergence flashing your device, you might want to wait a day or two before doing that That option was added yesterday and is in testing phase. Still, I tested that and it worked for me well.
  • botioni
    Level 11  
    Can sombady share an homeassitant yaml config for rgbwc bulb with driver configured
    i cant find anyware documantion?
  • ferbulous
    Level 15  
    p.kaczmarek2 wrote:
    As for colors, you can open a new issue on git. Was it always like it?

    It's been like that for quite some time, i'll open a new issue there

    p.kaczmarek2 wrote:
    As per MAC, there is already a tool for that. Go to Web App, go to Flash tab, and press "Restore RF Config". It will create a correct RF partition if you have lost your one. It should work on both T and N.

    So this will be next step after doing a factory reset (7x power cycle)?
    For my switch, I've tried flashing openbk again using serial method and did 7x power cycle. I can see the AP, but I just can't connect to it
    Any other way to restore the mac somehow with serial method?
  • p.kaczmarek2
    Moderator Smart Home
    It doesn't matter if RGBCW has a driver chip or direct PWMs. It works the same way every time.

    Here's my old, reliable config for RGBCW bulb (WARNING: may contain old HA syntax):
    Code: yaml
    Log in, to see the code
  • p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

    p.kaczmarek2 wrote:
    As per MAC, there is already a tool for that. Go to Web App, go to Flash tab, and press "Restore RF Config". It will create a correct RF partition if you have lost your one. It should work on both T and N.

    So this will be next step after doing a factory reset (7x power cycle)?

    You can do this anytime you want. No need to do resets. Just remember it will change your MAC address to something random.

    Regarding AP issue - you might have gotten unlucky and gotten the build with a temporary issue which is resolved. Try latest build.


    BTW: We are migrating from daily Releases to doing Release every week or two with a stable tested features. There will be also a daily alpha builds, but they might be unstable. More details coming soon.

    Second news: I wrote a simple SPI flasher for BK, right now just with hardcoded parms, more coming soon...
    https://github.com/openshwprojects/BK7231_SPI_Flasher
    This tool is able to bring back the bricked BK chips back to live.