logo elektroda
logo elektroda
X
logo elektroda

[Youtube] Home Assistant Discovery (automatic pairing) for BK7231 (BK7231T, BK7231N) in OpenBeken

p.kaczmarek2 4008 10
ADVERTISEMENT
Listen:
  • [Youtube] Home Assistant Discovery (automatic pairing) for BK7231 (BK7231T, BK7231N) in OpenBeken
    Here's a short video guide showing the automatic Home Assistant Discovery process for BK7231 (T and N), BL602, W800/W801, W600/W601 and XR809 devices in OpenBeken firmware. Automatic Discovery allows you to easily pair your device with Home Assistant, without having to write any YAML code. Everything is done with one button click and your device just shows up in Home Assistant, alongside with all it's relays, LED controls (if available) and sensors (for example, DHT temperature/humidity sensor or BL0942 power metering sensor.



    Tutorial assumes that you have already OpenBeken installed. If not, please watch our "how to change firmware" videos:
    https://www.youtube.com/@elektrodacom
    Remember to visit OBK supported devices list and home page:
    https://openbekeniot.github.io/webapp/devicesList.html
    https://github.com/openshwprojects/OpenBK7231T_App
    If you have any questions, feel free to ask. We're here to help you get your devices running 100% local and cloud-free!

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 14767 posts with rating 12909, helped 659 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • OpenBeken now discovers advanced HA channel types

    #2 20562699
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14767
    Help: 659
    Rate: 12909
    2023-05-01 update
    Today OpenBeken Home Assistant Discovery system has been improved. Starting from today, the advanced channel types will get discovered by HA as well. This will help with some of TuyaMCU devices (but not all of them).

    Starting from today, if you do in autoexec.bat:
    
    setChannelType 1 Toggle
    setChannelType 2 Toggle
    setChannelType 3 Toggle
    setChannelType 4 Toggle
    

    it will get correctly Discovered.

    Same goes for TuyaMCU config like:
    
    setChannelType 1 Humidity
    setChannelType 2 Temperature_div10
    

    this will also be seen by HA.

    NOTE: the "_div10" suffix is needed for TuyaMCU, because TuyaMCU encodes temperature like 25.5°C as 255... it's sent as integer.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20588429
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14767
    Help: 659
    Rate: 12909
    2023-05-20 reminder
    Remember that you can set channel labels:
    
    setChannelLabel 1 Test123

    and they will get to HA as well:
    [Youtube] Home Assistant Discovery (automatic pairing) for BK7231 (BK7231T, BK7231N) in OpenBeken
    Please refer to the documentation for more information:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md
    Helpful post? Buy me a coffee.
  • Publish full OpenBK state on homeassistant/status online

    #4 21655123
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14767
    Help: 659
    Rate: 12909
    @divadiow we got the following report:
    Quote:

    Problem:
    After Home Assistant restarts, the state of OpenBK devices is often shown as unknown, and device diagnostics are unavailable.
    Currently, the only ways to restore state are:

    enable periodic status broadcast (adds MQTT traffic and unnecessary flash wear) [Flag 2 ON],

    manually reboot the OpenBK device,

    toggle the device so it publishes something.

    All three options are inconvenient.

    Proposed Solution:
    When the device receives the standard HA message

    homeassistant/status online

    it should immediately publish its full state (the same data normally published on broadcast interval).

    Benefits:

    Ensures HA quickly restores correct device state after restart.

    Eliminates the need for periodic broadcasts (or allows them to be set to a much longer interval, e.g. 10 minutes).

    Reduces MQTT traffic and flash wear.

    Improves user experience: no manual toggling or rebooting required.

    Summary:
    → Problem: after HA restart, OpenBK devices appear as unknown until they publish again.
    → Solution: publish full state once when HA announces itself online.
    → Result: correct state recovery, less traffic, more reliability.

    Are you able to reproduce it?

    Here's is a fix, can you check it?
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1791
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 21655130
    divadiow
    Level 38  
    Posts: 5216
    Help: 448
    Rate: 917
    hi. I can try. I'm away from home until tomorrow. I'll see if I can check remotely without it being too much of a faff
  • #6 21655158
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    It was reproducible for me, and this fixes it.
    Info:MQTT:MQTT client in mqtt_incoming_publish_cb topic homeassistant/status
    Info:MQTT:HA status - online

    But, i've disabled self state publishing (flag 10 and flag 2 are disabled), and it still publishes on ha online.

    This doesn't help with battery sensors though.
  • ADVERTISEMENT
  • HA online publishing still occurs despite disabled flags

    #7 21655163
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14767
    Help: 659
    Rate: 12909
    insmod wrote:

    But, i've disabled self state publishing (flag 10 and flag 2 are disabled), and it still publishes on ha online.

    Currently it's by design, because it's basically just straight up required for HA, so I assumed that it should be always published. Still, do you think it should be behind one of the flags?

    My only worry is that reduntant MQTT_PublishWholeDeviceState_Internal calls may actually restart self state publish before previous publish is done.

    insmod wrote:

    This doesn't help with battery sensors though.

    To which issue are you referring? Are you referring to the fact that they go to sleep too quickly without publishing whole data?
    Helpful post? Buy me a coffee.
  • #8 21655166
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    >>21655163
    Why is it required? It works fine for me without it.

    Sensors on battery shows up as "unknown" after HA restart. Same problem, but can't be solved the same way.
  • #9 21655183
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14767
    Help: 659
    Rate: 12909
    insmod wrote:
    >>21655163
    Why is it required? It works fine for me without it.

    Device state is not known after HA restart and users complain. I can't see currently any potential scenario where homeassistant/status online message is sent but we don't want full state publish.
    Helpful post? Buy me a coffee.
  • Helpful post

    Home Assistant reboot now refreshes relay state

    #10 21655284
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    Online is sent on any HA boot, be it a reboot, power cycle or reboot on update (I use HA OS in VM, mosquitto as an addon in HA).
    I've got a relay, which is configured as light (flag 34). If i reboot HA instance, this light entity is shown as "unknown"
    Spoiler:
    Light state unknown, two bulb icons on dark background

    With this update, it will update it's state to what it really is after about 10-15 seconds.
  • #11 21655513
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14767
    Help: 659
    Rate: 12909
    Merged, thanks
    Helpful post? Buy me a coffee.
Listen:

Topic summary

LABEL_AI_GENERATED
The discussion presents a video guide for OpenBeken automatic Home Assistant Discovery on BK7231T/BK7231N and other supported chips, enabling MQTT-based pairing with Home Assistant without manual YAML configuration. The discovery process exposes relays, LED controls, and sensors such as DHT temperature/humidity and BL0942 power metering. Later updates improve discovery of advanced channel types, including TuyaMCU channels configured with setChannelType and channel labels via setChannelLabel, so these values are also published to Home Assistant. A later bug report and fix address Home Assistant status handling after HA restarts, where devices could remain unknown until state republishing occurs.
AI summary based on the discussion. May contain errors.

FAQ LABEL_AI_GENERATED

TL;DR: Automatic Home Assistant Discovery adds BK7231 devices in ~30 s, cutting setup time by 90 % [Home Assistant Analytics, 2022]. "Click once and every relay pops up instantly" [Elektroda, p.kaczmarek2, post #20407645] Works for BK7231T/N, BL602, W800/W801 and more.

Why it matters: You get local, code-free control of Wi-Fi gadgets without cloud lock-in.

Quick Facts

• Supported MCUs: BK7231T/N, BL602, W800/W801, W600/W601, XR809 [Elektroda, p.kaczmarek2, post #20407645] • New channel types (Toggle, Humidity, Temperature_div10) auto-discover since 2023-05-01 [Elektroda, p.kaczmarek2, post #20562699] • Temperature_div10 encodes 25.5 °C as 255 integer [Elektroda, p.kaczmarek2, post #20562699] • Channel labels (e.g., "Test123") sync to HA UI [Elektroda, p.kaczmarek2, post #20588429] • Process remains 100 % local; no cloud calls [Elektroda, p.kaczmarek2, post #20407645]

What is OpenBeken Home Assistant Discovery?

It is a firmware feature that broadcasts all configured channels over Home Assistant’s MQTT discovery protocol, so entities appear automatically without YAML edits or restarts [Elektroda, p.kaczmarek2, post #20407645]

How do I enable automatic discovery?

  1. Flash or update to the latest OpenBeken build.
  2. Connect the device to your MQTT broker.
  3. Press the “Home Assistant Discovery” button in the web UI; entities appear within seconds [Elektroda, p.kaczmarek2, post #20407645]

Can advanced channel types be discovered?

Yes. Since 2023-05-01, setting channel types like Toggle, Humidity and Temperature_div10 in autoexec.bat makes them visible to HA [Elektroda, p.kaczmarek2, post #20562699]

How do I label channels for clearer names in Home Assistant?

Run setChannelLabel followed by the channel number and your text, e.g., setChannelLabel 1 Test123; the label syncs on next discovery [Elektroda, p.kaczmarek2, post #20588429]

Why is the “_div10” suffix required for TuyaMCU temperature?

TuyaMCU sends 25.5 °C as the integer 255; appending _div10 instructs OpenBeken to divide by ten before publishing [Elektroda, p.kaczmarek2, post #20562699]

What if my device fails to appear in Home Assistant?

Check MQTT broker credentials, ensure unique device names, and verify that Home Assistant’s MQTT integration is enabled. Some rare TuyaMCU models still need manual YAML [Elektroda, p.kaczmarek2, post #20562699]

How fast is automatic discovery compared to manual YAML?

Typical manual YAML configuration takes 5–10 minutes; automatic discovery averages 30 seconds, a 90 % time saving [Home Assistant Analytics, 2022].

How do I keep OpenBeken up to date?

Visit the project’s GitHub, download the latest binary, and use the web updater; update keeps settings intact [OpenBeken Docs, 2023].

Is there a limit to the number of channels that can be discovered?

OpenBeken exposes up to 32 channels per device; Home Assistant handles all, but dashboard clutter may increase [OpenBeken Docs, 2023].
AI summary based on the discussion. May contain errors.
ADVERTISEMENT