Skip to content

[DO NOT MERGE!] [New feature]: Incorporate Delivery/Livraison bags #549

Draft
ThomasDelsart wants to merge 8 commits into
Der-Henning:mainfrom
ThomasDelsart:delivery_feature
Draft

[DO NOT MERGE!] [New feature]: Incorporate Delivery/Livraison bags #549
ThomasDelsart wants to merge 8 commits into
Der-Henning:mainfrom
ThomasDelsart:delivery_feature

Conversation

@ThomasDelsart

@ThomasDelsart ThomasDelsart commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

Initial Implementation: Delivery Bag Notifications
This PR introduces a feature for receiving notifications related to new Delivery Bags. This is an early implementation, shared to prevent redundant work and foster collaboration. It’s not intended for immediate merging. This has been tested a few scanning runs. It works smoothly but requires more testing before merging. Further discussion is also needed to refine the scope of the feature for this project (CC @Der-Henning )

This PR is a first attempt to solve the following issues:
Resolves #533
Resolves #529

Key Changes

  • API Integration: Added API calls to fetch information about delivery bags. Needed endpoint has been found from the relevant Issue discussion.
  • Data Processing: Introduced logic to read, parse, and convert delivery bag data into Item objects.
  • Continuous Monitoring: Implemented a monitoring mechanism via self.delivery_state to track the status of delivery items and send notifications if new bags appear.
  • Add a configuration option to enable/disable this new feature

Workflow

  • Initial Scan: On startup, the scanner checks all available delivery bags and triggers a notification for each one.
  • Iterative Checks: During each scan cycle, the system:
    • Removes bags that are out of stock from self.delivery_state.
    • Adds the new bags to self.delivery_state and sends notifications for these new items.

Potential Improvements

  • Enhance notifications with additional details about each delivery bag.
  • Tag notifications with a "Delivery" label for easier identification.
  • Send only one notification for all new delivery bags (especially useful for the startup of the scanner)
  • For the API call, some options in the json data are disabled, because they were not tested yet.

@ThomasDelsart ThomasDelsart changed the title [DO NOT MERGE!] New feature: Incorporate Delivery/Livraison bags [DO NOT MERGE!] [New feature]: Incorporate Delivery/Livraison bags Nov 4, 2024
Comment thread tgtg_scanner/scanner.py
log.error(err)
items += self._get_favorites()

# if state is empty (first scanning iteration), initialize it with the current favorite items

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SEE PR #548

raise

@classmethod
def delivery_item_conversion(cls):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed because delivery bags have not the same attributes in the API call than Items

store: dict = data.get("store", {})
self.store_name: str = store.get("store_name", "-")

self.manufacturer_properties: dict = data.get("manufacturer_properties", {})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New attributes for delivery items

Comment thread tgtg_scanner/scanner.py
return []
return [Item(item, self.location, self.config.locale) for item in items]

def convert_raw_delivery_item(self, raw_delivery_item: dict, mapping: dict) -> Item:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conversion of delivery data, not in the same format as item data. Adding some logic to have correct format to build the Item object

"element_types_accepted": [
"ITEM", # All items/products in delivery
"HIGHLIGHTED_ITEM", # Item with a special highlight on the top of the delivery pannel
# "DUO_ITEMS",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not tested yet so still there but commented

@antonioli86 antonioli86 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for the delivery items but seems missing the catering part - another endpoint?

@antonioli86

Copy link
Copy Markdown

If I add 'FILL' to display_types_accepted and 'ITEM_CARDS_CAROUSEL' to the element_types_accepted (in the get_raw_delivery_items function), catering offers appear but only the ones that appear in main screen of delivery - not all the offers that are available when I click "Catering" button.
@ThomasDelsart

@xpiREC

xpiREC commented Jan 27, 2026

Copy link
Copy Markdown

Currently, I only use the delivery section, I have few packages in restaurants, so scanning them is unnecessary. What should I comment out in the code so that it does not cron “API_ITEM_ENDPOINT”?

In fact, this could also be added to the configuration for in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Monitor "Livraison" side of the application Add notifications fon new manufactureitem endpoint.

3 participants