logo elektroda
logo elektroda
X
logo elektroda

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

p.kaczmarek2 3540 10
ADVERTISEMENT
📢 Listen (AI):
  • [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 12920 posts with rating 10724, helped 599 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 20562699
    p.kaczmarek2
    Moderator Smart Home
    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
    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.
  • ADVERTISEMENT
  • #4 21655123
    p.kaczmarek2
    Moderator Smart Home
    @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 36  
    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 28  
    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.
  • #7 21655163
    p.kaczmarek2
    Moderator Smart Home
    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 28  
    >>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
    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
    #10 21655284
    insmod
    Level 28  
    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.
📢 Listen (AI):

Topic summary

The discussion focuses on the automatic pairing process of BK7231 (BK7231T, BK7231N), BL602, W800/W801, W600/W601, and XR809 devices with Home Assistant using OpenBeken firmware. A video guide demonstrates the Home Assistant Discovery feature, which simplifies device integration without requiring YAML code. Users can easily pair their devices with a single button click, allowing for the automatic recognition of relays, LED controls, and sensors like DHT and BL0942. Recent updates have improved the discovery system, enabling advanced channel types and custom channel labels to be recognized by Home Assistant. Users are encouraged to refer to the OpenBeken documentation for further details and supported devices.
Summary generated by the language model.
ADVERTISEMENT