BLE Sig Mesh Gateway

Hello,

I have a BLE Sig Mesh Light that I can control via Smart Life with my Phone.
I’m looking for a DIY BLE Gateway for this kind of device. I would prefer via a PI 4 or an ESP32 if possible.

I saw this kind of device but I would like a Gateway 2 MQTT or via ESPHOME.
It seems all current BLE GW are for sensors/beacons, not for lights.

Thanks for the help.

You might explore the localtuya integration to see if it is possible to control your Moes device. I have looked around github and not found much current work on any BLE mesh projects. I think folks are waiting for the whole Matter thing to solidify. Espressif ESP32-H2 is a new chip that is coming soon that may spur development with both BLE and Zigbee (dot or whatever it is named now) mesh to wifi. BLE mesh is more complex to implement that the current projects that simply listen for BLE advertising packets, this is what most of the BLE integrations do currently.

Good hunting!

1 Like

I know for a fact the ESP32-C3 and S3 support BLE-MESH and for the pi4 it’s just a matter of software.
Speaking of, this is all I could really find, BLE-MESH and Mesh2MQTT so it looks like just the one guy is working on this, at least until Thread Matter is sorted out.

I have just been looking https://github.com/lucamoroz/Bluetooth-Mesh-Sensor-Network the rest apart from previously posted seems to be firmware based.

I just ordered x2 Bluetooth Smart Switch Wireless Remote Control with Bluetooth Gateway – MOES as both Moes and bluetooth mesh sig is new to me and was curious hwo compatible it is as a bluetooth mesh rather than a lesser common radio such as Zigbee seems it could be a great product platform.

I haven’t a clue to tell you the truth :slight_smile:

I just wanted to share, that it is in fact possible to control Bluetooth Mesh lights via MQTT and Home Assistant. I use a python library on top of the Bluez bluetooth-mesh service to retrieve device information, turn devices on/off, set the brightness and light color.

My current state is available here GitHub - dominikberse/homeassistant-bluetooth-mesh: Allows to use bluetooth mesh devices directly from homeassistant, but it is still very much under development and might be a little tricky to configure and set up.

2 Likes

can you help to configure meshctl ? I have installed the binary and the python requirements, but don’t know what to do with meshctl.
thx

I think meshctl is ok now, I try to run the gateway, but I …/store.yaml is missing, is there any data to put in that file ?

[email protected]:~/homeassistant-bluetooth-mesh/gateway# python3 gateway.py scan

Traceback (most recent call last):
  File "/root/homeassistant-bluetooth-mesh/gateway/gateway.py", line 259, in <module>
    main()
  File "/root/homeassistant-bluetooth-mesh/gateway/gateway.py", line 240, in main
    app = MqttGateway(loop)
  File "/root/homeassistant-bluetooth-mesh/gateway/gateway.py", line 69, in __init__
    self._store = Store(location='../store.yaml')
  File "/root/homeassistant-bluetooth-mesh/gateway/tools/store.py", line 23, in __init__
    raise Exception('Store data not available')
Exception: Store data not available

Ah right, I think you can simply create that file with the following content

local:
  address: 1

The rest of the file should be created automatically, it just does not handle the case where the file does not exist or is empty properly by now. Testing the initial setup process is a little annoying, that’s why I have not had time to do that yet. The file stores information about the provisioned devices.

I also noticed that it crashed on the very first startup (after I created that file). I just had to re-run the application.

By the way, please double check that you know how to reset a provisioned device. If something goes wrong, you might end up with a provisioned device that cannot be accessed over a network. For my light bulbs, this is simply turning them on and off with 3 seconds delay for 5 times (costed me a lot of 30 seconds so far :smiley:).

Sorry for the headache, this is my bleeding edge development state :smiley: I just wanted to share it, so that people can play around with it and maybe even improve it.

I make some progress, but still need some help :

The script does nothing, just stale on Connecting to org.bluez.mesh

[email protected]:~/homeassistant-bluetooth-mesh/gateway $ sudo python3 gateway.py scan

DEBUG:asyncio:Using selector: EpollSelector
DEBUG:MqttGateway:Connecting to D-Bus
INFO:MqttGateway:Connecting to org.bluez.mesh

Trying with meshclt
I found my device, by I’m block at this step :

Request hexadecimal key (hex 16 octets)
[[mesh-agent]# ] Enter key (hex number): 0000
Incorrect input: expecting 16 hex octets
		OOB: 0000

any idea ?

I’m not quite sure on how to work with meshctl directly. The script uses the bluetooth-mesh service, which should come with Bluez with meshctl and the message indicates that it is not running. Depending on your setup you can either run it from command line or using systemctl. I would recommend command line with debug info first:

sudo ./bluetooth-meshd --nodetach --debug --dbus-debug

If you build Bluez yourself it should be inside the build folder under ./mesh/, otherwise it might be under /usr/lib/bluetooth/.

As the service wants exclusive access to the hci device, you might run into a message that indicates that the hci device is not available. In that case you will need to release the device using:

sudo hciconfig hci0 down

From what I understand, as long as the default bluetooth service is running, it will try to regain access to the bluetooth controller after a while. However I read in some places, that stopping the bluetooth service gracefully might power down the bluetooth controller making it inaccessible. Maybe it’s best to disable both the bluetooth and the bluetooth-mesh service while setting everything up and once the setup works, enable the bluetooth-mesh service.

It seems it quite better now.

Scan is working, I found my uuid.
But I can’t prov it :

INFO:root:Provisioning node a8017*****...


INFO:root:Provisioning 1 new address(es)

ERROR:root:Failed to provision a8017*****:
bad-pdu

Mesh contains 0 node(s):
INFO:MqttGateway:Unregistering application
[email protected]:~/homeassistant-bluetooth-mesh/gateway $ cat ../config.yaml
mqtt:
  broker: 192.168.1.10
  node_id: mqtt_mesh
mesh:
  a8017*****:
    uuid: a8017*****
    name: name
    type: light             # thats it for now
    relay: false

What is this error BAD PDU