BRmesh app bluetooth lights

Hi Dennis,

Thanks a lot for your awesome ESPHome setup! It’s been incredibly helpful.

I noticed that the transitions when turning on/off or changing colors are a bit jerky. Is there a way to adjust the duration of these transitions? Any pointers on how to smooth them out would be much appreciated!

Thanks again!

Broadlink Fastcon use a system that piggybacks on Bluetooth Low Energy advertisements, and I was finding that command messages were getting lost when sending multiple…

So what I did was, I setup a queue now that takes commands (i.e. any change in color/brightness/etc) and advertises them for a set amount of time before sending the next command in the queue. The advertisement period has a default time length, but is configurable. But it still inherently queues the commands up…

I added this to each of my lights in the yaml to eliminate the transitional commands that esphome tries to do, it might help you?

light:
  - platform: fastcon
    ...
    default_transition_length: 0s
3 Likes

Mind be a long shot :gun: … but as you did a deep (successful) dive :man_surfing: already in that area do you think this ledvance smart+ bluetooth could be integrated into espHome? The topic already contains a link to a project but it requires to salvage a esp32 just for that function (like it was previously the case with this brmesh/fast-con too before your component landed :flying_saucer:) :+1:

I think its doable, I see some ble_mesh_send_* functions that could be pulled and adapted. I’d take a stab at it for you, except I don’t have any of these lights to mess with and make it work

1 Like

Hi Dennis,

So big kudos to you for bringing this to ESPHome. Setup was very easy!

For me the Transition is very very slow does this apply to you as well?
When using the App the BLE commands ar published nearly instantly.
Do you know why that is or how to improve?

Have you tried setting default_transition_length to 0s like I suggested a couple messages above? As I explained there, I have implemented a queue to queue commands up because I was seeing messages getting dropped. ESPHome by default transitions from one state to the next and sends a bunch of transitional commands to do that, which my code is just going to queue up and send.

There’s probably a better way to handle it, but for me I just disabled the transitions. I need to add a note to the readme in the github repo about it.

If you did already try that, the other thing you can mess with are the advertisement settings to adjust how long each command is advertised before moving on to the next message in the queue.

3 Likes

So I changed some variables to make it work. I previously used default_transition_length but it was still slow.

The transition length is super weird i mean if it works it would look cool. But the problem with sending like 100+ commands or even more to dimm the light up and down results in it basically receiving the worng commands. That turns into flickering and wrong end states.

Here is what I used to make it work. It works 100% of the time so far.

deep_sleep:
  run_duration: 0s
  sleep_duration: 0s

fastcon:
  mesh_key: "<key>"
  adv_duration: 15
  adv_gap: 2
  adv_interval_min: 0x06
  adv_interval_max: 0x08
  max_queue_size: 16

Now i have near instant response of if i press the button in HA it will instantly turn on one light. obviously if its more than one at once it will do so in a que.
But i guess thats the limitation of the BLE protocoll on one Esp.

Thanks again Dennis.
Very nice project you created there!

1 Like

Thank you for sharing this information! I’m going to play with it using your settings tonight and see about maybe changing the defaults to match what you have, as well as add some better notes about all this to the README.

1 Like

Here’s my version of the ESP32 code that auto-adds lights and makes them available over MQTT: GitHub - dsclee1/BRmesh-esp32-mqtt

hey, in this version each time esp boots it will try to send the wake signal, right? I don’t see any place where the generated gets stored?

I’ve been trying to set these lights up but not much of a clue with what I’m going to be honest getting too old for these things I think o can get mesh lights to show up using David’s firmware in mqtt but don’t know how to add to home assistant can’t find them anywhere what’s the easiest way anyone can suggest for us old ones lol

So if I get it right, there are currently five possible solutions on how to run your lights which use BRmesh? The listing is sorted from easiest to hardest in my opinion.

  1. Use the BRmesh App → lights can only be controlled by the smartphone
  2. Use Alexa as a gateway: connect all lights to the BRmesh App, then click the “Activate Alexa” function in the BRmesh app and connect the lights to your Alexa (Afterwards the BRmesh app can be deleted as the installation guide I have from my lights state).
  3. Use a BoradLink Gateway GW4C and connect it with your HA HW
  4. Use Dennis ESPHome component: Install /github.com/dennispg/esphome-fastcon on an ESP32 and use the ESPHome integration for HA: ESPHome - Home Assistant to integrate the lights to your HA? Does that work this way?
  5. Use Kyles HA integration from github: /github.com/millskyle/BRMesh_homeassistant which seems to need some debugging, depending on the individual preferences

Did I get that right? Please correct me, If I misunderstood something :wink:

God damnit, I can only put two links in my post which makes my approach to get all information summed up mor or less impossible :frowning:

Here’s code to decrypt the QRCode from BrMesh (C#). My daughter wouldn’t give me her android phone so I needed to decompile BRMesh.

I’ve base64 encoded the key and IV just so they ren’t obvious.

        public string DecryptText(string encryptedString)
        {
            string ret=string.Empty;
            String b64sKey = "YnJnZGJyZ2RicmdkYnJnZA==";
            String b64ivParameter = "MDM5MjAzOTIwMzkyMDMwMA==";
            using ( var myRijndael = new RijndaelManaged())
            {
                myRijndael.Key = Convert.FromBase64String(b64sKey);
                myRijndael.IV = Convert.FromBase64String(b64ivParameter);
                myRijndael.Mode = CipherMode.CBC;
                myRijndael.Padding = PaddingMode.PKCS7;

                Byte[] ourEnc = Convert.FromBase64String(encryptedString);

                ICryptoTransform decryptor = myRijndael.CreateDecryptor(myRijndael.Key, myRijndael.IV);

                using (MemoryStream msDecrypt = new MemoryStream(ourEnc))
                {
                    using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                    {
                        using (StreamReader srDecrypt = new StreamReader(csDecrypt))
                        {

                            // Read the decrypted bytes from the decrypting stream 
                            // and place them in a string.
                            ret = srDecrypt.ReadToEnd();
                        }
                    }
                }

                return ret;
            }
        }

Is this the QR code you get from the “Share Family” option? I’m not seeing where else to get it from… Also I don’t know if it matters, but the app is now called “MagicHome” on android. That might be why

It’s the QRCode from the Sharing Device(s) with other phones in the iPhone app. You get a Base64Encoded String when pass into an online QRCode decoder online. e.g.

Aon3wdCCbtvKU2vN/kkyhTQy6x5QRklx/mZaAta35lWCcshB1ZUXorhixU2DlxuvHtQKsAjCa0tysACs9+DV5WTFoO9fvysouRLr4v9KixGuKQuohVw5JMtJkM6i65+crc+4ZnxHqCzxxxxxxxxPgGttox7LtHVPvbBYYRLKvlwEBoSyjtI53TD6lnxfIvElcOT9hXTZFRarjQHAfoXeCQ==

The above routine decrypts that to:
[{"d":"xxxxxxxx5f1f","v":"4.4.0.3850.53","n":"Light 5f1f","a":1,"t":1},{"d":"xxxxxxxx5a8f","v":"4.4.0.3850.53","n":"Light 5a8f","a":2,"t":1}];4x3x7x0x

where 4x3x7x0x is the mesh key (or I think it is - not quite working but that could be the DFRobot Firebeetle I used for ESPHome and your code).

If you have an android phone you don’t need this and can look in the logs.

I xxxxed out some of the digits as technically someone could take control of my lights.

Yep - it is the mesh key at the end. Working now. the JSON has got the lights with name, version, ID, d and t (don’t know what d and t are). Maximum of 6 per QR Code.

I know it’s only my kids who could take control of my lights - at least one is capable and would find it funny.