Keg Cop: Keg Monitoring and Control

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
I’ll take a look tomorrow when I’m at my desk. It’s possible, but I’ve never done it.
Amazing thanks, I use fusion 360 which gives you an option under export -> STEP. This gives the used the actual most rather than the mesh which makes it easier to modify and play with.
I’m just trying to modify the design for the sensor box you created to fit the flow sensor 3x board, I am thinking it might be easier to modify the PCB to fit in the same space actually now but is good to have options!

Thanks for your help :)
 
My version of AutoCAD does not export to STEP. (I would need AutoCAD Mechanical)

I can export to .IGS or .IGES. Does either of those help you?

If so, can you also give me the name of the .STL file you are interested in so that I can make sure I get the correct file.
 
Here is an update for some of you waiting for MQTT/Home Assistant:

1687525612098.png


I need to put it through its paces a bit, but it's close to a beta.
 
Release Candidate: 1.3.0-RC1

https://web.brewflasher.com/fw/135

Release notes:

The major changes since 1.2.0 are:
  • Fixed async instability with updated core libs (finally!)
  • Added Home Assistance support (thank you @mper!)
  • Added a new filesystem editor
  • Move to LittleFS for additional file stability
  • Allow configuration for traditional debug items
    • Turn telnet on and off
    • Turn logging levels up and down
  • Attempt to reconnect WiFi if it drops
  • And, of course, bugfixes.

What's Changed​

There are changes since the 1.2.0 release:

Feature Changes:​

Bug Fixes:​

Full Changelog: 1.2.0...1.3.0-RC1

This is not yet available as an online upgrade. You must use BrewFlasher to load this code. Be sure to back up your configuration first so you can restore it after.

I did say I was going to get the keg entry by weight done first - that ended up being some significant Java Scripting so I want to look at moving to Vue first (which will be 1.4.0+).
 
Last edited:
Feature Release: 1.3.0

1689791897527.png


https://web.brewflasher.com/fw/135

Release notes:

The major changes since 1.2.0 are:
  • Fixed async instability with updated core libs (finally!)
  • Added Home Assistance support (thank you @mper!)
  • Added a new filesystem editor
  • Move to LittleFS for additional file stability
  • Allow configuration for traditional debug items
    • Turn telnet on and off
    • Turn logging levels up and down
  • Attempt to reconnect WiFi if it drops
  • And, of course, bugfixes.

What's Changed​

There are changes since the 1.2.0 release:

Feature Changes:​

Bug Fixes:​

Full Changelog: 1.2.0...1.3.0

Updating:
  • You may do an online upgrade from version 1.1+ (it will not appear if you are on < 1.1). If you do an online upgrade all settings will be retained.
  • If you are on < 1.1, you must use BrewFlasher to load this code. Be sure to back up your configuration and restore it afterward if you use BrewFlasher.
I did say I was going to get the keg entry by weight done first - that ended up being some significant Java Scripting, so I want to look at moving to Vue first (which will be 1.4.0+).
 
Last edited:
I have a lot to learn about Home Assistant, but even so I have this set up with a few minutes' effort:
1690214666478.png


I'm wondering one thing, though: the entities for the volume remaining appear to be tied to the name of the beer--when I replace the Pale Ale with something else, I'm thinking that means its card won't work any more. Or will it?
 
I'm wondering one thing, though: the entities for the volume remaining appear to be tied to the name of the beer--when I replace the Pale Ale with something else, I'm thinking that means its card won't work any more. Or will it?
This is where my Home Assistant knowledge ends. I am not sure, honestly. I know the controller captures all of the taps, but the taps are concatenated from the tap ID + the name. If a new one is created, it should send a new tap entity.

That looks good though! Mine were .... not so pretty.
 
the taps are concatenated from the tap ID + the name.
Might it be possible to call it something else more generic? I mean, it wouldn't be the worst thing ever to have to update the card with the new entity whenever I changed a keg, but it'd be nicer yet to be able to keep the config unchanged. Though I'd then need to pick up the name somewhere else...
 
There is only one "name" field for HASS auto-discovery. However, the sensor has a tap number so maybe if you set up the card at the sensor level - this is unfortunately beyond my understanding of Home assistant.

The template I use to create the device (the controller) is:

C++:
PGM_P HASS::deviceTemplate PROGMEM =
    "'device': {"
    "'configuration_url':'http://${hostname}.local/settings/',"
    "'identifiers': '${GUID}',"
    "'model': 'Keg Cop',"
    "'name': '${devicename}',"
    "'manufacturer': 'Lee Bussy',"
    "'sw_version': '${ver}'"
    "}";

And each sensor (tap) is:

C++:
PGM_P HASS::tapInfoDiscovTemplate PROGMEM = // Tap Auto-Discovery Payload (per tap)
    "homeassistant/sensor/${hostname}_tap${tapnum}/volume/config:"
    "{"
    "'icon':'mdi:beer',"
    "'name': '${taplabelnum}. ${taplabel}',"
    "'device_class': 'volume',"
    "'unit_of_measurement': '${UOM}',"
    "'state_topic': 'kegcop/${hostname}_tap${tapnum}/volume/state',"
    "'json_attributes_topic': 'kegcop/${hostname}_tap${tapnum}/volume/attr',"
    "'availability_topic': 'kegcop/${hostname}_tap${tapnum}/tap/availability',"
    "'payload_available': '${availability-on}',"
    "'payload_not_available': '${availability-off}',"
    "'unique_id': '${hostname}_tap${tapnum}',"
    "${device}"
    "}|";
 
In case someone else would like to get started with seeing the KegCop information in Home assistant, here are some notes on the process:
  • Naturally, start with Home Assistant installed. I'm not sure if it will matter, but I'm using the "Home Assistant OS" installation method. I'm doing it in a virtual machine (creation of the virtual machine under Proxmox takes only a one-line command), but the same would work on bare hardware, like a Raspberry Pi or a small PC. Install it and configure to your taste; other tutorials will cover this process if you need help. Make sure you configure it to have a static IP address.
  • Log into the Home Assistant web interface and install the Mosquitto add-on. Go to Settings -> Add-ons -> Add-on store, and click on the Mosquitto broker. Click Install. Once it installs, turn on Start on boot and Watchdog, and then click Start.
  • Next, configure the integration. Go to Settings -> Devices & Services, then click the Configure button for MQTT. A window will pop up asking, "Do you want to configure Home Assistant to connect to the MQTT broker provided by the add-on Mosquitto broker?" Click Submit. At the next pop-up window, click Finish.
  • You'll then need to set up a user for KegCop. Go to Settings -> People, and click on Add Person. Enter a descriptive name like "KegCop User", and turn on "Allow person to login." In the next form, enter a username and password. You'll probably also want to turn on "Can only log in from the local network," particularly if your Home Assistant installation is available remotely. Click Create.
  • You've now configured Home Assistant to receive MQTT data. Now you'll need to configure KegCop to send it. In KegCop, go to Settings, then to Targets -> Home Assistant. The Broker Address will be the IP address of your Home Assistant installation, Port will remain at its default of 1883, and the username and password will be the ones you configured above. Leave Autodiscovery Topic at its default of "homeassistant." Click Update.
At this point, you've set up KegCop to send its data to Home Assistant. I found it took a while (around 24 hours) before all the taps updated. But if you've kept the default dashboard in place on Home Assistant, you'll see the data populate there; it will look like this:
1690366289438.png


Let's make a dashboard to show the relevant data a bit more clearly.
  • Back in the Home Assistant web interface, go to Settings -> Dashboards, and then click Add Dashboard. Call it whatever you like ("kegcop" in this example) and choose any icon you like (mdi:keg is a good choice). Then click Create.
  • Next to your newly-created dashboard in the list, click Open.
  • The new dashboard will default to showing all your data, which you don't want. Click on the three dots in the upper-right corner, and then Edit dashboard.
    1690366760021.png

    Turn on "Start with an empty dashboard" and click Take control
    1690366812780.png
  • You now have a blank dashboard. Let's add a keg/tap readout to it. Click on Add Card in the lower-right corner. In the window that pops up, select Gauge.
  • You'll now need to configure the gauge. First, under Entity, choose your first tap. Its name will be "1. " followed by the name of the beer. You'll likely want to set "Maximum" to the capacity of that keg, in whatever units you've told KegCop to use--I've set mine to 5, for 5-gallon corny kegs. The other settings are up to you, but here's how I've configured them. Notice that the needle isn't in the right place while you're editing the gauge; that's normal:
    1690367172812.png

    When you're happy with how it looks, click Save. Repeat with your other taps as desired.
  • I'd also like to have a card up there to show the keg temperature. Click Add card and choose Entity as the card type. Choose "Keg Temp" as the entity. Then click Save.
  • You're done editing the dashboard for now, so click Done in the upper-right corner. You'll be left with something like this:
    1690367696193.png
From here, you're pretty much on your own. As I've said above, I have a lot to learn about Home Assistant, so if there are better ways to do this, feel free to let me know.
 
That's great, Dan. Now I've got more I can play with.

By the way - unless there are network issues, all of the data should update within about 3-4 minutes. Sometimes I had to refresh the HASS page to see them. I am 92% sure adding a HASS target triggers a full send - I'll check on that.
 
unless there are network issues, all of the data should update within about 3-4 minutes.
I figured as much, but for some reason, only the first tap was showing for quite a while (i.e., overnight). In fact, I was just starting to post about that when I did another pour from the third tap (I'd already done two pours since I configured the HA target), and then they all showed up. I won't rule out the possibility of network issues, but the KegCop device has a clear, unobstructed line of sight to the AP, about 30' away--it should be good. And since then, pours register on the dashboard in a matter of seconds.
 
I can have a look - thinking about it I realized I always reset the controller to force things, so it might be that adding HASS forces it to go out of order and the HASS side waits to display till it gets the magic bit.
 
Where do you buy the hardware - flow controls - that go with KegCop? Seems like a handy tool. Thanks
 
A little bit more refinement to the dashboard, now it looks like this:
1690538465508.png

The trick is to use the "horizontal stack" card, which lets you put two (or more) cards side by side. To do this, when you're editing the dashboard,

  • Click Add Card in the lower-right corner, and find Horizontal Stack. Click on that.
  • A new window will pop up, titled Horizontal Stack Card Configuration, which will let you select the first card in the stack. For the effect shown above, find and select the Markdown card.
  • In the Markdown card, you can enter a title (the tap number and beer name, as shown above), and content. The contents can be any text you like, and you can style it using Markdown syntax--this is where I entered the beer descriptions. It will look like this:
    1690539293517.png

    When you've finished, click the + to the upper-right to add the gauge. Configure it as described above, or otherwise as desired.
  • Repeat for any other taps.
 
That looks great! If you’re feeling froggy and want to contribute to the docs, please do. I’m sure someone else would benefit.
 
That looks great! If you’re feeling froggy and want to contribute to the docs, please do. I’m sure someone else would benefit.
I can give it a try. Would that be a PR against the GitHub repo? If so, looks like I'd go into the docs/ directory and make a new subdirectory for homeassistant?
 
I can give it a try. Would that be a PR against the GitHub repo? If so, looks like I'd go into the docs/ directory and make a new subdirectory for homeassistant?
That is how it gets there. The "work" is writing the doc in Markdown. It's built upon MyST, which renders (and extends) Markdown to compile documentation. If you wanted just to do it in Markdown, I could walk you through the mechanics of the PR. You can look in the /docs folder now to see the current documentation to get an idea or hit it from the other side and just use the MyST and MD docs.
 
I'm reasonably familiar with Markdown, so that shouldn't be too difficult. And I think I already did a PR against your repo, to add the 6-way breakout board. But if I'd need to do anything special for the docs, I'd need some guidance there.
 
It looks like it might be beneficial to set the Retain flag on the MQTT messages--a restart of Home Assistant loses all the tap values. "Updating" the HASS configuration restores three out of the four (curiously, it's 1, 2, and 4); I'm sure the fourth will come back in due course.
 
a lot about HASS seems like magic.
I'm not sure if that's a good thing or a bad thing--perhaps some of both. It would surely be worth monitoring what's going on via a Telnet console, though, which I haven't as yet done, to at least see if Keg Cop's even trying to send these things (and what it's trying to send).

Has uptime.csv gone away? I was trying to load it to see if I was getting recurrent panics, but it doesn't seem to load--though it looks like I am; right now the system's reporting 49 seconds of uptime with the last restart due to "ESP_RST_PANIC, Description: Software reset due to exception/panic".
 
I am not sure how you are getting crashes …. But hey, config stays, right?

I think that is turned off in release mode, I’ll have to look.
 
I haven't done a whole lot of testing, but I don't think this is it. I don't keep the kegcop.local page open in general. The instance yesterday where I noticed the problem was after I tried to open that page, and first got "host not found," then a timeout, and then finally the page loaded. At that point, the "About" page listed the 49-second uptime with the last restart due to a panic. The network connection seems to be extremely flaky, but I'm not sure if that's related:
Code:
╰─ ping kegcop.local                                                                                           ─╯
PING kegcop.local (192.168.1.200): 56 data bytes
Request timeout for icmp_seq 0
64 bytes from 192.168.1.200: icmp_seq=1 ttl=255 time=834.963 ms
64 bytes from 192.168.1.200: icmp_seq=2 ttl=255 time=551.626 ms
Request timeout for icmp_seq 3
64 bytes from 192.168.1.200: icmp_seq=3 ttl=255 time=1078.200 ms
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
64 bytes from 192.168.1.200: icmp_seq=6 ttl=255 time=1126.470 ms
64 bytes from 192.168.1.200: icmp_seq=7 ttl=255 time=141.855 ms
Request timeout for icmp_seq 9
Request timeout for icmp_seq 10
Request timeout for icmp_seq 11
Request timeout for icmp_seq 12
Request timeout for icmp_seq 13
Request timeout for icmp_seq 14
Request timeout for icmp_seq 15
Request timeout for icmp_seq 16
64 bytes from 192.168.1.200: icmp_seq=16 ttl=255 time=1106.158 ms
Request timeout for icmp_seq 18
Request timeout for icmp_seq 19
Request timeout for icmp_seq 20
Request timeout for icmp_seq 21
64 bytes from 192.168.1.200: icmp_seq=22 ttl=255 time=851.104 ms
Request timeout for icmp_seq 23
As of right now, though, it's reporting a 17-hour uptime.
 
The network connection seems to be extremely flaky, but I'm not sure if that's related:
These boards have notoriously meager antennae. If the board loses connection to the access point, it will reset itself too.

But, AsyncTCP is a pig, and it's not very stable. Once I get the UI to Vue, I can move back to the regular TCP and avoid all the problems with Async. At least right now, the workflow is stable and you should not get resets unless the web server comes into play. When you got "page not found" I am guessing that Async crashed trying to render the initial page.
 
I've now had occasion to put a different beer on tap. Somewhat to my surprise, the sensor on the HA dashboard updated itself automatically, so I didn't have to change the gauge card to use a different sensor. I naturally had to change the name, description, and stats of the beer in the markdown card.
 
Back
Top