Automated Grocery Shopping

I want to share a project I worked on a while ago, that I still use from time to time. 

Basically all my grocery shopping is done at Kolonial.no, which is a Norwegian online grocery store that has an api for the shopping cart and products. 

I am a cheapskate in many fields, including grocery shopping. And how I shop is somewhat robotic, very predictable and some might say boring and uninspired. But the thought process when I select items, can easily be automated, so I did. The code is on my github

All the docs are there, so I won't bore you with that here. 

But the idea and process is quite simple:

  1. I need eggs. Eggs are not a product. Eggs are a category of products. So my shopping list in this code is the category ID of eggs at kolonial.no. 
  2. On the same line in my shopping list I can also specify words that should or should not appear in the product name. For example "frittgående" should be in the name. (Norwegian for "free range")
  3. Next filter is whether or not the product is in stock. It must be in stock.
  4. If this results in more than one product, sort the items by the gross unit price, and select the cheapest alternative. So the price per weight or volume matters.
  5. Finally, how many items of the product I want. Now I can put the product in correct quantity in my shopping cart.
So this is what happens in my head when I shop physically, but now also programmatically. It is a bit of initial work finding the correct ID's and building the shopping list (actually csv), but from there on out, it's snappy.

Here it is in action:




First is the list that says to buy 2 "eggs", and the word "frittgående" (case insensitive) must be in the name. So it found the cheapest product that fit the criteria, and put two of them in my shopping cart.
After the automation has done its thing, it's a good idea to look over what it did and do manual adjustments if the quantities or anything else is wrong.

You may find it odd that I do this with docker. It might be overcomplicating things, but I prefer to dockerize as much as possible. A bit irrational perhaps, but it works on any computer with docker and I like it.

So I hope this post and code helps and inspires some of you to automate your own shopping or other mundane tasks in your life.

Have a great day! 

Comments

Popular posts from this blog

Hidden settings in the Raspberry Pi Imager

Getting the Miyoo Mini Plus battery into Home Assistant

Getting Company Portal apps locally using PowerShell (no auth!)