Anybody found a solution not involving buying a expensive gateway?
I’m also curious whether there has been any positive progress with this. TW Downlights with Zigbee integration, decent dimmability and Ra are hard to come by. SG has all tick boxes except for this gateway…
If this is using the Avi-on infra based on CSRMesh, then check out
- GitHub - oyvindkinsey/esphome-avionmesh
- GitHub - oyvindkinsey/avionmesh: Library for interacting with lights based on Avion mesh techology.
- GitHub - oyvindkinsey/avionmesh-cpp
- GitHub - oyvindkinsey/recsrmesh: CSRMesh protocol library
- GitHub - oyvindkinsey/recsrmesh-cpp
If it’s not Avi-on, but still uses CSRMesh, then look at the recsrmesh libraries for how to communicate with the mesh. Happy to discuss how to create wrappers similar to avionmesh if necessary.
Note that esphome-avionmesh is a fully cloud-free alternative - it allows managing the mesh fully without the use of any proprietary apps/cloud infra.
Indeed, this is using the same CSRMesh protocol - if anyone has devices and know their way around some python, I’d be happy to offer some guidance on how to figure out what’s required. The GitHub - oyvindkinsey/avionmesh: Library for interacting with lights based on Avion mesh techology. module even provides a simple cli for managing the mesh - shouldn’t be hard to rework this into supporting the SG devices as well, which makes this process quite easy.
Hi Øyvind, I have a number of SG Bluetooth dimmer. I have also pip install recsrmesh. But then I do not know what to do. How do I get this into HA and how to use this. Is it necessary with a bridge with the dimmers connected to proceed since I have to provide a bridge_mac and passphrase? My hope was to do this without an additionl bridge.
There has to be a bridge of some sorts that communicate using ble/csrmesh, and if the python CLI lets you communicate with your mesh, then it’s easy enough to build the wrapper to integrate with ha. A cpp esphome as a bridge is much better for stability/speed, and is pretty much just a $5 investment.
Start by running the cli to see if it works for you, if it can find a device to connect to - you shouldn’t need to provide a bridge_mac, but would need a passphrase of some sort. I’ll see what I can find out
The problem will be to get the passphrase.
The specific logic for this is not easily available for this app and you will need some proficiency with e.g Frida to extract the specific logic (the specific passphrase, or more ideally reverse engineer the cloud api call used to get it based on your username/password). As I don’t have such lights/such an account, I probably can’t help much here (I can provide info on Frida though).
There is no bridge. I have an app on my mobile which provided by SG. I have to register an account to be able to use the app and add devices. I can use BleakScanner to find the device and BleakClient to check if I can connect and pair. An then I can find the services, etc. Now I need to find out how to send a command to the device. I do not think I need passphrase to directly write to the device. If I would go through an extra bridge I would probably need an access code/passphrase. I think I have to somehow reverse engineer the command to be sent to the dimmer device.
The device the phone connects acts as the bridge, and while you don’t need a passphrase to connect to it, you need a passphrase to encrypt the messages you send through it.
Without the passphrase, which the app gets from your account, there’s nothing you can do. I’ll see when I have time to look into what web api’s the app rely on for this - with that identifier, it should be trivial to get the passphrase and you can use the library above to control the system.
Since I don’t have these myself, it’s not certain that I can even get the app to reveal where this is stored, so no promises. If possible, it would be ideal if someone who had an active account with lights registered did this.
Hi, ive recently moved into a house with a bunch of SG led dimmers i want to connect to my home assistant, so this thread is very relevant for me. I have an active account and the SG app working, so i'll start digging into this today
Might take a bit to get up to speed with the bluetooth mesh stuff. hopefully i can find a bluetooth adapter that can communicate with the devices as a first step.
Might also take a stab at debugging/reverse engineering the app to get a passphrase or understand the API it uses a bit better
The best approach is via a rooted phone and Frida - I have this all set up, but can't access it for a few weeks. If you can create a dummy account used with a device, then I can map out the http API that will reveal the passphrase. But if you're comfortable with Frida, go for it - I'm pretty sure the BT stuff is generally mapped out and supported via the recsrmesh library.
Thanks for the pointer to Frida, that was very helpfull. I played around with it and got a patched version of the app to run with Frida gadget (didnt have a phone to root). I think perhaps that was overkill, since i also found and dumped the apps main sqlite db, which might be all i need. It contains a networkPassphrase, sigMeshNetKey and sigMeshAppKey, as well as the access code for the sector. I dont have a bluetooth dongle to test with yet, but i was thinking trying to get a small app running with the reccsrmesh library next
Try Comparing main...tui · oyvindkinsey/recsrmesh · GitHub - if this works, then porting the same logic to the cpp library is trivial, and you'll be able to use the superior esp32 implementation.
Claude is likely to figure this out for you.
Has anyone tried the SG Smart Gateway 3.0 with Matter support? Guess it is now possible to integrate SG smart devices into Home Assistant using the Matter integration.
Hy again. It’s been a while, but I am still working on this project. In fact i have been slowly reverse engineering the mesh protocol. It wasn’t so straight forward that i could just plug in oyvinds cli or libraries idrectly, but they were immensely helpful! I also helped that i bought a bluetooth dongle to test all this from my PC and not an esp32. TBF, my coding agent is figuring out the details, but i now have a basic CLI that can connect to a device, turn it off and on, and control dimming.
So now i’m starting to play with some ESP32 waveshare boards and esphome builder in HA again.