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.
Immediately after uploading them, reset the controller. It should pick up the new configuration.
Nope. I'm not sure if resetting the controller (Settings -> Advanced -> Reset Controller) is wiping out appconfig.json, or if it isn't being picked up in the first place, but one way or the other, following the reset, the app config settings are back to defaults.
 
When you use the UI software reset, all settings in memory are force-saved (over-writing your configuration change.) You need to hit the reset button on the controller to do this.

As I said, I'd like to provide a software way to do this, I just have not had time to get to it.
 
Last edited:
Still working on it, but your tax dollars are at work, and I am getting pummelled at work.

In troubleshooting, you cut it in half, cut it in half, and continue. I am about three iterations through that, and I know roughly where the issue is. Finding this is huge and reproducible, all of which means I am much closer to resolution.
 
Okay ... I think I fixed it. I definitely addressed what I was seeing, and it totally didn't have anything to do with @Thorrak adding support for KegScreen TV. ;)

Please give this a try - it IS going to be the release candidate if that bug is fixed.

Keg Cop 1.2.1-Alpha.5
Uhhhh.... git blame... uh.... something something....
 
Please give this a try - it IS going to be the release candidate if that bug is fixed.
I'm not sure what the bug is that's supposed to have been fixed. But after updating to Alpha5, uploading appconfig.json and flowconfig.json, and hard-resetting the device, the new settings took, the theme and brewery name were right, the tap information was there, etc. The Raspberry Pints settings were there, but re-saved them. And it doesn't look like anything happens with MQTT on a pour:
Code:
2023-04-21T21:29:42Z V: Flowmeter Config Save: Configuration saved.
2023-04-21T21:29:51Z V: Processing put to /api/v1/config/settings/.
2023-04-21T21:29:51Z N: Settings Update: [rpintshost]:(192.168.1.165) applied.
2023-04-21T21:29:51Z N: Settings Update: [rpintsport]:(1883) applied.
2023-04-21T21:29:51Z N: Settings Update: [rpintsusername]:(RaspberryPints) applied.
2023-04-21T21:29:51Z N: Settings Update: [rpintspassword]:(password) applied.
2023-04-21T21:29:51Z N: Settings Update: [rpintstopic]:(kegcop) applied.
2023-04-21T21:29:51Z V: Keg Cop Save: Saving configuration.
2023-04-21T21:29:51Z V: Keg Cop Save: Configuration saved.
2023-04-21T21:29:51Z V: MQTT: Initializing connection to broker: 192.168.1.165 on port: 1883
2023-04-21T21:29:51Z V: MQTT: Connecting.
2023-04-21T21:29:55Z V: Sending /api/v1/info/secret/.
2023-04-21T21:29:55Z V: Sending /api/v1/info/tempcontrol/.
2023-04-21T21:29:55Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:29:55Z V: Sending /api/v1/config/theme/.
2023-04-21T21:30:05Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:30:12Z V: Disconnected from MQTT.
2023-04-21T21:30:15Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:30:25Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:30:31Z V: Tap 3 is registering 2075 pulses.
2023-04-21T21:30:31Z V: Debiting 2075 pulses from tap 3 on pin 2023-04-21T21:30:31Z 18.
V: Flowmeter Config Save: Saving configuration.
2023-04-21T21:30:31Z V: Flowmeter Config Save: Configuration saved.
2023-04-21T21:30:31Z V: KegScreen reporting not enabled, skipping (Pour Report).
2023-04-21T21:30:35Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:30:41Z V: KegScreen reporting not enabled, skipping (Temp Report).
2023-04-21T21:30:45Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:30:55Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:31:05Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:31:15Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:31:26Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:31:36Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:31:41Z V: KegScreen reporting not enabled, skipping (Temp Report).
2023-04-21T21:31:47Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:31:58Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:32:09Z V: Sending /api/v1/info/sensors/.
2023-04-21T21:32:21Z V: Sending /api/v1/info/sensors/.
 
I'd also note that, although it certainly isn't a critical issue, there's something weird with the serial log when a pour is registered, in that it spits out that line immediately, even if it's in the middle of printing another log entry--or vice versa, as shown above, it starts printing the next line before it finishes printing the line showing the pour.
 
Last edited:
...and after a couple of hours' uptime, the controller appears to reboot itself, and at that time the appconfig settings are lost--the rPints target, the theme, brewery name, and other settings are lost. uptime.csv doesn't indicate a panic:
Code:
Date/Time, Start Reason, Restart Description, Uptime (Secs)
2023-04-21T21:24:50Z, ESP_RST_POWERON, START_WARMBOOT, 54
2023-04-21T21:28:40Z, ESP_RST_POWERON, START_WARMBOOT, 212
2023-04-21T21:32:39Z, ESP_RST_POWERON, START_WARMBOOT, 229
2023-04-21T23:32:38Z, ESP_RST_SW, START_WARMBOOT, 7190
 
What da hell ….

Okay so it worked, except for mqtt, till it rebooted?

I may have ended up in the hospital this evening and can’t look tonight, but I know I fixed that bug - there may be another. I’ll kill it too.
 
WARNING: Do not click if blood skeeves you out:

IMG_3492.jpg

You know how when you are about to do something, you just KNOW it's not going to go well?

We thought it might be a good idea to have a fire pit, all I had for kindling was some 2-by cut-offs so I was splitting that with a hatchet. Yep, just like they told you not to do in Boy Scouts.
 
Well.....that sucks. Hatchet glanced off and did you in, I'm guessing?
You got it. Bonehead move.

The good thing is I type horribly anyway so that thumb is not slowing down my typing much, except that it huts a little flexing to keep it off the keyboard.

Anyway, I'm poking at the code and I am making good time.
 
You got it. Bonehead move.

The good thing is I type horribly anyway so that thumb is not slowing down my typing much, except that it huts a little flexing to keep it off the keyboard.

Anyway, I'm poking at the code and I am making good time.

Here's a, "the barn door has been open for a few days, now", type of suggestion.....


memtnv1663743323446~2.jpg


I have one. I also had a "hatchet moment". 🫤
 
Here's a, "the barn door has been open for a few days, now", type of suggestion.....
I've seen those, and they look pretty neat. I don't split many/any logs; this was just me getting some kindling out of some scrap 2x6 pine. Would stuff like that fit in there?

Now that we're WAY off-topic, I'll bring it back with an update:

The stability of my current build seems good. I am dressing up the filesystem explorer because it seems to be "a thing" now rather than just a slap-it-in-there stopgap.

I will have another build out today. The two bugs I am tracking are as reported by @danb35:
  1. Lost settings on controlled reboot ("this one should be easy" he said tempting fate)
  2. RPints/MQTT not firing on pour (another easy one)
 
I'd also note that, although it certainly isn't a critical issue, there's something weird with the serial log when a pour is registered, in that it spits out that line immediately, even if it's in the middle of printing another log entry--or vice versa, as shown above, it starts printing the next line before it finishes printing the line showing the pour.
This one annoys me, but there's no fix I can think of. Because the pour triggers an interrupt, it is asynchronous to the rest of the processing. I am fairly certain I'll trigger a crash (or at least miss pours) if I try to slow down the debug printing.

Most of that printing will be gone when we get to a release version.
 
I am releasing 1.2.1-Alpha.6 to get some road time on the new filesystem handler. This is a replacement for the former /edit/ functionality to upload and download files:

BrewFlasher: Keg Cop 1.2.1-Alpha.6

Access the filesystem functions by navigating to /file/ rather than /edit/. The credentials are still admin/p@ssword.

The MQTT/RPints part is still broken, but I found where (comes before "why," unfortunately.) I suspect this part may take a few hours of concentration which I will not get tonight. I'd appreciate any feedback on the new filesystem handler, though.

Also, the two-hour reboot is removed; let's see how it does.
 
Somewhere over the course of the last day or two, the tap/flowmeter config disappeared on my unit. I have a saved copy of flowconfig.json, so easy enough to upload that, but it's (again) going to be missing a few pours. I'll try Alpha 6.
 
I am releasing 1.2.1-Alpha.6
Network connection on Alpha 6 is unusable--it won't even reliably respond to pings (75+% packet loss). Same SSID/password/AP/locations/everything as had been the case previously--literally nothing has changed except moving from Alpha 5 to Alpha 6.

And /edit/, /file/, and /files/ are all 404.

Edit: In case a bad build got out:
1682380373917.png
 
Last edited:
@danb35 I can't reproduce that, and I did try from BrewFlasher. If you have time and can try again, maybe it just got a corrupt flash.

If you don't want to mess with it, I am hammering at MQTT, which should resolve the balance of your current pain points.
 
OK, I re-flashed Alpha 6, a few times. First time, I re-joined it to the same SSID/AP I'd been using with it for Alpha 5 and prior. Same result, network was unusable, 75+% packet loss on pings. Re-flashed and joined to a different SSID, one with a closer AP (but with more than one AP on that SSID). Network was much more reliable. But still getting 404 on /file, /files, and /edit, with and without a trailing slash on all of those.

Then flashed Alpha 6 to another ESP--same result there. Network is plenty responsive, but 404 on /file, /files, and /edit. I'll try entering the config manually and see if it sticks around.
 
First time, I re-joined it to the same SSID/AP I'd been using with it for Alpha 5 and prior. Same result, network was unusable, 75+% packet loss on pings. Re-flashed and joined to a different SSID, one with a closer AP (but with more than one AP on that SSID). Network was much more reliable.
This is frustrating. I wish I could fix this part, but it is part of closed-source code from the manufacturer. I can go back to older libs, but there are issues with that too. When we get to a release candidate, I'll compile with both versions (if I can) and we can see if there's a significant advantage to one or the other. There's a rumor that it's fixed in an upcoming version.

But still getting 404 on /file, /files, and /edit, with and without a trailing slash on all of those.
The path is /fs/
 
The path is /fs/
Got it, that works. And yes, it definitely looks more polished than the former /edit/ page.
I think you are using HAST, right?
Since I don't recognize the acronym, I'm going to say no. But it sounds like it has something to do with Home Assistant--and while I do use HA, I'm not as yet trying to integrate KegCop with it.
 
How are you testing it?
Lately by monitoring the serial console--with versions through Alpha 5, there's been no mention of any MQTT activity connected with a pour. Haven't watched it yet under Alpha 6. But the target is pointing to a RaspberryPints installation on Debian 11.
 
Lately by monitoring the serial console--with versions through Alpha 5, there's been no mention of any MQTT activity connected with a pour. Haven't watched it yet under Alpha 6. But the target is pointing to a RaspberryPints installation on Debian 11.
It's tough to tell exactly what someone means in short messages here - I feel pretty strongly this would all work better if we were standing around drinking a beer. I'm going to go back to the basics though - even if you already know this, it may help someone else.

First, when you configure an MQTT (RPints only right now) host, Keg Cop will try to do a connection - you have probably seen this. It generally stays connected, but most MQTT systems will disconnect on occasion. When it does, it should try to reconnect. You can see this in the logs.

So this is step 1: It must make a connection. To do that, a broker should be on the other end of the connection. If there is not, Keg Cop will not even try to send MQTT.

Then step 2, whenever a pour is registered and Keg Cop is connected to an MQTT broker, it will send an RPints formatted pour message. You can see that in my screenshot above.

My best, uneducated guess, is that you've not gotten past step 1. I don't know how you have set up your target system, but this is how I set mine up to test:
  1. Install mosqitto mqtt broker and pub/sub client: sudo apt install mosquitto mosquitto-clients
  2. Check status: sudo systemctl status mosquitto (it should show "running")
  3. Add a listener
    1. Edit the configuration file: sudo nano /etc/mosquitto/mosquitto.conf
    2. Add two lines to the end of the file:
      1. listener 1883
      2. allow_anonymous true
    3. Restart mqtt: sudo systemctl restart mosquitto
    4. Validate your change to make sure it is running sudo systemctl status mosquilto
  4. Test the installation:
    1. Subscribe to all: mosquitto_sub -h localhost -t "#" &
    2. Send a test: mosquitto_pub -h localhost -t "mqtt/test" -m "Hello world"
  5. Optionally, install mosquitto-clients on another system and send a test pub: mosquitto_pub -h {hostname.local} -t "mqtt/test" -m "Hello world"
Once you have this, you can reproduce my test above. One thing to be aware of is mosquitto does not, by default, set up a listener for external connections. Step 3.2 handles that change.
 
Last edited:
Back
Top