Urgent.News

What's breaking now, across thousands of outlets.

Tech

The coffee log, rebuilt in .NET

The coffee log, rebuilt in .NET Back in June I wrote about my coffee machine writing my blog . Smart plug watches the coffee machine, Raspberry Pi watches the plug, bit of Python tells Umbraco I've made a coffee. If you've not read that one, go and read it first, it covers the plug, the KLAP handshake, the controller on the site, all of it. None of that has changed. So why am I writing about it…

The coffee log, rebuilt in .NET is a story of how the author replaced the Python script controlling their coffee machine with a .NET application. Initially, the Python script was written for a Raspberry Pi Zero and relied on pure Python, with careful consideration of library versions and installations. However, as the author upgraded to a 64-bit Raspberry Pi model, they realized that a self-contained .NET application could be published as a single binary, eliminating the need for external runtimes and package managers. This change made the project more manageable and easier to maintain.

The author found that maintaining the Python script became increasingly difficult, as they were no longer familiar with the code and had to re-learn it after a few months. Additionally, the Pi's upgrade to a 64-bit model opened up new possibilities, such as the ability to create a self-contained .NET application. This new version of the coffee log writes every detected brew to a JSON file on the Pi, which proves to be a valuable asset for analyzing coffee habits.

One of the main challenges the author faced was determining when a coffee machine starts and finishes brewing. Initially, the state machine had two simple rules: power going up indicates a brewing start, and power dropping indicates a brewing completion. However, this rule was not foolproof, as the machine occasionally logged coffees that were not brewed.

To address this issue, the updated service now writes every detected brew to a JSON file and includes additional rules for detecting brew starts and finishes, minimum duration, and a cooldown period.

The author also highlights the importance of replay mode, which allows them to run the coffee detector using data from a CSV file instead of the actual plug. This feature enables them to test different settings and configurations without the need to brew actual coffee. The detector is designed to be interface-based, allowing it to accept readings from either the real plug or a CSV file. This flexibility makes it easy to swap between the two sources without affecting the downstream components.

In terms of wiring the coffee log back up to the website, the author uses a pluggable sink system, which allows them to choose how the data is processed and stored. Currently, they have a JSON file sink and an Umbraco sink, both of which write the data to their respective destinations. In the past, the Pi had a pending queue that kept retrying posts until the website responded, but this approach led to duplicate posts if the response got lost in transit.

To avoid this issue, the .NET sink deliberately does not retry failed posts, treating them as missing posts that can be fixed manually. This approach ensures that only unique, correctly published coffees are displayed on the website.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

A hold-and-release queue for orders waiting on paperwork

Every fulfillment system eventually meets the order that cannot ship for a boring reason. The battery datasheet has not arrived. The commercial invoice lists a country of origin the buyer disputes.

  • FulfillNexa's system assigns hold codes, owners, timestamps, expiries to orders
  • Two checkpoints prevent unnecessary delays before shipping
  • Expiration dates create clear decision points for late documents

Stop Calling an Agent Run “Done”: Model Delivery, Acceptance, Merge, and Deployment Separately

An agent says the task is finished. A branch exists. CI is green. The ticket moves to Done. Those four facts often arrive close together, but they are not the same fact.

  • Separate states for intent, review, integration, and deployment
  • Named actors: requester, task owner, runner, reviewer, repository maintainer, release owner
  • Workflow: draft → open → claimed → delivered → accepted

Finding double-billed shipments before the carrier's invoice ages out

Carrier invoices contain duplicates. Not many, and not usually in bad faith, but enough that any operation shipping across several carriers and several services will find some on any given month.

  • Detect duplicate invoices immediately upon receipt, not during quarterly reviews
  • Route flagged duplicates to manual review queue for further investigation

More from Friday 2 October →