Elektroda.com
Elektroda.com
X

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

p.kaczmarek2 115065 1236
This content has been translated flag-pl » flag-en View the original version here.
  • #751
    leecher1337
    Level 6  
    @p.kaczmarek2
    p.kaczmarek2 wrote:
    @leecher1337 why not just connect external UART to USB converter and capture the the communication data? That way we will know if it's a TuyaMCU or something

    Oh, so this may be a TuayMCU, thanks for the hint!
    Sorry for stupid question, but is there a way to tell OpenBK that it has to use RXD1/PWM2 as serial protocol interface ports instead of TXD1/RXD1 to even have a chance that the TuyaMCU driver is working or did I miss something?
  • #752
    AcuarioCat
    Level 5  
    p.kaczmarek2 wrote:

    W800 port is now fully functional, even with OTA!


    Did you ever do a W600 port or did you go straight to W800?
  • #753
    brijin
    Level 1  
    thank you for this wonderful project, I appreciate the effort behind this. I thought I'll share my setup on this main thread since I have bunch of devices running on this project. they all run solid, connected to HA and works fine.

    attaching some pictures. sorry if I am hijacking this thread. [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
  • #754
    p.kaczmarek2
    Moderator Smart Home
    ]
    rawilson wrote:
    @ p.kaczmarek2 it looks like the GU10 bulbs available in Poland woj14415 are based on WBLC5 + SM2135Eh - I2C communication. After dismantling, it turned out that the CLK line is connected to pin 26, date to pin24. Would you provide information on how to configure this bulb?

    Are you still here?
    SM2135 driver will be ready tonight.


    leecher1337 wrote:

    Sorry for stupid question, but is there a way to tell OpenBK that it has to use RXD1/PWM2 as serial protocol interface ports instead of TXD1/RXD1 to even have a chance that the TuyaMCU driver is working or did I miss something?

    It's not possible to change the location of hardware UART ports on Beken chips. Are you sure about that PWM2? Maybe it's not a TuyaMCU after all. Please try to sniff the packets with external USB to UART converter.

    AcuarioCat wrote:

    Did you ever do a W600 port or did you go straight to W800?

    Why? Do you know a device with W600?
    I haven't looked into W600 yet, but the W600 dev board is on the way and I will do the port as well.


    @brijin this is very useful, would you like to provide us more details, the exact product names (and wwhere to buy them) and ready pinout configurations?

    You could also post them here: https://www.elektroda.com/rtvforum/forum507.html
  • #755
    ferbulous
    Level 16  
    Hi @p.kaczmarek2 , sorry been away for work
    Just tested the tasmota group feature, i've added openbk 2 gang wall switch into an existing tasmota group (nightlamp -> 4 lights bulbs, + button 3 from a 3gang switch)
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    By toggling either tasmota bulbs or switch, it would toggle the openbk switch as well. But toggling openbk switch would not control the other tasmota devices so I'm guessing this is where I should use eventhandler script?
    For the evenhandler, how do i enable that in the command line and see the ouput? And how could I get single, double, hold clicks working without toggling the openbk switch relay?

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

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

    For example, wifi bulb is connected the openbk switch relay 1, so I intend to have the relay 1 always on while using button 1 clicks for custom bulb action.

    By the way, Is it also possible to separate switch for the group? similar to devgrouptie

    EDIT

    Ok, i think i almost got it
    I changed button 1 for pin 14 to togglechannel
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Then I added this in custom cummond
    addEventHandler OnClick 14 SendGet http://192.168.1.198/cm?cmnd=Power0%20Toggle 

    Pushed button 1, but doesn't seem to do anything, the web request is correct when I tried it on browser
  • #756
    AcuarioCat
    Level 5  
    @p.kaczmarek2 Yes the Smart Home WiFi Smart Switch has a TW-02 module whic has a W600 processor - unless they have updated it since the ones I bought.
    I did a 'transplant' to an ESP on one device which works fine but much better to use the native device.
  • #757
    marioalmeida
    Level 10  
    I have a 4 gang touch switch with WB3S and CMS8S5880 MCU connected via Serial pins, any idea if this is TuyaMCU supported? I have flash ver 1.7.1 but not sure how to configure this.
  • #758
    p.kaczmarek2
    Moderator Smart Home
    ferbulous wrote:

    By toggling either tasmota bulbs or switch, it would toggle the openbk switch as well. But toggling openbk switch would not control the other tasmota devices so I'm guessing this is where I should use eventhandler script?

    It seems I just forget to add the callback for relay change. No a problem, I can add it fifteen minutes.
    https://github.com/openshwprojects/OpenBK7231T_App/commit/cd920de7e96edc39d4a352067e057badcd782786
    Here, done, can you check now? Sending power should be working automatically, no scripting needed. I will also look into the dimmer and RGB.

    WARNING: you MUST use correct channel indexes. I tested it with two power metering plugs. It will work correctly if you use channel 0 (not 1!) for relay on obk, because it expects channel 0 to be the first channel. Here is my test setup:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    The only issue is that I don't have any ESP8266 RGB lights, nor any RGBCW. Can you recommend me where can I buy ESP8266 LED bulb?

    Otherwise I will try to implement it blindly, would you be able to test that in this case, @ferbulous ?

    One of the things I am unsure of currently, is the DGR protocol of Tasmota supposed to send raw RGB color and dimmer separately, and then I shall do finalColor = dimmer * rawColor, or is the color send by Tasmota DGR already a final value?


    ferbulous wrote:

    Then I added this in custom cummond
    addEventHandler OnClick 14 SendGet http://192.168.1.198/cm?cmnd=Power0%20Toggle 

    Pushed button 1, but doesn't seem to do anything, the web request is correct when I tried it on browser

    I am confident that "ToggleChannelOnToggle" is not using Button code at all, thus "OnClick" won't work for that, the same goes for "OnHold" and "OnDblClick".
    Would you like me to add a special "OnToggle" callback for this specific purpose?



    @AcuarioCat
    ah ok, I will look into it when the dev board arrives.

    @marioalmeida
    Have you tried this https://www.elektroda.com/rtvforum/topic3904845.html ?
    If not, I will try to guide you step by step on the setup proccess. Do you know dpIds already?



    @rawilson SM2135 setup
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    
      - platform: mqtt
        name: "I2C SM2135 (T)"
        rgb_command_template: "{{ '%02x%02x%02x' | format(red, green, blue)}}"
        rgb_state_topic: "SM2135_RGBCW_BK7231T/led_basecolor_rgb/get"
        rgb_command_topic: "cmnd/SM2135_RGBCW_BK7231T/led_basecolor_rgb"
        rgb_value_template: "{{ value[0:2]|int(base=16) }},{{ value[2:4]|int(base=16) }},{{ value[4:6]|int(base=16) }}"
        #rgb_value_template: "{{ '%02x%02x%02x'| format(red, green, blue) }}"
        command_topic: "cmnd/SM2135_RGBCW_BK7231T/led_enableAll"
        state_topic: "SM2135_RGBCW_BK7231T/led_enableAll/get"
        availability_topic: "SM2135_RGBCW_BK7231T/connected"
        payload_on: 1
        payload_off: 0
        brightness_command_topic: "cmnd/SM2135_RGBCW_BK7231T/led_dimmer"
        brightness_scale: 100
        brightness_state_topic: "SM2135_RGBCW_BK7231T/led_dimmer/get"
        brightness_value_template: "{{value}}"
        color_temp_command_topic: "cmnd/SM2135_RGBCW_BK7231T/led_temperature"
        color_temp_state_topic: "SM2135_RGBCW_BK7231T/led_temperature/get"
        #color_temp_value_template: "{{value}}"
        retain: true
    

    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    i didn't have much time to test it but I will help you if any issue arise

    Dodano po 10 [minuty]:

    ferbulous wrote:

    Then I added this in custom cummond
    addEventHandler OnClick 14 SendGet http://192.168.1.198/cm?cmnd=Power0%20Toggle 

    Pushed button 1, but doesn't seem to do anything, the web request is correct when I tried it on browser

    UPDATE: as I said, it won't work this way, because ToggleOnToggle is not using button code.
    I have added a specific callback for this purpose:
    https://github.com/openshwprojects/OpenBK7231T_App/commit/dea3e827baaf09a2401e9b79aec441fd2e7206d9
    If you're using ToggleChannelOnToggle, you should use:
    addEventHandler OnToggle 14 SendGet http://192.168.1.198/cm?cmnd=Power0%20Toggle 

    where 14 is a index of toggle pin and not a channel index

    But, also keep in mind that automatic Tasmota Device Groups power send was added last hour, so there is no need for so much scripting now.

    What else would you like me to add?
  • #759
    marioalmeida
    Level 10  
    Thanks @p.kaczmarek2 , that worked.

    Added after 3 [hours] 25 [minutes]:

    @p.kaczmarek2

    How do I map the countdown dpId?

    Code: json
    Log in, to see the code

    Tried below but did not work
    setChannelType 7 TextField
    linkTuyaMCUOutputToChannel 7 4 7


    Added after 1 [hours] 52 [minutes]:

    Got it working as below.
    
    startDriver TuyaMCU
    
    setChannelType 1 toggle
    setChannelType 2 toggle
    setChannelType 3 toggle
    setChannelType 4 toggle
    
    setChannelType 7 TextField
    setChannelType 8 TextField
    setChannelType 9 TextField
    setChannelType 10 TextField
    
    linkTuyaMCUOutputToChannel 1 1 1
    linkTuyaMCUOutputToChannel 2 1 2
    linkTuyaMCUOutputToChannel 3 1 3
    linkTuyaMCUOutputToChannel 4 1 4
    linkTuyaMCUOutputToChannel 7 2 7
    linkTuyaMCUOutputToChannel 8 2 8
    linkTuyaMCUOutputToChannel 9 2 9
    linkTuyaMCUOutputToChannel 10 2 10
    


    Now I need to know how to configure the wifi led indicator, which is connected to the TuyaMCU
  • #760
    p.kaczmarek2
    Moderator Smart Home
    Sorry @marioalmeida , I've been away, but I see you have worked it out partially. That's great! Btw, you can also consult this topic:

    https://www.elektroda.com/rtvforum/topic3895301.html

    As for WiFi LED indicator... well, I'm not sure. Is WiFi LED indicator also a dpId, or isn't it?

    If WiFi LED indicator is not a dpId, then you'll have to wait, as I haven't implemented it yet.

    Would you have time to test it if I were to implement that? I don't have any devices with TuyaMCU wifi indicator at hand.

    Second option - can you tell me where to buy the device you have?


    ALSO: If you need some special kind of GUI for the TuyaMCU (for example for timeouts), just tell me, I will try to organize something.

    EDIT: WiFi state is not a dpID:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    but it should be easy to implement that
  • #761
    ferbulous
    Level 16  
    @p.kaczmarek2
    I believe sonoff B05-BL-A60 still has esp

    Thanks for the new update, I tried OnToggle for the addevent handler and it works
    Is there a different command for double press or long press with ToggleChannelOnToggle since OnHold & OnDblClick is not using button code?

    For tasmota group, it doesn't seem to work for me on 1.7.5, neither tasmota lamp/switch or openbk switch are being controlled even after adding to same group. That and I'm unable to access the webpage or ping after 5-6 minutes for the openbkswitch that I'm testing but the switch still functions normally and listed as connected in the router settings. I'll try flashing openbkt on another device and see if this still persists.

    Also, is there a proper step for restoring back to original tuya firmware if I need to?
    I backed up the cb3s firmware with bk7231tools, dissected rbl and I'm getting bootloader_1.00.bin & app_1.00.bin. But I'm not sure for the next step
  • #762
    marioalmeida
    Level 10  
    @p.kaczmarek2

    Many thanks for your kind support.

    I purchased it from Amazon India https://amzn.eu/d/aComulF not sure how you will get that but, I can test it you can send me the bin file

    For timeout, basically the countdown and number https://www.home-assistant.io/integrations/number.mqtt/ got the job done.

    Next I'll be working on this fan controller. https://amzn.eu/d/efQEeQN and this switch https://amzn.eu/d/bPJHxPd
  • #763
    p.kaczmarek2
    Moderator Smart Home
    @marioalmeida great, if you have some time, could you make some screenshots of product offer page, gather some information from the product description, make some photos, save the OpenBK config and post everything for each product separately as a "Teardown" on our forum?
    Here: https://www.elektroda.com/rtvforum/forum507.html put product name in a title

    It would be useful for other users so they can also know how to configure.


    ferbulous wrote:

    Thanks for the new update, I tried OnToggle for the addevent handler and it works
    Is there a different command for double press or long press with ToggleChannelOnToggle since OnHold & OnDblClick is not using button code?

    There is no "double press" and no "onDblClick" for ToggleChannelOnToggle. Are you sure you know how ToggleChannelOnToggle works? ToggleChannelOnToggle is for case where you have old switch in the wall and still want to reuse it. Normally, you'd use a Button pin.

    ferbulous wrote:

    For tasmota group, it doesn't seem to work for me on 1.7.5, neither tasmota lamp/switch or openbk switch are being controlled even after adding to same group.

    Please post photos of both device configurations. The "Tasmota lamp" is not enough information for me, do by "a lamp" you mean a relay?
    Do your OpenBK device has any PWM pins set in the pins config?
    What exactly do you need to synchronize, power states, LED state?
    I need to know how different your configuration is.
    My config is:
    - Tasmota device (power metering plug) with single relay on channel 0
    - Obk device (power metering plug) with single relay on channel 0
    No extra channels, no PWM pins. Both of them have a button.
    Tasmota DGR communication is this case works in both ways.

    And also, thanks for feedback in general. It's not possible for me myself to test all possible cases and device combinations.

    Also, is your device T or N?

    ferbulous wrote:

    Also, is there a proper step for restoring back to original tuya firmware if I need to?

    I have no idea, I have never tried that.

    Dodano po 3 [godziny] 18 [minuty]:

    UPDATE: Tasmota device groups bugfix and improvement is on the way, should be up in the next 12 hours.
    Change 1: fixed rare logical error leading to device reverting to old state
    Change 2: added correct LED driver gui (1:1 like in Tasmota) for single color LED strip
    Change 3: single color LED strips now are also 100% DGR compatible (automatically, just like the relays)

    See:
    [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

    Now I would also like to do:
    - support for WarmWhite/ColdWhite strips and DGR
    - support for RGB bulbs and DGR
    - support for RGBW and RGBCW bulbs
    but I lack items for testing, I will try to order some bulbs here in Poland and maybe I will get something with esp.

    Again - can anyone help with testing?
  • #764
    ferbulous
    Level 16  
    @p.kaczmarek2
    p.kaczmarek2 wrote:
    There is no "double press" and no "onDblClick" for ToggleChannelOnToggle. Are you sure you know how ToggleChannelOnToggle works? ToggleChannelOnToggle is for case where you have old switch in the wall and still want to reuse it. Normally, you'd use a Button pin.


    I see, i thought that's the option to pick if I need to enable to multipress action like on tasmota (decouple relay with s073 and obtain multiple button states)

    p.kaczmarek2 wrote:
    Please post photos of both device configurations. The "Tasmota lamp" is not enough information for me, do by "a lamp" you mean a relay?
    Do your OpenBK device has any PWM pins set in the pins config?
    What exactly do you need to synchronize, power states, LED state?
    I need to know how different your configuration is.
    My config is:
    - Tasmota device (power metering plug) with single relay on channel 0
    - Obk device (power metering plug) with single relay on channel 0
    No extra channels, no PWM pins. Both of them have a button.
    Tasmota DGR communication is this case works in both ways.


    My devices are:
    a) 4 tasmota bulbs
    b) 1 tasmota wall switch (3 relays - 1 relay assigned to group (devgrouptie)
    c) 1 openbkt wall switch (3 relays) - No PWM set in the pins

    Just trying to sychronize power states for now

    p.kaczmarek2 wrote:
    Also, is your device T or N?

    It's N (CB3S)

    Some updates, I'm trying openbk on 2 gang switch (N device CB3S)
    After a few minutes, same issue with web ui unable to access after a few minutes on 1.7.5 (happened on 3 gang switch)
    I reverted back to 1.6.9 (previous firmware for the 2 gang switch) and it's more stable now

    UPDATE

    After upgrading incrementally from 1.6.9
    1.70, 1.7.1 is still stable
    1.7.2 onwards the web ui/mqtt becomes unresponsive after a few minutes
    Not sure why this is happening, any logs i could post here?
  • #765
    p.kaczmarek2
    Moderator Smart Home
    Wait, do you mean that MQTT gets unresponsive after few minutes of using Tasmota Device Groups, or in general?
    Are you using that option?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I already had reports that there is an issue with MQTT LWIP library and sending too many requests may crash the device.

    Are you using those "broadcast" options as well? How many MQTT broadcast options do you have enabled?

    Or to put it differently:
    1. Does the crash occur if you don't use DGR but use all MQTT publish options?
    2. Does the crash occur if you disable all MQTT publish option flags?
    3. Does the crash occur if MQTT is disabled at all?
    4. Does the crash occur if MQTT is disabled but DGR enabled?


    UPDATE: I am trying to replicate your problem with BK7231N lamp RGBCW device:
    [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

    Dodano po 3 [godziny] 18 [minuty]:

    ferbulous wrote:

    . That and I'm unable to access the webpage or ping after 5-6 minutes for the openbkswitch that I'm testing but the switch still functions normally and listed as connected in the router settings.


    I think that I just managed to recreate the same issue (with all MQTT broadcast flags enabled) on my RGBCW bulb (thanks to your input) and the issue is now fixed. The device now could only disconnect MQTT, but should not crash/lock itself any more, but more testing is needed.

    Please try latest updates and report back here. I will also do more tests as the day comes.
  • #766
    ferbulous
    Level 16  
    p.kaczmarek2 wrote:
    Or to put it differently:
    1. Does the crash occur if you don't use DGR but use all MQTT publish options?
    2. Does the crash occur if you disable all MQTT publish option flags?
    3. Does the crash occur if MQTT is disabled at all?
    4. Does the crash occur if MQTT is disabled but DGR enabled?


    From what I recall, I did not change anything on MQTT publish option & just using the tasmota group.
    As for disabling MQTT, might have to wait for further testing since I accidently bricked my 3 gang switch, I noticed sparks when I turned it on because the neutral cable was loose/not connected
  • #767
    marioalmeida
    Level 10  
    @p.kaczmarek2 ,

    1) Is there a way to auto restore the cmds from autoexec.bat file after firmware upgrade?
    2) FYI, 3 of the device I upgrade from 1.7.5 to 1.9.0 and now they are disconnected from network, is the normal?

    Added after 2 [hours] 43 [minutes]:

    "2) FYI, 3 of the device I upgrade from 1.7.5 to 1.9.0 and now they are disconnected from network, is the normal?"
    @p.kaczmarek2 , this is due to my stupidity, I installed BK7231N on BK7231T. Is there a way that this can be validated after we drop the firmware and before OTA starts?
  • #768
    xostia
    Level 6  
    Hi,

    I bought two ELIVCO LSPA9 in Ali (7$)

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

    I opened one of them and this is the version with WB2S + BL0937. Different than the described by pkaczmarek2 in one of his fantastic how-to.

    Following the instructions in that link, I could flash the WB2S with OpenBK7231T_UA_1.9.0. In this case, I could use bk_writer1.60 but I had to desolder TX1 and RX1 to achieve the connection using my USB TTL 3.3V.

    The device boots and I can configure the wifi. With this configuration I have the basic functionality:

    P7 BL0937 CF 0
    P8 BL0937 CF1 0
    P10 Btn 1
    P24 BL0937 SEL 0
    P26 Rel 1

    The button works, I can enable the relay (web and button) and I get Voltage/Current/Power information (uncalibrated) if I execute the "startDriver BL0937" in the log part of the web app. The blue led is fixed blue and it turns to red when the relay is enabled.

    If I add "P6 Rel_n 1" I get the red and blue leds mixed when the relay is on. I would like to use the blue led to inform about wifi activity... but I did not find how.

    The problem is that I can not see any information about BL0937 in the logs and I can not enable any checkbox in that screen related to BL0937. I can only see continously this BLXXX messages in the logs section:
    "Info:BL0942:Consumed 255 unwanted non-header byte in BL0942 buffer"

    If I execute the calibration commands, like "VoltageSet [correntVoltageVal], CurrentSet [correntCurrentVal] i PowerSet [correntPowerVal]" nothing is shown in the screen... and then I can not calibrate.

    Probably it is my fault, I am "rookie" with this thigs... Can anybody explain to me how to enable the messages?

    In the other hand, if you can include a profile for this LSPA9 WB2S+BL0937, It would be great.

    Thank you for your fantastic job. Thank you.
  • #769
    Tych0
    Level 6  
    Awesome work on the SM2135 LED driver :-)
    Very cool project, keep up the good work everyone!

    I have two devices with a SM2135. I started off with a LSC GU10 RGBCW from Action store with BK7231T. Upgraded to the latest 1.9.0 version. Nice work on the Tasmota alike GUI btw.

    At first everything seemed to work nicely. There is one small issue... the colours are mixed up and HA is acting weird, color picker jumps from red to green for example when I try to set red. Tried to re-order RGB to BRG but that made it even worse...
    Color temps on the CW leds works flawless. Brightness is also working.

    I messed around with the YAML you posted here for the SM2135 but I can't figure out how to correct the issue.
    Does anyone has any idea what's wrong?
  • #770
    p.kaczmarek2
    Moderator Smart Home
    BL0937 LSPA9... yes, I have two LSPA9, one with BL0942 and second with BL0937.

    I have many sockets, thanks to one polish donor:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    I have BL0937 guide on the way.
    xostia wrote:

    P7 BL0937 CF 0
    P8 BL0937 CF1 0
    P10 Btn 1
    P24 BL0937 SEL 0
    P26 Rel 1

    The button works, I can enable the relay (web and button) and I get Voltage/Current/Power information (uncalibrated) if I execute the "startDriver BL0937" in the log part of the web app. The blue led is fixed blue and it turns to red when the relay is enabled.

    This is OK. I will also add a autostart of BL0937 driver when one has pin specified.

    xostia wrote:

    If I add "P6 Rel_n 1" I get the red and blue leds mixed when the relay is on. I would like to use the blue led to inform about wifi activity... but I did not find how.

    Just set WiFi or WiFi_N role for the LED pin

    xostia wrote:

    The problem is that I can not see any information about BL0937 in the logs

    Logs are disabled, I may add a debug flag to enable them only for testing in the future

    xostia wrote:

    I can not enable any checkbox in that screen related to BL0937.

    Which screen are you referring to? Which checkbox? I have no idea.

    xostia wrote:

    "Info:BL0942:Consumed 255 unwanted non-header byte in BL0942 buffer"

    Now now, this is very strange.
    This message ("Consumed 255 unwanted non-header byte in BL0942 buffer") is from BL0942 driver:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/driver/drv_bl0942.c

    The message prefix "Info:BL0942" may be ignored, because the logging BL0942 prefix is used for BL0937 as well (I will fix that now), but the "buffer" thing is BL0942-only

    Now there are two options....
    1. I might have made some kind of bug, I will double check
    2. maybe you have "startDriver BL0942" command somewhere, maybe in short startup command or in autoexec.bat?




    marioalmeida wrote:

    1) Is there a way to auto restore the cmds from autoexec.bat file after firmware upgrade?

    There was some kind of button, "save fs block" and "restore fsblock", but it was designed by @btsimonh when he contributed to the project and I am not sure how functional is that.
    Still, having a copy of single file on your hard drive is relatively easy... and for short configurations, you always have also "short startup command" which is not cleared during OTA.

    marioalmeida wrote:

    this is due to my stupidity, I installed BK7231N on BK7231T.

    Oh no, I can see how that can be a problem! I will check if it's possible to do some kind of simple prevention against that. Maybe at least compare the file name and if it detects N on T (and vice versa) then block update...


    @ferbulous MANY, MANY changes were made yesterday to improve stability, but I will still strongly advice NOT TO use "broadcast mqtt every minute" flag.








    Tych0 wrote:

    At first everything seemed to work nicely. There is one small issue... the colours are mixed up and HA is acting weird, color picker jumps from red to green for example when I try to set red. Tried to re-order RGB to BRG but that made it even worse...
    Color temps on the CW leds works flawless. Brightness is also working.

    Is the issue on MQTT/HA communication side, or in the wrong channels used for RGB?
    Please disable MQTT totally, make sure that your device is disconnected, and then, on OpenBeken gui, set the color to:
    1. set to 100% RED (255 0 0) - is the color red?
    2. set to 100% GREEN (0 255 0) - is the color green?
    3. set to 100% BLUE (0 0 255) - is the color blue?
    Tell me the results and I will provide futher instructions. I might add per-channel role setting to the SM2135 driver if needed.

    For me, SM2135 driver works great so it's not possible to debug this issue on my side.

    [UPDATE] I went and checked my socket, and well, my LSPA9 BL0937 seems to be working.. 60W bulb test, no calibration yet
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Some of my sockets, with one of them ESP8266, used for testing Tasmota Device Groups device state synchronization:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    one of them is older LSPA9 with WB2S+BL0937, second LSPA9 here is newer one with CB2S and BL0942
  • #771
    Tych0
    Level 6  
    p.kaczmarek2 wrote:
    Is the issue on MQTT/HA communication side, or in the wrong channels used for RGB?
    Please disable MQTT totally, make sure that your device is disconnected, and then, on OpenBeken gui, set the color to:
    1. set to 100% RED (255 0 0) - is the color red?
    2. set to 100% GREEN (0 255 0) - is the color green?
    3. set to 100% BLUE (0 0 255) - is the color blue?
    Tell me the results and I will provide futher instructions. I might add per-channel role setting to the SM2135 driver if needed.

    For me, SM2135 driver works great so it's not possible to debug this issue on my side.


    Obviously, I have no clue what's going on... MQTT 'disabled' by changing server IP to non-existing address.
    I can't find where to change the colours in the OpenBeken GUI... I would expect to see it on the main page, right?
    The only way to get the LED light up using the GUI is to send led_enableAll 1 as command. led_enableAll 0 also turns them off again. But SetChannel 1 100 does nothing. Not sure what I'm doing wrong... sorry.

    Works:
    
    Debug:CMD:cmd [led_enableAll 1]
    Info:CMD: enableAll (led_enableAll) received with args 1
    Info:GEN:CHANNEL_Set channel 1 has changed to 100 (flags 2)
    
    
    Info:GEN:CHANNEL_Set channel 2 has changed to 100 (flags 2)
    
    
    Info:GEN:CHANNEL_Set channel 3 has changed to 100 (flags 2)
    
    
    Info:GEN:No change in channel 4 (still set to 0) - ignoring
    
    
    Info:GEN:No change in channel 5 (still set to 0) - ignoring
    

    Does not work:
    
    Debug:CMD:cmd [SetChannel 1 0]
    Info:GEN:CHANNEL_Set channel 1 has changed to 0 (flags 0)
    

    I also noticed that most of the time I have to repeatedly send the commands before the show up in the log.
    Oh and de "Status" page in the WebApp say's: 0:0 role
    Not sure if this is normal behaviour.
  • #772
    p.kaczmarek2
    Moderator Smart Home
    Tych0 wrote:

    I can't find where to change the colours in the OpenBeken GUI... I would expect to see it on the main page, right?

    Ah, I see... you might have an older version. The current version requires you to set this flag:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    The setChannel doesn't work right now for SM2135. SM2135 is connected to new led driver. There is a scriptable command to get around it:
    
     startDriver SM2135
     SM2135_RGBCW FF00000000
    

    but it's not required for normal operation.

    Still, the advanced scripting with "IF" and "WHILE" etc statements is also coming soon, I already have working prototype. It will be very simple to use, with a simple, user-friendly syntax.

    Altough I must note that I am not sure how the final configuration system for SM2135 will look like. I don't how which SM2135 use cases should we expect. I will update the system on the fly, I might also add a direct access to SM2135 channels, it should be very easy as well.

    For example, is SM2135 used with only Cool White/Warm White lights as well? It wouldn't make sense, would it?
  • #773
    Tych0
    Level 6  
    p.kaczmarek2 wrote:
    Ah, I see... you might have an older version.

    Check. I was on 1.9.0 and updated to 1.10.1. Set the flag, and yes I can now change stuff on the main page. But... same behaviour. When I change the color in the GUI to red, the green LED's turn on. Exactly the same pattern when I use HA and MQTT. I don't know if there are different SM2135 versions. This is a bulb with a SM2135EH.

    I have another one, different brand with a SM2135E. Same issue as the other one, mixed-up colours. And the Cold en Warm LED's do not seem to work on this one... which is working perfectly on the bulb I been talking thus far. (side note, I had trouble flashing this one and I might have fried it while doing so...)

    Thanks so far, I really appreciate your help!
  • #774
    xostia
    Level 6  
    Respect @p.kaczmarek2 and LSPA9 WB2S+BL0937.

    There is a checkbox to select "BL0942" messages but no "BL0937". In any case, you say that the logs are disabled, I hope that in future versions we can select both.

    I have nothing in my autoexec.bat, the BL0942 boots by itself ... I started BL0937 by hand in a command (If you have time, associate the Enter key of the keyboard with the launch command button... I realised that Enter does not work to execute commands, I must click with the mouse).

    When I try to calibrate, I get always a 000.00000 value, ¿do you know why? It seems that the calibration commands only run in BL0942, that is running but it is invalid for this device. How can I stop the BL0942 module?

    Thanks for your help

    Added after 1 [minutes]:

    This is by default in the 1.9 version in the startup:

    backlog startDriver BL0942; VREF 15987.125000; PREF -683.023987; IREF 272302.687500

    Added after 12 [minutes]:

    Now it seems that I can calibrate with VoltageSet XXX en so on...

    I replaced the default startup BL0942 with BL0937. There is no log information but the calibration messages answer with regular values... before always 000.0000.

    I will update now to 1.10.2 also. Thank you, this is great.

    One question... is there any way to connect by console (putty or similar) to enable/disable the relay?. I would like to have a simple access to my devices like this...
  • #775
    p.kaczmarek2
    Moderator Smart Home
    Ah ok, that's very simple, @Tych0 . It's just that the order of outputs from SM2135 is not standarized and the manufacturers do whatever they please.

    I have added a command to remap it. Can you check?
    https://github.com/openshwprojects/OpenBK7231T_App/commit/84b982a7177f40fd60c90bd1f310c90b764c24a9

    Usage:
    
    SM2135_Map 2 1 0 4 3 
    

    this is the default order, you might try SM2135_Map 0 1 2 4 3
    Remember that setting is not saved, so add the command call to the "short startup command"
    PS: SM2135 is started automatically now if you have set the pins, no need for StartDriver SM2135. If you need multiple commands, use "backlog yyy; zzzz; xxxxx; " etc
  • #776
    xostia
    Level 6  
    From the console of my router (I can access from outside my home) simply with this command:

    curl http_the.url.of.the.device/index?tgl=1 | grep ON

    I can switch on/off. The grep is to check if on or off. If no html appears after the command, the relay is off. I will prepair something more "elaborated" but this work!
  • #777
    marioalmeida
    Level 10  
    @p.kaczmarek2 that worked.

    First "Read fsblock", -> OTA update -> "Restore fsblock" and last "Restart"
  • #778
    p.kaczmarek2
    Moderator Smart Home
    xostia wrote:

    There is a checkbox to select "BL0942" messages but no "BL0937". In any case, you say that the logs are disabled, I hope that in future versions we can select both.

    Thank you for reporting this, this was indeed a left over from times where I had only BL0942 driver.
    Now I renamed it to "Power Metering". This checkbox is only to show/hide logging.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    xostia wrote:

    This is by default in the 1.9 version in the startup:
    backlog startDriver BL0942; VREF 15987.125000; PREF -683.023987; IREF 272302.687500

    It is not. I guess you used LSPA9 template that is for BL0942 version. The template has set the command. I will have to change it's name or something. But now it explains everything.


    xostia wrote:

    One question... is there any way to connect by console (putty or similar) to enable/disable the relay?. I would like to have a simple access to my devices like this...

    What about HTTP cmnd access? By GET command?
    Raw TCP access is not present yet, as no one ever before requested it. Still, I might modify the log_server_thread of TCP log server to also accept packets. I will consider that.

    Or maybe I will add a command line directly... let me look into it
  • #779
    marioalmeida
    Level 10  
    @p.kaczmarek2 , feature request. Is it possible to add HTTPS and Basic Authentication?
  • #780
    xostia
    Level 6  
    It is true... @p.kaczmarek2, I was playing with the "easy config" and probably edited later... and that stayed in the startup (LSPA9 but the other model with CB2S).

    Respect to the command line. curl is a HTTP client, it works perfect... the problem is that it does not interprete the HTML output.

    If you have time to create a url in the web server to enable or disable the relay and, if possible, inform about the Voltage / Power / Current and the status (on/off), in PLAIN TEXT, it will be perfect for simple command line control.

    Another 3 questions... and sorry:

    1) How can I perform a individual time configuration (I did not see in the web of the device that, set date or NTP config).
    2) Is there any way to program on/off periods and leave the configuration in the device itself? (to work even when ther is no connection to wifi or the home-assistant).
    3) How can I know that the BL0937CF is in the right GPIO (I understand, reading the datasheet, that is related to the protection when there is a high current). Is the protection took in account in your firmware? (switch off in a certain limit).

    ... probably I am asking for too much and is is something TBD.

    Thank you very much for your sorftware and the corrections performed. You made a fantastic work.

    EDIT:

    I include here my startup text (that includes the calibration of my device LSPA9 WB2S+BL0937). I performed the calibration using the original firmware in the other unit (it can not be perfect but more or less... it works).

    backlog startDriver BL0937; VREF 0.121402; PREF 1.235294; IREF 10.192307

    Added after 31 [minutes]:

    For your information, I updated with OTA from 1.10.2 to 1.10.4 ... and the device is dead.

    I tried to switch off many times before the 30 seconds but ... no device wifi appears for recovery.

    I understand that I need to open again and flash with USB-TTL again, true?

    Please, check that version... it seems to have any problem.