BLE to MQTT bridge for the Ember mug, designed to be used with Home Assistant
Uses the python-ember-mug library for the BLE communication, and asyncio-mqtt for MQTT communication.
Provides autoconfiguration messages for Home Assistant.
Allows control over the mug temperature and the LED color. Allows turning the heater off, though turning it back on can be flaky if the mug doesn't believe it has anything in it.
Simply run the executable, like:
./ember-mqtt-bridge.py --config-file=./ember-mqtt-bridge-config.yml
If you like, you can override some parameters on the command line:
./ember-mqtt-bridge.py --config-file=./ember-mqtt-bridge.config.yml --mqtt-password:$password
To pair a mug, put it in pairing mode. The bridge will present a pairing button. Find that in your Home Assistant interface, and press it. The mug will be picked up in the next iteration (or two). The bridge reads known devices from the MQTT saved messages and will try to pair with known devices automatically. This doesn't always work. If you're running the bridge on a new device (or new Bluetooth adapter) and it doesn't seem to be connecting to the mug, put the mug in pairing mode. In my case, it gave confusing errors about device interference when all I needed was to re-pair!
Delete the device in the MQTT integration in Home Assistant, then unpair the device from the device hosting this bridge.
My Raspberry Pi Zero W's Bluetooth doesn't seem to get a good signal from the mug, even while sitting on the same desk. This bridge was mostly written from my laptop. If you want to use the Pi, try a USB-attached Bluetooth dongle!
This bridge intends to support running multiple instances in the same network. It will use MQTT to detect devices which are announced, and attempt to keep track of them. This is not deeply tested, but is a design goal, and might work.