diff --git a/README.md b/README.md
index bfc6533..aa405cf 100644
--- a/README.md
+++ b/README.md
@@ -41,7 +41,7 @@ No matter which deployment option you chose you must setup some environment vari
| `BRING_USERNAME` | The email address of your bring account | Yes | - | `myuser@myemailprovider.com` |
| `BRING_PASSWORD` | The password of your bring account | Yes | - | `my super secret password` |
| `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` |
-| `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!  | No | - (all ingredients will be added) | `Salt,Pepper,Frying oil` |
+| `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!
.
Additionally, any ingredients marked as "On hand" in your Mealie recipes will be automatically ignored and not added to your Bring shopping list. | No | - (all ingredients will be added, except these matching 'On hand') | `Salt,Pepper,Frying oil` |
| `LOG_LEVEL` | The loglevel the application logs at | No | `INFO` | `DEBUG` |
| `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` |
| `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` |
@@ -137,3 +137,4 @@ or
$ curl -s -o /dev/null -w "%{http_code}" https://mealie-bring-api.yourlocaldomain.com/status
200
```
+````
diff --git a/source/ingredient.py b/source/ingredient.py
index df3b2a8..1e321fc 100644
--- a/source/ingredient.py
+++ b/source/ingredient.py
@@ -3,20 +3,21 @@
import dataclasses
import uuid
-
@dataclasses.dataclass
class Ingredient:
name: str
specification: str = None
-
+ uuid: str = None
@staticmethod
def from_raw_data(raw_data: dict) -> Ingredient:
- return Ingredient(name=Ingredient._get_name(raw_data), specification=Ingredient._get_specification(raw_data))
+ return Ingredient(name=Ingredient._get_name(raw_data), specification=Ingredient._get_specification(raw_data),uuid=Ingredient._get_uuid(raw_data))
@staticmethod
def _get_name(raw_data: dict) -> str:
- return raw_data["food"]["name"]
-
+ return raw_data["food"]["name"].capitalize()
+ @staticmethod
+ def _get_uuid(raw_data: dict) -> str:
+ return raw_data.get("reference_id",str(uuid.uuid4()))
@staticmethod
def _get_specification(raw_data: dict) -> str:
specification = f"{Ingredient._get_quantity(raw_data)}{Ingredient._get_unit(raw_data)}"
@@ -36,7 +37,10 @@ def _get_quantity(raw_data: dict) -> str:
return ""
quantity = int(quantity_raw) if quantity_raw.is_integer() else quantity_raw
return str(quantity)
-
+ @staticmethod
+ def in_household(raw_data: dict) -> str:
+ ret_val = len(raw_data["food"].get("households_with_ingredient_food",[])) > 0
+ return ret_val
@staticmethod
def _get_unit(raw_data: dict) -> str:
unit_raw = raw_data["unit"]
@@ -68,7 +72,7 @@ def is_ignored(name_of_ingredient: str, ignored_ingredients: list[Ingredient]) -
return name_of_ingredient.lower() in [ingredient.name for ingredient in ignored_ingredients]
def to_dict(self) -> dict:
- return {"itemId": self.name, "spec": self.specification, "uuid": str(uuid.uuid4())}
+ return {"itemId": self.name, "spec": self.specification, "uuid": str(self.uuid)}
@dataclasses.dataclass
diff --git a/source/main.py b/source/main.py
index 51301e8..24b37d9 100644
--- a/source/main.py
+++ b/source/main.py
@@ -37,7 +37,8 @@ def webhook_handler() -> str:
ingredients_to_add.append(IngredientWithAmountsDisabled.from_raw_data(ingredient_raw_data))
else:
name_of_ingredient = ingredient_raw_data["food"]["name"]
- if Ingredient.is_ignored(name_of_ingredient, ignored_ingredients):
+ # Ignore if the ingredient is in the household or on ignored list
+ if Ingredient.is_ignored(name_of_ingredient, ignored_ingredients) or Ingredient.in_household(ingredient_raw_data):
logger.log.debug(f"Ignoring ingredient {name_of_ingredient}")
continue
ingredients_to_add.append(Ingredient.from_raw_data(ingredient_raw_data))