logo elektroda
logo elektroda
X
logo elektroda

Configuring OpenBeken on MagicHome RGBW-IR with BL602 for Home Assistant Discovery

MrShannon 3786 16
ADVERTISEMENT
  • #1 20740950
    MrShannon
    Level 3  

    I was able to flash the BL602 in a MagicHome compatible LED controller and configured the 5-pins for RGBW and IR, but so far I have not been able to get it added to Home Assistant using MQTT discovery.

    I followed this guide for flashing with OpenBL602_1.17.246.bin and configured the pins. I did change the standard order of the channels to match the pinout of my 12V LED Strip:
    GPIO3 = PWM, Channel 1 (red)
    GPIO4 = PWM, Channel 2 (green)
    GPIO21 = PWM, Channel 3 (blue)
    GPIO20 = PWM, Channel 4 (white)
    GPIO12 = IRRecv

    I also configured the Names and MQTT topic to use "obl-b396-mhled" and later that day I upgraded via OTA to 1.17.247.

    Then I followed this guide to configure Home Assistant Discovery, and I can see the MQTT State is "connected" from the main menu of the device page.

    Configuring OpenBeken on MagicHome RGBW-IR with BL602 for Home Assistant Discovery

    And I can see the device connecting in the MQTT logs in Mosquitto.

    
    2023-09-20 12:14:57: New connection from 192.168.0.192:64003 on port 1883.
    2023-09-20 12:14:57: New client connected from 192.168.0.192:64003 as obl-b396-mhled (p2, c1, k100, u'homeassistant').
    


    But no devices or entities appear in Home Assistant.

    Configuring OpenBeken on MagicHome RGBW-IR with BL602 for Home Assistant Discovery

    Today I upgraded again to 1.17.248 and tried running Discovery again, but still nothing is getting added to Home Assistant.

    Here's the LED strip lit up and working with the White LEDs - the RGB LEDs also work, I just can't control it from Home Assistant yet.
    Configuring OpenBeken on MagicHome RGBW-IR with BL602 for Home Assistant Discovery

    This is the Controller on Amazon, although the photo in the listing is wrong as it does not show the IR receiver: https://www.amazon.com/gp/product/B08Z7KXN6D/

    And here's a photo of my specific controller with the ZJ-BWCE-IR-RGBW v1.2 board with the Buffalo BL602 L20 S8JlF3 2040-F2 chip.
    Configuring OpenBeken on MagicHome RGBW-IR with BL602 for Home Assistant Discovery

    Any ideas on what I need to do to get this into Home Assistant?
  • ADVERTISEMENT
  • #2 20741236
    p.kaczmarek2
    Moderator Smart Home
    Hello, do you get that message?
    A browser screen message regarding MQTT discovery queued.
    What happens in HA logs when you get that message?
    Helpful post? Buy me a coffee.
  • #3 20741294
    MrShannon
    Level 3  

    I do, but it actually says "No relay. PWM sensor or power driver running. MQTT discovery queued."

    Error message: No relay, PWM, sensor or power driver running. MQTT discovery queued.

    I see nothing new in the Home Assistant Core log nor in the Mosquitto broker log. Is there somewhere else to look?
  • ADVERTISEMENT
  • #4 20742271
    spin55
    Level 17  

    MrShannon wrote:
    Any ideas on what I need to do to get this into Home Assistant?


    Have you tried manual MQTT configuration?

    Screenshot showing MQTT setup for RGB controller.

    In my case it is RGB controller. In your case you would have to add:

    color_temp_command_topic: "cmnd/obl429A0BD6/led_temperature"
    color_temp_state_topic: "obl429A0BD6/led_temperature/get"
  • ADVERTISEMENT
  • #5 20742654
    MrShannon
    Level 3  

    I did try that, but it did not work for me. And, the yaml I copied out of the Home Assistant Cfg page looks like it would make four separate lights, one for each of the RGBW channels. Is that the problem? Something about using four PWM channels?

    Code: YAML
    Log in, to see the code


    I also noticed that if I go to "Launch Web App" / Tools, I can use the buttons for 100% Red, 100% Blue, 100% Green and 100% Cool all work, but 100% Warm does nothing.

    Screenshot of LED tools menu with six buttons: 100% Red, 100% Green, 100% Blue, 100% Warm, 100% Cool, Toggle LED.

    I know the RGBW strip I am using has a dedicated White LED, and mine happen to be Warm (not Cool), so I am not sure why there are different buttons for Warm/Cool in the Tools. I thought maybe the 100% Cool button would use the RGB LEDs to make a cool white, and the 100% Warm button would use the dedicated White channel. Is that configurable?

    (sorry for stacking two questions in this post)
  • ADVERTISEMENT
  • #6 20742737
    spin55
    Level 17  

    Look at the Flags page and play with them. The 24th looks good.

    My firmware is old, I don't know if the Flag numbers will match yours.

    List of software feature flags with selected options.
  • #7 20744304
    MrShannon
    Level 3  

    Flag 24 did sound like it might do the trick, but when I turn that on the White LEDs stop working and the RGB LEDs just 'emulate' the white channel. In fact, the controller just completely stops using channel 4, so I have disabled that flag again.

    Do I need to configure the pins differently? My LED strip is pretty simple, but I don't know what the model is. They are not individually addressable so there is no IC chip and no data wires, just the ground wire and then 4 channels, one for each LED. Even the Tasmota guide for the Magic Home controller talks about using PWM, so I assumed PWM was the right setting for this strip.

    LED strip with wires and controller on a white surface.

    I don't understand why the YAML is making 4 individual lights instead of a single RGBW Light?

    And to get these in Home Assistant, do I need to configure something in MQTT? I thought discovery was enabled by default.
  • Helpful post
    #8 20744762
    spin55
    Level 17  

    I don't know if Home Assistant Discovery is already implemented for BL602. The author of the firmware or someone who has this device could confirm this for you.

    If it were in your case, I would load version 1.15.383 and do an initial RGB only configuration with the YAML that I provided to try to find out why the Light/RGB entity (only RGB at the moment) does not appear in Home Assistant.

    I have the same device in RGB version and with that firmware and that manual configuration it works. The RGB channels are the same as yours:
    P3 --> PWM 1 Red
    P4 --> PWM 0 Green
    P21 --> PWM 2 Blue

    mqtt:
    light:
    - unique_id: "OpenBL_LED"
    name: "OpenBL_LED"
    rgb_command_template: "{{ '#%02x%02x%02x0000' | format(red, green, blue)}}"
    rgb_value_template: "{{ value[0:2]|int(base=16) }},{{ value[2:4]|int(base=16) }},{{ value[4:6]|int(base=16) }}"
    rgb_state_topic: "obl-b396-mhled/led_basecolor_rgb/get"
    rgb_command_topic: "cmnd/obl-b396-mhled/led_basecolor_rgb"
    command_topic: "cmnd/obl-b396-mhled/led_enableAll"
    state_topic: "obl-b396-mhled/led_enableAll/get"
    availability_topic: "obl-b396-mhled/connected"
    payload_on: 1
    payload_off: 0
    brightness_command_topic: "cmnd/obl-b396-mhled/led_dimmer"
    brightness_state_topic: "obl-b396-mhled/led_dimmer/get"
    brightness_scale: 100
  • #9 20744881
    MrShannon
    Level 3  

    Hey, good suggestion spin55! I did not try an older version, but I did remove the settings from the white channel pin.

    Apparently having a fourth PWM channel is not being handled like I need it to. With only the RGB channels set, it generated some very different YAML code than before and similar to what you posted:

    Code: YAML
    Log in, to see the code


    and Home Assistant Discovery did send the message to the MQTT broker on the "homeassistant" topic!

    Code: JSON
    Log in, to see the code


    This was picked up by HA and now there is a device named "obl-b396-mhled" with a "Light" entity that I am able to use the strip with the color LEDs...but not the white. Still, that's progress!

    Screenshot of device info for BL602 and light control options

    Any suggestions how I can help getting this working with all four channels?
  • #10 20745489
    spin55
    Level 17  
    This thread talks about an RGBW strip with a BK7231N chip and it seems that the problem was solved with flag 24. Since you have already experienced this and it has not worked, the question arises: Is it implemented on the BL602 platform?

    https://www.elektroda.com/rtvforum/topic3962379.html#20471373

    On the other hand, from reading this extensive thread I have not been able to deduce if the firmware for the RGBW strips with BL602 chip is already implemented. So we will have to ask p.kaczmarek2.

    https://www.elektroda.com/rtvforum/topic3889041-330.html
  • #11 20746449
    p.kaczmarek2
    Moderator Smart Home
    I checked the code and it really looks like it should work. I also added a self-test to Window build and it passes it.

    I have no idea what's wrong at the moment, so I added this debug log:
    Screenshot showing a snippet of C code involving PWM counting functions.
    Can you update to latest build (it will be available in 15 minutes), of course don't power off during update, and try new version and check what does the log say? What are the seen PWM counts?

    Of course, I assume that:
    - you have 4 PWMs set
    - you have enabled flag 24 (OBK_FLAG_LED_EMULATE_COOL_WITH_RGB)
    It will not work otherwise with 4 PWMs at the moment. You would get that error:
    Code snippet in an editor with a highlighted error message line related to handling 4 PWM.
    of course, first set flag, then do discovery.

    Added after 1 [minutes]:

    MrShannon wrote:

    GPIO3 = PWM, Channel 1 (red)
    GPIO4 = PWM, Channel 2 (green)
    GPIO21 = PWM, Channel 3 (blue)
    GPIO20 = PWM, Channel 4 (white)
    GPIO12 = IRRecv

    Can you try:
    
    GPIO3 = PWM, Channel 1 (red)
    GPIO4 = PWM, Channel 2 (green)
    GPIO21 = PWM, Channel 3 (blue)
    GPIO20 = PWM, Channel 5 (warm white)
    GPIO12 = IRRecv
    

    skip channel 4 (which is emulated) ?
    Helpful post? Buy me a coffee.
  • #12 20746861
    MrShannon
    Level 3  
    I updated to 1.17.257, but whenever I add a fourth PWM pin the YAML that is shown in the "Home Assistant Cfg" page creates four "unique_id:" entries. This happens if I use Channel 4 or channel 5, and if Flag 24 is on or not.

    Screenshot of Home Assistant configuration with unique IDs.

    Code: YAML
    Log in, to see the code


    The odd thing is, when I hit "Start Home Assistant Discovery", it sent the same discovery message as if it still only had 3 pins configured. It's as if adding the 4th pin isn't being processed somehow.

    Code: JSON
    Log in, to see the code


    I watched the logs on the OpenBeken Web App and, there were a LOT of messages about "secondsWithNoPing" in there, but here's what I saw when I would make changes. It's also worth noting that there was only activity in the log when I change the pin configuration. There were no log entries when I changed the flag.

    I set Flag 24 OFF and removed the fourth PWM channel. This made a YAML configuration for RGB with only one unique_id for "OpenBL_LED_light" and posted a discovery message to Home Assistant
    Code: Text
    Log in, to see the code


    Leave Flag 24 OFF and add a 4th PWM pin on channel 5. This created a YAML configuration with four unique_id's "OpenBL_LED_light_1", "OpenBL_LED_light_2", "OpenBL_LED_light_3" and "OpenBL_LED_light_5" but did not send any messages to Home Assistant.
    Code: Text
    Log in, to see the code


    Turn Flag 24 ON and remove the 4th PWM pin. This made the same YAML configuration for RGB (no W) with only one unique_id for "OpenBL_LED_light" and posted a discovery message to Home Assistant
    Code: Text
    Log in, to see the code


    Leave Flag 24 ON and add the 4th PWM pin on Channel 5 again. This created the same YAML configuration with four unique_id's "OpenBL_LED_light_1", "OpenBL_LED_light_2", "OpenBL_LED_light_3" and "OpenBL_LED_light_5" but did not send any messages to Home Assistant.
    Code: Text
    Log in, to see the code


    Does that help?
  • #13 20747009
    p.kaczmarek2
    Moderator Smart Home
    MrShannon wrote:

    Leave Flag 24 ON and add the 4th PWM pin on Channel 5 again. This created the same YAML configuration with four unique_id's "OpenBL_LED_light_1", "OpenBL_LED_light_2", "OpenBL_LED_light_3" and "OpenBL_LED_light_5" but did not send any messages to Home Assistant.
    Code: Text
    Log in, to see the code

    Does that help?

    why do you think that it didn't publish any messages? Log clearly says:
    
    Info:MQTT:Queued topic=homeassistant/light/OpenBL_LED_light/config, 1 items in queue
    Info:MQTT:Publishing val (812 bytes) to homeassistant/light/OpenBL_LED_light/config retain=1
    

    I am starting to suspect that we need to increase some kind of MQTT buffer for BL602 because it seems messages of certain larger lengths seems to be skipped...
    Helpful post? Buy me a coffee.
  • #14 20747335
    MrShannon
    Level 3  

    p.kaczmarek2 wrote:
    Why do you think that it didn't publish any messages?


    That's a fair question. What I shared from the logs was what happened after I would change the PIN settings and hit Save on the "Configure Module" page. When I changed the Flags or when I hit "Start Home Assistant Discovery" is when nothing would get posted to MQTT. It seems that changing the PIN settings was automatically posting the discovery message, which is good, but I was unable to do it manually.

    That, and the YAML being generated when I set up 4 channels doesn't look right, so even if I could force it, I think it would be...bad.

    When I only have the three channels configured, Home Assistant only shows the RGB color picker
    Screenshot of Home Assistant lighting interface with three channels and RGB control.

    But, after you pointed out the discovery message was posted after adding the 4th channel, I looked again and realized that the Light Entity in Home Assistant now has both an RGB and W control.
    Light control interface with four RGB and W channels

    The odd part is that the controller is allowing both the RGB and W LEDs to be on at the same time. I can turn off Flag 24 to prevent both from being on, but then "Cool White" no longer works.
    LED strip with RGB and white diodes connected to a controller.

    This is pretty different from how the Magic Home controller manages things. There, the Light entity shows an RGB and W control, but the W is just an on/off button and not a color temperature picker. The White LEDs on the strip are a fixed temperature and only their brightness can be adjusted. Here's an example of the same hardware under Magic Home.

    LED lighting control interface in a kitchen with a slider set to 20% and options for color and brightness selection.

    Is there a flag I should be setting to make the OpenBeken controller behave like this?
  • #15 20747853
    p.kaczmarek2
    Moderator Smart Home
    Yaml generation for 4 channels is not implemented, but the discovery should work.

    Your previous post indicates that HASS Discovery for RGBW does not reach the HA, so I increased the MQTT buffer for BL602:
    https://github.com/openshwprojects/OpenBL602/commit/e5769160cfc91a5fe36f040b3d5314e51eda3a28
    Can you update and recheck? Namely, I am referring to what I've written in post #13
    Helpful post? Buy me a coffee.
  • #16 20750728
    MrShannon
    Level 3  

    Sorry, this took longer to reply than I wanted, but I did update to 1.17.261 and went through a couple of actions. The behavior doesn't seem any different than before, and I haven't figured out how to configure an RGBW (RGB and single dedicated/fixed White color) instead of an RGBCW (RGB and both Cool and Warm white colors).

    I've also removed all of the "secondsWithNoPing" lines, but here are the logs:

    Leave Flag 24 off, and set a fourth channel to PWM on channel 5
    Code: Text
    Log in, to see the code


    Turn Flag 24 on, then remove the fourth PWM channel
    Code: Text
    Log in, to see the code


    Finally, leave Flag 24 on and add the fourth PWM channel
    Code: Text
    Log in, to see the code


    After that, I disabled Flag 24 to prevent the RGB and W channels from being used at the same time, but that did not create any events in the log.

    Then I rebooted it just to see the log entries and saw a few things of interest.

    First, the password for the Wifi SSID -and- the MQTT is clearly in the logs... this might be ok for debugging, but I'd recommend not doing that on a real release. It would make sharing logs potentially dangerous! Maybe replace the clear text password with '***' or something?
    Code: Text
    Log in, to see the code


    Second, there is a message about the "IR" driver being "not known", is that just meaning future work is needed to implement the IR controller?
    Code: Text
    Log in, to see the code


    And finally, there was an error about 'startScript NOT found' - not sure if that really matters either at this point.
    Code: Text
    Log in, to see the code


    Thank you for all the interaction on this, I really do appreciate it!
  • #17 20775417
    MrShannon
    Level 3  

    Is there a configuration or flag that I can set to expose the controls for an RGB color selector and brightness, but the White LEDs are just on/off/brightness without a color temp? Like this:

    LED lighting control interface in a kitchen with a slider set to 20% and options for color and brightness selection.

    My controller/strip has only a dedicated Warm LED, and if I switch from the RGB to the White channel, the temperature picker is not appropriate. Sliding the picker all the way to warm basically sets the White LEDs to 100% brightness, and sliding to cold just turns them off because there are no Cool LEDs to turn on.

    I've updated to 1.17.276 and found if I turn on Flag 24 the RGB LEDs will emulate the Cool White. This also means adjusting the color temp basically adjusts the brightness of the W and RGB channels to create the selected color temperature. This also means all of the LEDs on the strip would be on at the same time, and I'm not sure if that's... safe?

    If possible, I'd prefer to have the White channel only allow on/off/brightness settings and to not provide a color temp option. That would prevent all the LEDs in the strip from being on at the same time, but I could switch between a color selection and white.

Topic summary

The discussion revolves around configuring OpenBeken firmware on a MagicHome RGBW-IR LED controller with a BL602 chip for integration with Home Assistant via MQTT discovery. The user successfully flashed the firmware and configured the GPIO pins for RGBW and IR channels but faced issues with Home Assistant not recognizing the device correctly. Responses included troubleshooting steps such as checking Home Assistant logs, trying manual MQTT configuration, and adjusting firmware flags. The user discovered that enabling Flag 24 caused the RGB LEDs to emulate the white channel, leading to confusion in controlling the white LED. Suggestions included reverting to an older firmware version and modifying the YAML configuration to ensure proper recognition of the RGBW setup. The conversation highlighted the need for specific configurations to handle RGBW versus RGBCW setups and the challenges of integrating multiple PWM channels in Home Assistant.
Summary generated by the language model.
ADVERTISEMENT