Hook up your Bluetooth LE iBBQ thermometer to MQTT with Python.
It's probably best and easiest if you install these in a venv.
master
version from Git, it includes some fixes for the helper. You need to have libglib2.0-dev
installed, and then it's as easy as:python3 -m pip install git+https://github.com/IanHarvey/bluepy.git
python3 -m pip install paho-mqtt
Your iBBQ device should be detected automatically. If more than one device is detected it will pick the one with the best signal strength.
No need to tell it the MAC address of your device. (If you have to though, look where hwid
is declared - instead of having it use find_bbq_hwaddr()
just give it a string with a colon seperated MAC address.)
mqtt_server_ip
.temperature_units
at the top of the file. This will change the on-unit display and the data which is sent to MQTT.handleNotification
function in the DataDelegate
class.The script will end. If you want to automatically start logging data again when you turn it back on, check out the included systemd service file. It's much easier to just restart the script than deal with reconnecting and reinitalising. The service file will restart bbq.py every 30 seconds. That's probably fine. You might need to change the user part of the service file.
If you're seeing error messages about bluepy.btle.BTLEManagementError: Failed to execute management command 'le on' (code: 20, error: Permission Denied)
then you need to run the script as root. If you don't want to do that read this: https://github.com/IanHarvey/bluepy/issues/313
You need to do:
sudo setcap 'cap_net_raw,cap_net_admin+eip' bluepy-helper
where bluepy-helper
is the file which is built when you install bluepy from Git.
Not much. According to top
it uses about 1% CPU (usually less) and about 3% RAM. A similar Node application would use more like 10% RAM - still not much, but pybq is less. Or is it fewer?
You should take a look at Telegraf. It makes it really easy to take an MQTT topic and send it to InfluxDB Cloud. Then you get those sweet charts you're looking for. Here's a Telegraf config snippet:
[[inputs.mqtt_consumer]]
servers = ["tcp://192.168.42.100:1883"]
topics = [
"bbq/battery",
"bbq/+/#"
]
data_format = "value"
data_type = "integer"
Have a look at this page: https://www.linode.com/docs/quick-answers/linux/start-service-at-boot/
I've got a couple of ideas for the future, but any pull requests are welcome.