In my home kegerator I have a nifty device called Kegtron that monitors the flow rate of two kegs and reports out data using Bluetooth LE Advertisement beacons. The team at Kegtron has recently documented there full BLE messaging format here:
I would really like to get this data into Home Assistant, and it seems like all the base ingredients to build a simple integration are there, but my (already limited) coding skills have greatly atrophied over the years and I’ve not attempted to write a HA integration before, so I’m hoping some kind soul will take pity on me and offer some help or advice on my quest.
On my RPi4/HassOS based installation, I can see the Kegtron BLE Advertisement data broadcasts when running bluetoothctl from the command line and enabling scanning.
Looking at the code for the Bluetooth LE Tracker, it appears scan for similar BLE messages, and I don’t need to connect to the device or interrogate UUID properties as all the data is presented in the passive scans. However, the existing BLE Tracker integration isn’t a perfect template, as it doesn’t appear to consume the advertising packets from the devices so I’ll need to figure that out. A quick look the pygatt library implies scanning is only used to find devices, not to listen for advertising broadcasts, but I could be missing something there.
If anyone has any advice, or wants to come along for the ride please let me know. Thanks!
I just ordered the Kegtron v1 and one of my goals is to get it into HA. I am thinking that this might be doable with one of the BLEtoMQTT options out there. Will need to get it and give it a try. Let me know if you make any progress.
Yep, I have added support for Kegtron recently to Passive BLE Monitor. One remark, you will have to enable active_scan to get the data from your Kegtron device.
That was a great card you made for your keg. Do you mind sharing how you created it?
I can find port name, keg type, keg size and dispensed litres, but how did you find out drinks served, and drinks remaining? I assumes you calculate the percentage keg remain, or do you read this in some smart way from the Kegtron?
Yes, you have to calculate it from the starting volume and the volume dispensed. I made a couple of template sensors in configuration.yaml to track this:
I also made template sensors to make it a bit easier to display the other attributes of the sensor.
Note that I’m simply assuming a served drink is always a US Pint (0.473 liters) as that works for my use case. A more robust solution may be to use a input_select entity to allow you to choose what serving size you want to track.
Other cool things to do with this integration: I send an alert when either tap drops below 10% remaining, and when its been more than 2 months since the lines were cleaned (this is also tracked manually). I’m also going to add a “Days on tap” sensor that auto-resets when the volume dispensed sensor reverts to zero.
What I really, really want to do is integrate this with the untappd APIs to display an utappd beer card for the tapped kegs. Getting the data from untappd is pretty easy using the REST integration (and you could store the untappd beerid in the kegtron “beer name” field using the kegtron app), but I don’t have the lovelace custom-card skills to recreate this info card in lovelace:
Those values aren’t saved to the device or broadcast by the BLE signal from the Kegtron, they are just locally stored by the Kegtron app. I just made equivalent ones in Home Assistant. The only thing I use the kegtron app for now is to reset the volume and keg size when I get a new keg, everything else is in home assistant.
I wish Untappd didn’t kill their API, I would have loved to pull beer information from Untappd for the kegerator as well.
Btw, a little late to mention here, but we have moved the Kegtron support to an official HA integration, using the build in Bluetooth integration. BLE monitor also still functional as before.
I’m getting a very weird thing, a random Bluetooth hexagon light panel (Chinese) device is showing up as a Kegtron device, what is the thing that determines what integration to match to a device ?