Skip to content

Commit 1d3cd17

Browse files
committed
Deprecate IGNORED_INGREDIENTS environment variable
Remove support for `IGNORED_INGREDIENTS` and replace it with a new ingredient management system to mark certain items as always on hand. Updated documentation and included a new image to guide users on configuring ignored ingredients through the UI instead.
1 parent f90f53f commit 1d3cd17

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Mealie instance and adds the ingredients of a recipe to a specified Bring shoppi
1111
> [!IMPORTANT]
1212
> This integration does only support Mealie version >= `2` which was [released in October 2024](https://github.com/mealie-recipes/mealie/releases/tag/v2.0.0). The support for Mealie version < `2` was deprecated in https://github.com/felixschndr/mealie-bring-api/pull/17.
1313
14+
> [!IMPORTANT]
15+
> The environment variable `IGNORED_INGREDIENTS` was deprecated and is now ignored. If you are using it, migrate to the
16+
new way of configuring which ingredients shall be ignored.
17+
1418
## Architecture
1519

1620
### Without this project
@@ -41,14 +45,28 @@ No matter which deployment option you chose you must setup some environment vari
4145
| `BRING_USERNAME` | The email address of your bring account | Yes | - | `[email protected]` |
4246
| `BRING_PASSWORD` | The password of your bring account | Yes | - | `my super secret password` |
4347
| `BRING_LIST_NAME` | The exact name of the list you want to add the ingredients to, supports special characters | Yes | - | `My shopping list with spaces` |
44-
| `IGNORED_INGREDIENTS` | Ingredients that are never added to the shopping list (things you always have at home), separated by a `,`, case insensitive, **WARNING**: This *only* works for recipes with *enabled* ingredient amounts in the recipe settings! ![recipe settings](./assets/images/recipe_settings.png) | No | - (all ingredients will be added) | `Salt,Pepper,Frying oil` |
4548
| `LOG_LEVEL` | The loglevel the application logs at | No | `INFO` | `DEBUG` |
4649
| `HTTP_HOST` | The address the application tries to attach to, leave this empty to listen on all interfaces, leave this empty if you are using Docker | No | `0.0.0.0` | `192.168.1.5` |
4750
| `HTTP_PORT` | The port the application listens on, change this if needed if you run the application locally, leave this empty if you are using Docker | No | `8742` | `1234` |
4851
| `HTTP_BASE_PATH` | The path the application listens on. Use this if you use the app behind a reverse proxy and have setup a path (e.g. set this to `/bring` if the application shall listen on `<mealie>.<yourdomain>.tld/bring`) | No | `""` | `/bring` |
4952

5053
Ensure to quote your environment variables. Without quotes your password might not be read properly if it contains symbols such as `<`, `&` or `;`.
5154

55+
#### Ignoring ingredients
56+
57+
It is possible to define ingredients that shall never be added to the shopping list. These are ingredients you always have at home (e.g., salt and pepper).
58+
59+
> [!WARNING]
60+
> The environment variable `IGNORED_INGREDIENTS` was deprecated and is now ignored. If you are using it, migrate to the new way of configuring which ingredients shall be ignored.
61+
62+
To do so
63+
1. Open the `Data Management` (under `<your mealie domain>/group/data/foods/`).
64+
2. Search for the ingredient you don't want to be added to the shopping list.
65+
3. Click on the edit button.
66+
4. Enable the checkbox `On Hand`.
67+
68+
![](assets/images/food_on_hand.png)
69+
5270
### Deployment options
5371

5472
You can run this app in three simple ways. I prefer the third option. Depending on the deployment option you chose

assets/images/food_on_hand.png

21.5 KB
Loading

source/ingredient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def _get_note(raw_data: dict) -> str:
6464
return f"({raw_data['note']})"
6565

6666
@staticmethod
67-
def is_ignored(name_of_ingredient: str, ignored_ingredients: list[Ingredient]) -> bool:
68-
return name_of_ingredient.lower() in [ingredient.name for ingredient in ignored_ingredients]
67+
def in_household(raw_data: dict) -> bool:
68+
return len(raw_data["food"].get("households_with_ingredient_food", [])) > 0
6969

7070
def to_dict(self) -> dict:
7171
return {"itemId": self.name, "spec": self.specification, "uuid": str(uuid.uuid4())}

source/main.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ def webhook_handler() -> str:
3636
# This often is the case when a recipe is imported from some source and not properly formatted yet
3737
ingredients_to_add.append(IngredientWithAmountsDisabled.from_raw_data(ingredient_raw_data))
3838
else:
39-
name_of_ingredient = ingredient_raw_data["food"]["name"]
40-
if Ingredient.is_ignored(name_of_ingredient, ignored_ingredients):
41-
logger.log.debug(f"Ignoring ingredient {name_of_ingredient}")
39+
if Ingredient.in_household(ingredient_raw_data):
40+
logger.log.debug(f"Ignoring ingredient {ingredient_raw_data["food"]["name"]}")
4241
continue
4342
ingredients_to_add.append(Ingredient.from_raw_data(ingredient_raw_data))
4443

@@ -55,19 +54,15 @@ def status_handler() -> str:
5554
return "OK"
5655

5756

58-
def parse_ignored_ingredients() -> list[Ingredient]:
57+
def check_for_ignored_ingredients() -> None:
5958
try:
60-
ignored_ingredients_input = EnvironmentVariableGetter.get("IGNORED_INGREDIENTS")
61-
except RuntimeError:
62-
logger.log.info(
63-
"The variable IGNORED_INGREDIENTS is not set. All ingredients will be added. "
64-
'Consider setting the variable to something like "Salt,Pepper"'
59+
EnvironmentVariableGetter.get("IGNORED_INGREDIENTS")
60+
logger.log.warning(
61+
"The variable IGNORED_INGREDIENTS is deprecated and ignored! "
62+
"Take a look README.md for more information on how to ignore ingredients."
6563
)
66-
return []
67-
68-
ignored_ingredients_raw = ignored_ingredients_input.replace(", ", ",").split(",")
69-
logger.log.info(f"Ignoring ingredients {ignored_ingredients_raw}")
70-
return [Ingredient(name.lower()) for name in ignored_ingredients_raw]
64+
except RuntimeError:
65+
pass
7166

7267

7368
if __name__ == "__main__":
@@ -77,7 +72,6 @@ def parse_ignored_ingredients() -> list[Ingredient]:
7772
asyncio.set_event_loop(loop)
7873

7974
bring_handler = BringHandler(loop)
80-
ignored_ingredients = parse_ignored_ingredients()
8175

8276
host = EnvironmentVariableGetter.get("HTTP_HOST", "0.0.0.0")
8377
port = int(EnvironmentVariableGetter.get("HTTP_PORT", 8742))

0 commit comments

Comments
 (0)