logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 177384 1242
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #391 19967628
    p.kaczmarek2
    Moderator Smart Home
    Today I have commited a scriptable I2C system prototype.

    I2C system will be used to map I2C devices inputs and outputs to our internal OpenBK7231 channels.

    Right now, I have added support for one device - TC74 temperature sensor:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Connection requirements are simple - solder wires to I2C1 port of WB3S:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Connect power, ground, SDA and SCL to I2C device.
    Also connect 4.7k pull up resistors on the I2C bus.
    You can use multiple I2C devices, as long as they have different addresses.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Here is my setup with two TC74 (A0 and A2 version, two different addresses):
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I2C devices can be added to any BK device. I have used Tuya 4 channels relay controller for this example.
    Relay controller was already configured:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I2C devices can be added only by commands. They will be most likely saved in LittleFS config file.
    In order to setup TC74, you must reserve a channel that is not used for relays.
    In this case, channels 5 and latter are not in use.
    So, mark a channel as temperature:
    
    setChannelType 5 temperature
    

    Then register I2C TC74 which will save output to channel 5 (0x48 here is I2C device address, I2C1 is the name of hardware I2C bus to use):
    
    addI2CDevice_TC74 I2C1 0x48 5 
    

    Result:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Same, for second TC74:
    
    setChannelType 6 temperature
    addI2CDevice_TC74 I2C1 0x4A 6 
    

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Now, for a test, let's warm up one sensor with soldering iron:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Both sensors work.

    Now, as you most likely already realize, having temperature values in MQTT automatically allows us to expose them to Home Assistant, just like with any other variables.

    WARNING: This is experimental feature, if you're a beginner and not a developer, please wait few weeks before using it.
    Now I really need to get that lightbulb with Beken and I2C RGBCW controller, do anyone know where I can buy one?

    theosoft wrote:

    I am trying do use OTA on BK7231N devices. No success...

    OTA also didn't work for me on N version, despite me changing the OTA partition address to correct one (partition addresses are different on N and on T).
    I am not sure what else to change. Will have to look into it, but I have very few N devices (only 2?). You can also try asking @btsimonh . BK7231 OTA is using entirely Beken OTA system, it was already in place, we just activate it by saving firmware to the OTA section of flash memory.


    ExploWare wrote:

    My four devices, one of the four was very steady, it was an older version,not connected to the MQTT. The wifi fix did not solve the connectivity, if anything, it worsened it according to this one way of testing.

    Fix should only affect device when it gets disconnected from WiFi, so that's really strange. I will look into it.

    theosoft wrote:

    For wifi scanning in http_fns.c
    Code: C / C++
    Log in, to see the code

    Thanks, added to repo.

    absinth84 wrote:
    IT use harcoded timezone (+1) but I start to implement the possibility to customize it from web console.

    I am integrating your changes, but some of them are incorrect. Are you sure that adding 1 to tm_hour is a correct way to handle timezone? That way you'd get a 23 + 2 = 25 instead of wrapping the day counter. You should rather add a hour offset before using gmtime function.

    Anyway, watch for the next commit, today or tomorrow.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #392 19969968
    ferbulous
    Level 18  
    @p.kaczmarek2
    Great progress with the i2c
    i had this gu10 bulb (bl605) with led driver SM2135E
    Should be the same one from this link

    EWeLink GU10 Wifi Smart Light Bulb 4W LED Spotlight Timer Function 220-240V RGB+CCT Voice Control Work With Alexa Google Home
    https://a.aliexpress.com/_mrzBDIi

    However on the next batch i ordered, the seller sent me with PWM.
    So you might need to verify with the seller first.

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • ADVERTISEMENT
  • #393 19970091
    p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

    i had this gu10 bulb (bl605) with led driver SM2135E

    I have a BL602 (if I remember correctly) bulb with SM2135E, but I need a Beken one.

    ferbulous wrote:

    So you might need to verify with the seller first.

    Do you think that seller knows on which Tuya chip is the sold product based? I 'd bet that he doesn't know and have no way to know.


    I have updated TuyaMCU code - it's finally configurable by commands (from littlefs autoexec etc).
    It's now possible to:
    - configure time offset (in hours) for NTP time
    - configure mapping between TuyaMCU outputs to our channels (for example, to save temperature or humidity from TH06)
    - manually send requests or/and updates to TuyaMCU devices
    It is not possible to set TuyaMCU variables yet (only getting works).
    NOTE: our TuyaMCU is similiar to one with Tasmota and it might have the same bugs (it does not follow TuyaMCU state managment), I will improve it later.
    Here is the script I used for TH06:
    
    ntp_timeZoneOfs 2
    addRepeatingEvent 10 uartSendHex 55AA0008000007
    setChannelType 1 temperature_div10
    setChannelType 2 humidity
    linkTuyaMCUOutputToChannel 1 1
    linkTuyaMCUOutputToChannel 2 2
    addRepeatingEvent 10 tuyaMcu_sendCurTime
    

    The 'repeating events' might not be a correct approach, I will be investigating it more soon. I will also need to modify TuyaMCU code to ensure that there is a certain delay between TuyaMCU packets.
    I will prepare a full documentation of comands when they are fully tested.
    This is TH06:
    Circuit board with mounted electronic components and a module labeled WB3S.
    Digital clock display showing temperature 23.3°C, humidity 24%, day of the week WEDNESDAY, time 8:08 AM, and date July 15, 2012.
    See measurements on screen and on OpenBK panel:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    (values on photo are slightly different because they change so fast...)
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Channels are automatically sent to MQTT server, so HomeAssistant should be now able to read out TH06 temperature and humidity, altough I might need one more fix for that later.

    I need information which devices are using TuyaMCU with Beken chips.
    I have recently bought a thermostat, MTS-700-WB :
    [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
    But it's WBR2 (RTL8720CF) + GD32E230F8P6TR (the MCU). See teardown here:
    https://www.elektroda.pl/rtvforum/topic3885079.html
    Helpful post? Buy me a coffee.
  • #394 19971215
    moeter
    Level 1  
    If you are interested in further devices using a Beken chip:
    I have a RGBCW led strip controller bought at Action in Germany which uses an BK7231T. It has (obviously) 5 PWM channels, 3 buttons and an IR input. It does not use a tuya module but is a custom PCB with MCU and output circuitry integrated, which leads me to believe they won't change the MCU any time soon.

    RX/TX1 and 2 are exposed by testpoints, I've already checked the pinout:

    pwmc=pwm5=P26
    pwmw=pwm4=p24
    pwmg=pwm2=p08
    pwmr=pwm1=p07
    pwmb=pwm0=p06
    s1[M]=P15
    s3[power]=p14
    s2[[C]=p16
    IR=p9

    For what it is (5m RGBCW strip + controller, remote and power supply) it's quite cheap at 20€.

    Company Name is LSC, model 970752, available here on action dot com as "tama-led-lsc-smart-connect" or "lsc-smart-connect-led-streifen" (sorry, I'm not allowed to post links yet...)
  • ADVERTISEMENT
  • #395 19971251
    p.kaczmarek2
    Moderator Smart Home
    I have just written a custom driver for RGBCW lighting based on 5 PWMs and tested it on BK7231N, would you like to test it on your device?
    Here is how it looks like in Home Assistant:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Click here to see hidden options:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    In color mode, you have a color picker. This is RGB only:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    In temperature mode, you get temperature slider:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    See my RGBCW BK7231N LED bulb guide for details here:
    https://www.elektroda.com/rtvforum/topic3880540.html
    (configuration.yaml code for rgb_command_topic, brightness_command_topic, color_temp_command_topic etc included!)

    Hmm we have some Action shops in Poland, I will go ask there.
    Helpful post? Buy me a coffee.
  • #397 19973258
    windex007
    Level 2  
    Amazing work on this project! I am super impressed!

    I bought some smart switches that up until recently were ESP based and I thought I was going to be stuck to the cloud until I found this project!

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

    Amazon product link is B07V3XB1QG (don't have enough points to be able to post links I guess)

    These are the switches, they're a 3-way switch which is important for what I need them for.

    Cracking them open I see they've got the Tuya WB3S chips in them which are based on the BK7231T. Datasheet here:
    (Actually don't have enough points to post links, look it up yourself I guess lol)

    [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

    The guts have 2 parts, a board with the microcontroller on it and then a board with all the High Voltage guts on it. There is a 5 lead interface between the two boards.

    Doing some tests, I was able to determine which of the pins on the interface is driven low/high when you toggle the light in the app with stock firmware. As well, I was able to figure out that one of the pins is attached to some kind of sensor (current?) which detects the actual state of the load (the light). This makes sense since this is a 3 way switch, you can't infer the state of the light by looking at the state of the relay, because if you turn the OTHER switch in the 3-way series on/off, the light will change without the relay in the smart switch changing state. This is why for a 3 way switch, you need to sense the load to know if the light is ACTUALLY on or off.


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


    Flashing this board was actually really easy. Since the pads are kinda "C" shaped, it was pretty easy to snug some probe leads into the cup shape and just held them there for the flashing. The 5 pin interface has really short pins that I couldn't reliably get into a breadboard so I hooked some test leads to them and that worked fine. All in all, literally no soldering required.

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

    This is the point where I began to really hit the limit of my knowledge and I'd be interested in some ideas/help.

    I was able to make the switch work using the following configuration:

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

    I can switch it on, switch it off by physically pressing the switch. Hooking it into home assistant with the following config:

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

    I was able to toggle the relay on/off using home assistant. SWEET.

    However, the device is reporting its state simply by saying the state of the relay. That works fine IF I only ever use the smart switch, but as soon as I flip the other switch in the 3-way circut, the state that the smart switch reports will be inverted (saying the light's off when it's really on, and on when it's really off).

    What would be ideal is if what the MQTT reported regarding state was ACTUALLY if PWM5 (P26) is being pulled low or not, because for this switch that is the real truth as to if the load (light) is actually on or not.

    Any thoughts on how to achieve this?
  • #398 19973508
    p.kaczmarek2
    Moderator Smart Home
    New I2C update!
    I have added MCP23017 driver.
    MCP23017 is a 16 bit port expander.
    It allows you to connect, for example, 16 relays to single I2C bus.
    With current system, it's possible to map 16 pins of MCP23017 to OpenBeken channels.
    Here is used command:
    
    backlog setChannelType 5 toggle; setChannelType 6 toggle; setChannelType 7 toggle; setChannelType 8 toggle; setChannelType 9 toggle; setChannelType 10 toggle; setChannelType 11 toggle; addI2CDevice_MCP23017 I2C1 0x27; MCP23017_MapPinToChannel I2C1 0x27 7 5; MCP23017_MapPinToChannel I2C1 0x27 6 6; MCP23017_MapPinToChannel I2C1 0x27 5 7; MCP23017_MapPinToChannel I2C1 0x27 4 8; MCP23017_MapPinToChannel I2C1 0x27 3 9; MCP23017_MapPinToChannel I2C1 0x27 2 10; MCP23017_MapPinToChannel I2C1 0x27 1 11
    

    Command was used on 4 relays driver. Channels 5, 6, 7 etc are mapped to expander bits.
    Here is how it looks like in UI (I didn't bother adding all 16 channels, just few of them):
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Here are LEDs during test:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Here is whole setup (ignore TC74 temperature sensors on I2C bus, let's focus on MCP23017):
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Adnotated:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Now you might ask - why? Why 16 channels? Why MCP23017?
    This is because it allows use to use this module:
    [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
    That would be a very cheap and nice hack to get a lot of relays controlled. Also, you can have multiple MCPs on the same I2C bus...

    ferbulous wrote:

    Nevermind, it's in the releases tab

    Well, the releases are all quite old. I will make a new release soon. Many things have been fixed since that time, including N version MQTT authorization.

    windex007 wrote:

    What would be ideal is if what the MQTT reported regarding state was ACTUALLY if PWM5 (P26) is being pulled low or not, because for this switch that is the real truth as to if the load (light) is actually on or not.

    Welcome to Elektroda. I'll be happy to help you. I haven't used such a device like the one you have. But you basically want to read the digital state (Arduino digitalRead) on given pin to a channel and get it from Home Assistant?
    I can add this functionality for you tomorrow. If that's what you need.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #399 19973540
    windex007
    Level 2  
    p.kaczmarek2 wrote:

    Welcome to Elektroda. I'll be happy to help you. I haven't used such a device like the one you have. But you basically want to read the digital state (Arduino digitalRead) on given pin to a channel and get it from Home Assistant?
    I can add this functionality for you tomorrow. If that's what you need.


    Thank you for the warm welcome and thank you so much for the work you've done so that people like me aren't stuck relying on cloud services for the smart devices we own!

    And yes, if there was a way to do the equivalent of a digitalRead on the pin and get that state information to Home Assistant, I think I'd be able to take it from there!

    Cheers
  • #400 19973661
    p.kaczmarek2
    Moderator Smart Home
    @windex007 Ok I just added a IOR_DigitalInput and IOR_DigitalInput_n.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    They should work on all 3 platforms -XR809, BK7231N and T.
    They save value to linked channel.
    There is no debouncing whatsover, it's just a digitalread.
    Here is commit:
    https://github.com/openshwprojects/OpenBK7231...mmit/bb8bb26a6d3546b9e1eeef4746fc692ea5e6b428

    Remember to use separate channel to store the read value from DIgital Input, for example, channel 5, and then read it from MQTT by obkBlab/5/get.

    It should work right now, of course assuming that's what you really need for this device. Also, can you compile binary yourself? If not, i will push a binaries for you...

    if that's not it, find me an ebay or banggood or offer from shop that accepts paypal and point me to it, I will buy your device from money from donations (remember guys - test devices are not going to fund themselves - https://www.paypal.com/paypalme/openshwprojects ) , and then I will make sure myself it's supported correctly and add Template for that.
    Helpful post? Buy me a coffee.
  • #401 19973756
    windex007
    Level 2  
    p.kaczmarek2 wrote:

    ...
    It should work right now, of course assuming that's what you really need for this device. Also, can you compile binary yourself? If not, i will push a binaries for you...


    I should be able to compile it myself! I'll play around with this build for a few days and see what I can get going with it. Thanks a ton!


    p.kaczmarek2 wrote:

    if that's not it, find me an ebay or banggood or offer from shop that accepts paypal and point me to it, I will buy your device from money from donations (remember guys - test devices are not going to fund themselves - ...) , and then I will make sure myself it's supported correctly and add Template for that.


    Save your hard-earned donation money for a harder-to-obtain item. DM me a mailing address and I'll ship you one. They come in 4 packs and I accidentally bought more than I need anyways.
  • #402 19973799
    p.kaczmarek2
    Moderator Smart Home
    Thanks, that will certainly come in handy for next teardown article.

    I've sent you a PM.

    Today I did another teardown of a smart bulb, but sadly W600 inside. TY5 module. Not supported yet, but maybe someday... it's time to check if manufacturers flash util works!
    [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
    Helpful post? Buy me a coffee.
  • #403 19973909
    ferbulous
    Level 18  
    @p.kaczmarek2 hi, i just tested tuya-cloudcutter tools to flash openbkt via ota to my led bulb and it was successful
    Only issue I'm facing is now after i configured the gpio pins, the webpage stopped responding.
    When I saved the wifi & mqtt settings, and restarted from gui it was still working fine though.
    But now I'm unable to access the webpage and this one of those tuya devices that makes it hard for solder/desolder job for wb2l inside to do further troubleshooting
    Any ideas why that could happen?

    Update - it's no longer broadcasting Openbkt AP when turned on
  • #404 19974059
    p.kaczmarek2
    Moderator Smart Home
    N or T version? Oh wait, WB2L, so T

    Are you using the lastest binaries (compiled by yourself or released by me yesterday)?
    https://github.com/openshwprojects/OpenBK7231T_App/releases/tag/1.0.5
    There are multiple things that were fixed during last week, including:
    - N version crashing on startup (but if you repower it and power off several times, it will recreate open ap)
    - both T and N versions crashing if you set PWM role to non-pwm pin
    etc etc

    Also few days ago I realized that OTA on N platform still requires some small bugfix, so you should flash now your T devices and wait a bit with all Ns (unless you can solder wires for update)


    Ok so first of all try to reset OpenBK by powering on, waiting few seconds and powering off, do this several times, this should bring back open access point. Then use OTA (it works on T platform) to update to latest binary.

    EDIT: I think you might have done that:
    Quote:

    It's not that you change the role of UART pin, it's that you're trying to set a PWM role for non-PWM pin and thus bk_pwm_stop gets called with -1 argument.
    I see no security check against that in SDK.
    Try this:
    https://github.com/openshwprojects/OpenBK7231...mmit/28e6ee05c32d717f04950f22f8073fafbecfc98e

    When are you binaries dated? That fix was added "@openshwprojects openshwprojects committed 18 days ago "
    Helpful post? Buy me a coffee.
  • #405 19974089
    ferbulous
    Level 18  
    @p.kaczmarek2
    I flashed 1.0.4 for T
    I will do the ota for 1.0.5 for my next bulb that's still working

    Quote:
    both T and N versions crashing if you set PWM role to non-pwm pin


    This could be the cause for it
    I configured the PWM for these pins right before it crashes

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

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

    Am i doing it right? I'm unsure if i should start with P0 or P1
  • #406 19974131
    p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

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

    @ferbulous have you consulted the datasheet before setting that and investigated connections on PCB with a contuinity tester?
    Here are the pin numbers which supports PWM channels. On Beken, only pins 6, 7, 8, 9 , 24 and 26 can do PWM.
    Code: C / C++
    Log in, to see the code

    Do not confuse indices above with channel indices, they are private pwm indexes of beken, not visible to users.
    I'm sorry, you've set a non-PWM pin to a PWM role and PIN_GetPWMIndexForPinIndex returned -1, and then:
    Code: C / C++
    Log in, to see the code

    bk_pwm_initialize and bk_pwm_start got called with -1 which crashes Tuya SDK (the Beken devs didn't bother with adding our of range check).
    The out of range check is now added by me in the code:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    but it wasn't added in 1.0.4. I'm not sure if there is anything I can do more for you right now. Resetting to open AP won't most likely work because pins are set first, no one expected a crash there. I can try to update binaries more often but I think more testing is needed.

    Hmm now you gave me idea, I might also modify the HTTP code to show PWM only for PWM-capable pins... hmm I will do that now.

    Ahhh, and I will remove the manually uploaded binaries that are from over a month ago.
    EDIT: Ok removed:
    https://github.com/openshwprojects/OpenBK7231...mmit/328dec0d3ba9d437c6c8f5dd78aa9f250551d80c
    EDIT2:
    PWM option is no longer shown on PWMs that do not support PWM:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Also added information:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • #407 19974478
    ferbulous
    Level 18  
    @p.kaczmarek2 thank you so much for the update!
    i didn't test the pins earlier and just assumed those were the pwm

    That means the only way to recover the bulb with crashed openbkt would be to use serial method and flash the firmware again since reset is not possible?
    As for the rgb bulb control, how do i get it to show as single led bulb with color/temperature controls instead of switches?

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    light:
      - platform: mqtt
        name: "obk510A1BC1 1"
        state_topic: "obk510A1BC1/1/get"
        command_topic: "obk510A1BC1/1/set"
        brightness_command_topic: "obk510A1BC1/1/set"
        on_command_type: "brightness"
        brightness_scale: 99
        qos: 1
        payload_on: 99
        payload_off: 0
        retain: true
        optimistic: true
        availability_topic: "obk510A1BC1/connected"
      - platform: mqtt
        name: "obk510A1BC1 2"
        state_topic: "obk510A1BC1/2/get"
        command_topic: "obk510A1BC1/2/set"
        brightness_command_topic: "obk510A1BC1/2/set"
        on_command_type: "brightness"
        brightness_scale: 99
        qos: 1
        payload_on: 99
        payload_off: 0
        retain: true
        optimistic: true
        availability_topic: "obk510A1BC1/connected"
      - platform: mqtt
        name: "obk510A1BC1 3"
        state_topic: "obk510A1BC1/3/get"
        command_topic: "obk510A1BC1/3/set"
        brightness_command_topic: "obk510A1BC1/3/set"
        on_command_type: "brightness"
        brightness_scale: 99
        qos: 1
        payload_on: 99
        payload_off: 0
        retain: true
        optimistic: true
        availability_topic: "obk510A1BC1/connected"
      - platform: mqtt
        name: "obk510A1BC1 4"
        state_topic: "obk510A1BC1/4/get"
        command_topic: "obk510A1BC1/4/set"
        brightness_command_topic: "obk510A1BC1/4/set"
        on_command_type: "brightness"
        brightness_scale: 99
        qos: 1
        payload_on: 99
        payload_off: 0
        retain: true
        optimistic: true
        availability_topic: "obk510A1BC1/connected"
      - platform: mqtt
        name: "obk510A1BC1 5"
        state_topic: "obk510A1BC1/5/get"
        command_topic: "obk510A1BC1/5/set"
        brightness_command_topic: "obk510A1BC1/5/set"
        on_command_type: "brightness"
        brightness_scale: 99
        qos: 1
        payload_on: 99
        payload_off: 0
        retain: true
        optimistic: true
        availability_topic: "obk510A1BC1/connected"
    


    Since openbkt reset is done by toggle on/off a few times, could it be disabled or increased by toggling several more times?
  • #408 19974505
    p.kaczmarek2
    Moderator Smart Home
    Important update: BK7231N OTA works! (and it worked before, but only when called by hand and not by REST api, because.... of the wrong address left in one of the function calls.)

    So now both BK7231N and BK7231T OTAs are working.

    Update your devices!

    ferbulous wrote:

    i didn't test the pins earlier and just assumed those were the pwm

    Well, it was discussed in this threads few pages before...


    ferbulous wrote:

    That means the only way to recover the bulb with crashed openbkt would be to use serial method and flash the firmware again since reset is not possible?

    I apologize for the inconvenience, but in this case, unfortunately, you have to use serial method. Luckily you are most likely the last person to experience it, since the foolproof checks are already in place (first fix was added 18 days ago, more improvements today) and now it's not possible to configure incorrectly stuff.

    ferbulous wrote:

    As for the rgb bulb control, how do i get it to show as single led bulb with color/temperature controls instead of switches?

    What kind of bulb do you have, can you post photo?
    RGBCW?
    I have prepared a step by step RGBCW guide and configuration yaml file there:
    https://www.elektroda.com/rtvforum/topic3880540.html#19938487
    configuration details for HA are in post #5.
    Right now automatic config gen doesn't support RGBCW, you have to edit config yourself in text editor.

    PS: Support for another peripheral incoming, who can guess which chip I just desoldered?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • #409 19974526
    ferbulous
    Level 18  
    @p.kaczmarek2
    I think it's RGCBW as well? It's got red, green, blue, with warm white & cold white

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

    Quote:
    I apologize for the inconvenience, but in this case, unfortunately, you have to use serial method. Luckily you are most likely the last person to experience it, since the foolproof checks are already in place (first fix was added 18 days ago, more improvements today) and now it's not possible to configure incorrectly stuff

    I probably could've avoided this if I tested each pin like i usually do, the whole pcb is sealed with silicone inside the bulb which makes it difficult to use serial method

    Quote:
    I have prepared a step by step RGBCW guide and configuration yaml file there:
    https://www.elektroda.com/rtvforum/topic3880540.html#19938487
    configuration details for HA are in post #5.
    Right now automatic config gen doesn't support RGBCW, you have to edit config yourself in text editor.

    Thanks! I'll try adding this config

    Quote:
    PS: Support for another peripheral incoming, who can guess which chip I just desoldered?

    CB3S?
  • #410 19974542
    p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:
    @p.kaczmarek2
    I think it's RGCBW as well? It's got red, green, blue, with warm white & cold white

    Do you know if it's 5 PWMs or I2C driver?


    ferbulous wrote:

    I probably could've avoided this if I tested each pin like i usually do

    You could also have avoided it if you read this whole thread and/or used latest self-build version, but now I think I will try to release binaries more often. It's just that I am doing most of development and testing myself and I am never sure if some new change breaks something else or not. @btsimonh helps from time to time but 3 (?) extra test devices is not much.



    ferbulous wrote:

    Quote:
    PS: Support for another peripheral incoming, who can guess which chip I just desoldered?

    CB3S?

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    CB2S + BL0942, which I plan to support very soon, if everything goes well... that chip has luckily UART interface, should be easy to read out voltage, current and power information.
    First power-metering features in OpenBK!
    Helpful post? Buy me a coffee.
  • #411 19974583
    theosoft
    Level 10  
    p.kaczmarek2 wrote:
    Important update: BK7231N OTA works! (and it worked before, but only when called by hand and not by REST api, because.... of the wrong address left in one of the function calls.)

    So now both BK7231N and BK7231T OTAs are working.

    Update your devices!





    I have used this fix :-)

        if (!strcmp(request->url, "api/ota")){
            return http_rest_post_flash(request, START_ADR_OF_BK_PARTITION_OTA);
        }
    
  • #412 19974590
    ferbulous
    Level 18  
    @p.kaczmarek2
    It's using 5 PWM, no i2c for this.
    I've added the configuration to my config.yaml

    #openbktbulb1
      - platform: mqtt
        name: obk510A1BC1
        rgb_command_template: "{{ '#%02x%02x%02x0000' | format(red, green, blue)}}"
        rgb_state_topic: "cmnd/obk510A1BC1/led_basecolor_rgb"
        rgb_command_topic: "cmnd/obk510A1BC1/led_basecolor_rgb"
        command_topic: "cmnd/obk510A1BC1/led_enableAll"
        availability_topic: "obk510A1BC1/connected"
        payload_on: 1
        payload_off: 0
        brightness_command_topic: "cmnd/obk510A1BC1/led_dimmer"
        brightness_scale: 100
        brightness_value_template: "{{ value_json.Dimmer }}"
        color_temp_command_topic: "cmnd/obk510A1BC1/led_temperature"
        color_temp_state_topic: "cmnd/obk510A1BC1/ctr"
        color_temp_value_template: "{{ value_json.CT }}"


    But it's not consistent or random, like if i change to specific color, doesn't really match the same as in the color pickup
    Same goes for cold & warm sliders

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

    Awesome, I was just about to ask about the power monitoring, great news especially for power plug with compact design that's just impossible to tear down without destroying the case
  • #413 19975042
    theosoft
    Level 10  
    Hello,

    Is it possible to push the WEBAPP sources into the repository?
    So some public modifications are possible ..

    regards

    P.S.: I have extracted them, so local i am able to do modifications :-)
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • #414 19975791
    p.kaczmarek2
    Moderator Smart Home
    BL0942 energy/voltage/current meter (UART mode) is now working, along with calibration process similiar to one with Tasmota.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Config:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Display:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Calibrating:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Calibration commands are named as in Tasmota, CurrentSet, VoltageSet, PowerSet.

    I will post detailed guide later. I also need to add a missing MQTT handler for that some Home Assistant can read values.

    theosoft wrote:


    I have used this fix :-)

        if (!strcmp(request->url, "api/ota")){
            return http_rest_post_flash(request, START_ADR_OF_BK_PARTITION_OTA);
        }
    

    Yes I remember myself introducing this constant START_ADR_OF_BK_PARTITION_OTA while fixing @btsimonh code, but I just must have missed one occurence. Next time, @btsimonh , and all other possible code contributors, PLEASE USE CONSTANTS correctly, #define them, and not enter them by hand in multiple places.




    ferbulous wrote:

    But it's not consistent or random, like if i change to specific color, doesn't really match the same as in the color pickup
    Same goes for cold & warm sliders

    I would need to see it. Tell me again, is it a) consistent or b) random? Does 100% red correspond to 100% red?
    There may be a bug, or maybe just my lighting calculations are sloppy and needs to be improved.
    Sadly I have only one RGBCW light and it's already without a case so it might be hard to check how the final effect looks like. I will try to put it together again. I need more test devices.



    theosoft wrote:
    Hello,
    Is it possible to push the WEBAPP sources into the repository?
    So some public modifications are possible ..

    Aren't they here? https://github.com/OpenBekenIOT/webapp/tree/gh-pages/vue feel free to submit a pull request
    Helpful post? Buy me a coffee.
  • #415 19975866
    ferbulous
    Level 18  
    @p.kaczmarek2
    So far it has been quite random
    Also the bulb i flashed openbkt was sold cheap as defect bulb
    On the stock firmware, it would flicker for 1 sec after a few hours. I asked around and it could be power supply issue

    After i flashed openbkt, if i select specific colors or just plain warm/cold white. I noticed it would turn off after 10 minutes or more and checking directly openbkt indicates that it was restarted (online time has changed).
    However if i simply turned on the bulb without toggle any colors/warm/cold light it would stay online indefinitely.

    Is there some logs i could check to see what caused the restart?
  • #416 19975887
    p.kaczmarek2
    Moderator Smart Home
    I took my time today and especially for you I put together back the only Beken smart lightbulb I have. So it's time for some real testing.
    Red:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Red+Blue:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Blue:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Cool white:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Warm:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Green:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    All colors at once (RGB, but not CW):
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    You can see on the photos when I placed the color choice marker in HA. Can you make the same photos with your bulb and your Home Assistant?
    I will leave my bulb running for a day and see if it resets. I don't know of any way to determine why device restarted.

    EDIT:
    @ferbulous test started at 15 , now it's almost 19 and after 4 hours bulb is still OK.
    The only issue I find is the non-refreshed brightness dimmer because HA right now can only send data to bulb and not read. But it will be easy to fix.
    Helpful post? Buy me a coffee.
  • #417 19976187
    ferbulous
    Level 18  
    @p.kaczmarek2 much appreciated
    sorry for late reply, uploading to youtube took forever





    mine was still restarting earlier, just changed to red color and it's still online somehow for the last hour, will check back later on this

    Quote:
    The only issue I find is the non-refreshed brightness dimmer because HA right now can only send data to bulb and not read. But it will be easy to fix

    Was gonna point this out, thanks!
  • #418 19976219
    p.kaczmarek2
    Moderator Smart Home
    @ferbulous , this is very strange. It looks like a slowed down response, but I am not sure why.
    I am not sure what to do now. We could try with more debugging. Maybe first test, are you sure that it's not just that channels are swapped (for example, blue swapped with red)? But it doesn't look like that for me.

    Try setting several times 100% red in HA, what is then shown on openbk panel?

    Try setting several times 100% blue in HA, what is then shown on openbk panel?

    Do you know how to use manual "Publish MQTT" in Home assistant? Are you able to simulate a publish send with, for example, R=0x00,G=0xFF,B=0x00 and check how the OpenBK reacts?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    NOTE: it only sets RGB color, the base RGB color, the given color is later multiplied by brightness and also the power value is taken into account (on or off), so don't be confused if you send 00FF00 to bulb and it's still off.


    Also... where can I get such bulb? It is somewhere on banggood or ebay? Or amazon pl? How to find that exact one you have?
    PS: my bulb has different PWMs:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    but I can't see any problem right now.... we both have set R G B C W correctly (1=R, 2=G, 3 =B, 4=C, 5=W)


    On a brighter side, I've found another WB2S device, TuyaMCU dimmer:
    [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
    WB2S + HT66F3195 ....
    Helpful post? Buy me a coffee.
  • #419 19977577
    theosoft
    Level 10  
    Hello,

    My modul CB3S, flash with the latest release firmware, is losing WIFI connection after a while.
    The serial port log shows "bad_channel vif_idx=0". I think, it is a ros message. It seems, that some sort of recovery doesn't exist...

    regards
  • #420 19977668
    p.kaczmarek2
    Moderator Smart Home
    Hey @theosoft , it seems you're not the first one to report it. I already proposed solution but somehow I am not sure if it worked for people or not.

    Anyway, here it is commited to repo, just a minute ago:
    https://github.com/openshwprojects/OpenBK7231...mmit/7f424690cb633c5ddeae7af4246e536646074d06

    Can you please checkout latest change, recompile, update by OTA and tell me if it works now (it should reconnect after connection is lost)?
    Helpful post? Buy me a coffee.

Topic summary

The discussion revolves around the development and implementation of custom firmware for devices using the BK7231T and BK7231N chips, particularly focusing on creating a mini HTTP server, MQTT support, and integration with Home Assistant. Users share their experiences flashing various smart devices, troubleshooting issues related to UART connections, and configuring GPIO pins for different functionalities. The conversation also touches on the challenges of maintaining WiFi connectivity, the importance of proper pin configuration, and the potential for using I2C for additional device control. Several users report successful firmware updates and the addition of new features, including support for various sensors and devices.
Summary generated by the language model.
ADVERTISEMENT