logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 178092 1242
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #781 20104054
    p.kaczmarek2
    Moderator Smart Home
    xostia wrote:

    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?

    The 1.10.4 works for me:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant

    Did you confuse the OTA file for N version with T version? This would block the device.


    Futhermore.... 1.10.2 was 45d47d2 commit...
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    The only things added were:
    https://github.com/openshwprojects/OpenBK7231...mmit/84b982a7177f40fd60c90bd1f310c90b764c24a9
    https://github.com/openshwprojects/OpenBK7231...mmit/279c61a26382be5808fc9b46ba1b73f6ba7e671f
    I don't think these changes could cause such a fatal behaviour, especially with all the safety checks and precautions in place. Rebooting device 5 times with failure should start it without any drivers.

    EDIT: second check, LSPA9 BL0937:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    EDIT2: Third test (ignore extra channel fields, I'm testing:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #782 20104098
    marioalmeida
    Level 10  
    @xostia , @p.kaczmarek2

    I update mine from 1.10.2 to 1.10.4, device is working.
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
  • ADVERTISEMENT
  • #783 20104277
    xostia
    Level 7  
    Thank you @p.kaczmarek2 and @marioalmeida...

    It is possible that I flashed the N version... sometimes this is a mess with the soldering, the cables, the computer... arggg, probably my mistake.

    I flashed the second LSPA9 unit and reflashed this one... both are working with 1.10.4.

    Ah! including:

    P6 Wifi_n 0

    The blue led flashes during connection and stays on if the wifi connection is established.

    ... all is in a good point to create a "quick profile". All seems to work well...

    When you have time, tell me samething about this:

    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 save the configuration in the device itself? (to work even when there is no connection to wifi or the home-assistant).
    3) How can I know that the BL0937 CF 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).

    Thank you for your quick asnswer and updates. This works perfect!
  • #784 20104638
    marioalmeida
    Level 10  
    @p.kaczmarek2

    In cfg_generic you have now mentioned "May cause device disconnect" for "Flag 2 -[MQTT] Broadcast self state every minute", I had it ON for 3 of my devices and after upgrade to version 1.10.4, one of the device I disable for testing.
    On the 2 devices where the check is ON, I don't have any issue but on the device where the check is OFF, the entity in Home Assistant becomes Unknown

    [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
  • #785 20105046
    p.kaczmarek2
    Moderator Smart Home
    @marioalmeida there is a certain very rare case where doing a lot of MQTT publish can disconnect device, but I already added multiple stability improvements and the final fix is also coming soon.

    Maybe retain YAML setting would help?

    @xostia for now, I am doing a simple TCP console with a certain set of commands that return only the requested value
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Examples of short commands:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    The final form of console is not determined yet. Right now "Short get" commands return single string value so you can easily parse it, but set commands return full output.

    NOTE: remember to close the socket after you execute the command, currently commandline handles one client at time, altough it would be relatively easy to change it fully to use non-blocking berkeley sockets IO and use multiple sockets at time.

    The console is not released yet as I am testing stability.

    @xostia NTP config is not exposed it, but we'll get it working, one feature at time.

    I will also add mechanism to do automatic on/off soon.

    Can you tell me more about your desired use case for the pre-implementation analysis?


    xostia wrote:

    3) How can I know that the BL0937 CF 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).

    I am not sure what are you asking for. For the first part of the question, I'd say that you open device and check the tracks with multimeter (you know pinout of BL0937. Regarding the second part...
    Do you mean over-current scenario?
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    That's not present right now, I think. Is there a practical use case for that?
    Helpful post? Buy me a coffee.
  • #786 20105878
    Tych0
    Level 6  
    p.kaczmarek2 wrote:
    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/OpenBK7231...mmit/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

    Nice, works as you designed it!
    I had to use "SM2135_Map 1 0 2 4 3" as startup command for the LSC GU10 RGBCW Led.
  • #787 20106440
    leecher1337
    Level 6  
    p.kaczmarek2 wrote:
    ]
    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.

    Absolutely sure about the PINs, checked with Multimeter multiple times.
    Can also be seen on the Pinout of the Pin header:

    Code: Text
    Log in, to see the code


    PWM2 = OB38A04T1: TK6/OCI_SCL/IIC_SCL/RXD_0/P1.1
    RXD1 = OB38A04T1: TK5/OCI_SDA/IIC_SDA/TXD_0/P1.0

    Tried to read data with 9600,8,N,1 but to no avail, didn't see any data over these PINs. My guess is that the controller is just used to capture Touch input and somehow tell the WB3S about the keys pressed down, but onknown, how it works.
    Is there anything that I can try to find out besides reverse engineering the original firmware, which I fear I'm not capable of?
  • #788 20106634
    p.kaczmarek2
    Moderator Smart Home
    It's possible that's using I2C communication or something else. You'd need to check it with, for example, Bus Pirate. I could also try do some testing myself, but I'd need to know where to get that device.
    Helpful post? Buy me a coffee.
  • #789 20106817
    xostia
    Level 7  
    Hi @p.kaczmarek2 ...

    Thank your for your answers. The console idea, for me, is great! ... date/time management and programming will be perfect. Thank you for hearing us.

    I will try to check if the BL0937 CF pin is in the right GPIO... but I am pretty sure that yes... I used the same that you indicated in this threat forother device and SEL and CF1 seems to work ok, probably CF is also right.

    It could be interesting, in the software, detect that overcurrent pulse of 6.78KHz (BL0937 CF)... and switch off the plug. Probably is not so easy and I am missing something. Using Smart Life App with the original firmware there was an option to "enable over-current protection". I suppose that It behaves like that.

    One detail, the code to include in YAML configuration for Home Assistant (provided in the web interface of the device) misses an "unique_id" (and for my LSPA9 WB2S the 1/0 enable/disable for the switch are inverted ... but I suppose that quickconfig modifies that and probably I was playing with that and that is the reason in my case).

    P.S. My use case is quite generic ... probably I will end installing something like home assistant after some time... but I will install 2 or 3 of this devices in my parent's home with a simple access to enable/disable with simple shell scripting. If the sheduling on/off is implemented... It is easier (I do not need to use cron to launch scripts). Thank you for your effort.
  • #790 20107248
    leecher1337
    Level 6  
    p.kaczmarek2 wrote:
    It's possible that's using I2C communication or something else. You'd need to check it with, for example, Bus Pirate. I could also try do some testing myself, but I'd need to know where to get that device.


    I also thought about I2C, but wouldn't it be connected to the appropriate I2C ports of the chip then?
    Unfortunately, I don't have a Logic analyzer available. I could try piscope on my RasPi, but I don't think that it's useful.

    The device is sold on Amazon, see here: https://www.amazon.de/-/en/RTERSKY-Smart-Roller-Shutter-Switch/dp/B07PQ11PPS?th=1
  • #791 20108479
    p.kaczmarek2
    Moderator Smart Home
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #792 20108768
    ferbulous
    Level 18  
    Hi @p.kaczmarek2 is there any plans to include irsend/irreceive for tuya ir blasters (now either using wb3s or cb3s)?
  • #793 20109175
    Vampir8
    Level 16  
    A core for PlatformIO is being created, not everything is working yet, but in the future there will be a chance to compile Tasmota or other projects
    https://kuba2k2.github.io/libretuya/
    The project focuses on developing a working core compatible with Arduino. The core is inspired by the official Espressif core for ESP32, which should make it easier to port / run existing ESP applications on Tuya IoT (and 3rd party) modules.

    LibreTuya also provides a common interface for all implementations. The interface is based on the official ESP32 libraries.

    This is good news for me.
  • #794 20110128
    p.kaczmarek2
    Moderator Smart Home
    It was already posted here several times, so it's not a news. Please stop with the openly advertising posts.

    Last time I checked their Beken ADC code, it crashed every time if there was any other thread running :D

    @ferbulous IR driver was announced by @btsimonh , ask him, he was planning to port IRLibrary from Arduino

    @leecher1337 and how it's going?

    @xostia ok I will look into it. Was unique ID requirement added recently?

    Next major update will be a simple script interpreter, scritps editable in WWW panel, they should be easy to read and in my opinion much more understandable than the ones in Tasmota
    Helpful post? Buy me a coffee.
  • #795 20110674
    kuba2k2
    Level 13  
    p.kaczmarek2 wrote:
    Last time I checked their Beken ADC code, it crashed every time if there was any other thread running

    To clarify: you tested the same code in OBK project, and it was crashing. AFAIK you didn't test this code in LT project, and it works fine in that scenario.

    But yes, I'll agree that posts made with a clear intention of simply advertising a similar project (or: a way to run a similar project) are not entirely appropriate.
  • ADVERTISEMENT
  • #796 20111630
    marioalmeida
    Level 10  
    @p.kaczmarek2
    Is it possible to add support for tuya fan with 5 speed? as I have a tuya fan controller with 5 speed option
    
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 03 02 00 04 00 00 00 02 1C 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 3, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 2
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 03 02 00 04 00 00 00 03 1D 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 3, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 3
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 03 02 00 04 00 00 00 04 1E 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 3, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 4
    Info:TuyaMCU:TUYAMCU received: 55 AA 03 07 00 08 03 02 00 04 00 00 00 05 1F 
    Info:TuyaMCU:TuyaMCU_ProcessIncoming: processing command 7 (State) with 15 bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: processing dpId 3, dataType 2-DP_TYPE_VALUE and 4 data bytes
    Info:TuyaMCU:TuyaMCU_ParseStateMessage: raw data 4 int: 5
    


    //fan speed channel
    setChannelType 3 OffLowMidHigh
    // link output 3 with data type 2 to channel 3
    linkTuyaMCUOutputToChannel 3 2 3
    


    With above config I get only 3 fan speed, appreciate if you can add 4th and 5th speed option.
  • #797 20111866
    khoam
    Level 42  
    Vampir8 wrote:
    LibreTuya also provides a common interface for all implementations. The interface is based on the official ESP32 libraries.

    Very well documented design and well-ordered source code. It's good that based on PlatformIO - it will save a lot of time for people who will want to develop their software based on LibreTuya.

    kuba2k2 wrote:
    But yes, I will agree that posts written with the clear intention of just advertising a similar project (or: a way to run a similar project) are not entirely appropriate.

    The question is whether the intrusive surreptitious advertising of a particular hardware manufacturer's products is also appropriate.
  • #798 20111876
    xostia
    Level 7  
    Hi @p.kaczmarek2

    I installed the last version of Home Assistant and the YAML check shows that message, it is mandatory a unique id (I wrote the same name and it works).

    I was checking the information in github but I did not find this... wich commands can a launch from web interface? I am preparing a console menu to use it with a simple ssh to my internet router. For example, the toggle button executes http://the.name.or.ip/index?tgl=1 but I tried http://openbk1./index?on=1 and it also works.

    I would like to know if there are commands about the status of the relay and to get the current or voltage... to include in my openbk.sh bash script. Do you have the list of the implemented right now?. I was testing with the commands documented in Tasmota... but are not the same. The truth is that they should be the same (if possible).

    If in a near future you implement a simple scheduler for the on-off switches... it will be a great advance.

    Thank you for your time.
  • #799 20111914
    p.kaczmarek2
    Moderator Smart Home
    kuba2k2 wrote:

    AFAIK you haven't tested this code in LT project and it works fine in this scenario.

    From what I remember your words, you haven't tested this code with many threads yet, unless something has changed since then.

    By the way, did you fix multiple WiFi reconnect (first failure)?

    khoam wrote:

    The question is whether the intrusive surreptitious advertising of a particular hardware manufacturer's products is also appropriate.

    Hello @khoam in a thread about Beken. Maybe you would take this opportunity to ask the users present here about alleged Tuya migration from ESP to other systems you think I am spreading "fishing stories", lies and FUD?

    Bonus question: how do you think @khoam works for "quick device search" for Bluetooth pairing when those devices are on ESP?

    And a more generic question, mostly to English speaking users - have you noticed any change in presence of ESP chips inside the Tuya devices? Do you think that Tuya is using now ESP more, or less, or much less than before (3 years ago or so)? Do you think that there is a trend of migration from ESP to different devices (mostly BK or different BT-supporting ones), or is it just a FUD spread by OpenBeken developers ? I would like to hear your opinion.
    Helpful post? Buy me a coffee.
  • #800 20113255
    xostia
    Level 7  
    Hi again @p.kaczmarek2. I tried to edit two times my previous post but it never shows edited...

    I updated one of the LSPA9 (BL0937 version) with 1.10.9 but I did it with OpenBK7231T_UA_1.10.9.bin (the bin ... and not the rbl).

    ... It is solved except the MAC address. Now, the MAC C8478C000000 and if I try to change I obtain a "MAC change error?" and it stays the same (probably some corrupt data someware in the flash). Any solution?. If I reopen the device, flash the original firmware and flash again your OpenBK will it be solved?

    Thanks.
  • #801 20113420
    p.kaczmarek2
    Moderator Smart Home
    I apologize for the technical difficulties, @xorya . It seems that there was something wrong with the server. I tried to reply you earlier, but my answer was lost as well.

    @marioalmeida adding new select type is just few minutes, do you mean 5 speeds (1, 2, 3, 4, 5) and 0 as "off" value? I will commit it today.

    @xostia I am aware about this issue. You have erased some memory region related to MAC. The temporary fix would be to reflash with original 2MB if you have a backup. Otherwise, you'll have to wait.

    @xostia I will ask again as my previous post most likely was lost due to the forum issue, which exactly Tasmota commands do you want? I can try to provide them for you, as I already have planned support for eg. Tasmota Control mobile Android app, etc.

    It's just that I do the project in my free time so sometimes you'll have to wait for an update longer.

    Dodano po 43 [minuty]:

    UPDATE: I have added requested channel type:
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    Helpful post? Buy me a coffee.
  • #802 20113482
    marioalmeida
    Level 10  
    @p.kaczmarek2
    I have 2 controllers,

    1) with speed 0, 1, 2, 3 and 4
    2) with speed 1, 2, 3, 4, 5 and 0 as off

    Added after 1 [minutes]:

    btw, if I set the desired speed via MQTT, it dose take effect, its only from the UI there isn't any option.
  • #803 20113504
    p.kaczmarek2
    Moderator Smart Home
    marioalmeida wrote:

    1) with speed 0, 1, 2, 3 and 4

    So 0 is labelled "Lowest" and not "Off"?
    Helpful post? Buy me a coffee.
  • #805 20113585
    p.kaczmarek2
    Moderator Smart Home
    Ah okay, no problem here, I will add this option as well and update docs.

    The better manual is coming soon

    Btw, can you post more information on the fan drivers you have?
    Helpful post? Buy me a coffee.
  • #806 20113719
    xostia
    Level 7  
    Hi @p.kaczmarek2... no stress, all this is really nice. I am enjoying to play with this and your work is amazing.

    I was testing some commands from here: https://tasmota.github.io/docs/Commands/#control but the URL commands for on/off are different, in general all are different. It would be nice to make them compatible Tasmota. I did not find in Tasmota any web command to get Current, Amp ... In the script that I prepared, I parsed the output of the main page of your firmware to extract this info. In Tasmota there is also the Power command to know the status (I had to do it in my script also parsing the web output provided by your firmware).

    About the "recovery MAC" address that I have now... I can live with this "C8478C000000". If in a future, if there is a way to write the original one, perfect... probably it will be easier to achieve no error trying to modify the MAC in the web interface.

    In any case... I prepared a bash script that runs a menu to enable and disable two switches and shows the status of them (Current in Watt and ON/OFF state). It is not perfect but really easy to use from a SSH connection to my router with DD-WRT (From Windows I use Putty and from Android ConnectBot... I discovered this last week, it can even provice tunnels to connect to IPs inside my home network). Here is the script if anybody wants to use it (http://openbk1. and http://openbk2. are my two LSPA9 BL0937 version, but this should work with any other device with your firmware OpenBK7231, replacing these names with your own names or IPs):
    Code: Bash
    Log in, to see the code


    You can download it directly from here:

    https://www.dropbox.com/s/e244ty8fet746df/openbk_v2.0.sh?dl=0

    It looks like this:

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


    If you want to include it or some part as an example from your wiki... no problem at all.

    Thank you again
  • #807 20114051
    p.kaczmarek2
    Moderator Smart Home
    You have a very nice script here, short and self-contained, but can you add it here just with a < syntax = bash > block? It's better than using external links that may expire someday.

    Also, have you looked into new TCP command line? It also provides short commands that return only requested value. You just need enable it in options and then connect TCP on port 100 (should be configurable in the future). I will provide more information soon.
    Helpful post? Buy me a coffee.
  • #808 20114576
    marioalmeida
    Level 10  
    p.kaczmarek2 wrote:

    Btw, can you post more information on the fan drivers you have?


    I was waiting for the 5 speed option to be added, now create a teardown post at https://www.elektroda.com/rtvforum/topic3908093.html

    Is it possible to add an option to control the WiFi LED indicator with TuyaMCU? please check the below video, the indicator is at the center and keep blinking.


  • #809 20114598
    p.kaczmarek2
    Moderator Smart Home
    Very good job, @marioalmeida . Please wait for our moderator to review your teardown and then it will be moved to the correct section of our forum.

    Your Home Assistant config also looks very useful, I must admit I have never used Tuya fan controllers before so your topic will really come in handy.

    Regarding Tuya MCU WiFi LED, I think I mentioned it before, but I don't have any devices with such LED. I could try to implement it without testing it myself, but I'd need you to check it from time to time.

    If you have any other BK devices, feel free to show them as well.
    I will be posting soon some more teardowns as well.

    UPDATE: Automatic W800 platform builds has been added to our Github!
    Helpful post? Buy me a coffee.
  • #810 20115304
    marioalmeida
    Level 10  
    p.kaczmarek2 wrote:

    Regarding Tuya MCU WiFi LED, I think I mentioned it before, but I don't have any devices with such LED. I could try to implement it without testing it myself, but I'd need you to check it from time to time.

    I'll be in India for another 10days, if you can send the firmware, I'll be able to test, after that I'll be in the U.A.E, where I have some Tuya smart plugs with power monitoring IC to be migrated to OpenBK and also a Tuya smart door lock, is there support for smart door locks with OpenBK firmware?

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