Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 36 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ Features
\
<img src="/docs/images/custom_button_card.png" alt="Example Custom Button Card" width="500"/>

[Bubble Popup Card with Markdown](/docs/community_templates/bubble_card_markdown.yaml) by @PineappleEmperor
\
<img src="/docs/images/bubble_card_markdown.png" alt="Example Bubble Card Popup with Markdown (for BBDs)" width="500"/>

### Tips & Tricks

* I send a reminder to edit my next delivery via a notification an hour before the edit deadline. To do this I created a template sensor for the countdown and a datetime helper to store the current edit deadline:
Expand Down Expand Up @@ -119,10 +123,13 @@ mode: single
I also have a grocery budget 'pot' and an extension to the notification can inform me if I need to top up the pot based on the estimated total.


### Sensors

The integration (currently) offers 5 sensors in a single device:
### Devices & Sensors

The integration offers 2 devices. The first contains the details about upcoming orders:
<details>
<summary><strong>Ocado (UK) Deliveries</strong></summary>
This device has 5 sensors:
<div style="margin-left: 25px;">
<details>
<summary><strong>Last Total Sensor</strong></summary>
<div style="margin-left: 25px;">
Expand Down Expand Up @@ -213,12 +220,37 @@ It has a single attribute:

</div>
</details>
</div>
</details>


<details>
<summary><strong>Ocado (UK) Deliveries</strong></summary>
<div style="margin-left: 25px;">
This device has a sensor for each day of the week:
<details>
<summary><strong>{{day}} Sensor</strong></summary>
<div style="margin-left: 25px;">

This sensor provides number of best before dates on the chosen day/date.

It has four attributes:

| **Attribute** | **Description** |
|-------------------|------------------------------------------------------------|
| **Updated** | This is the datetime of the email the info was taken from. |
| **Order Number** | The order number associated with the total. |
| **Date** | The date teh day falls on (i.e. the best before date). |
| **BBDs** | The list of items with a best before date on this date. |

</div>
</details>
</div>
</details>

Future Plans
--------
1. Testing 😅
2. Adding best before date sensors from the last delivery via the PDF receipt that is sent.
3. Other online grocery vendors? (in separate repos)

<!-- Badges -->
Expand Down
91 changes: 91 additions & 0 deletions docs/community_templates/bubble_card_markdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#########################################################################################
# Made by @PineappleEmperor
# Requires the fantastic bubble card available from HACS
#########################################################################################
type: vertical-stack
cards:
- type: custom:bubble-card
card_type: pop-up
# You will need to have some kind of navigation action that points to the hash
hash: "#ocado"
name: Ocado
# You may not have this icon so change it to whatever you prefer
icon: fapro:noun-swirl
width_desktop: 70%
margin_top_mobile: "-56px"
margin_top_desktop: 74px
auto_close: ""
hide_backdrop: false
bg_blur: 88
show_last_changed: false
title: Ocado Best Before Dates
button_type: name
show_icon: true
show_name: true
sub_button: []
bg_opacity: "88"
shadow_opacity: "0"
modules:
- default
- type: markdown
content: |-
{% set ocado_bbds = [
"sensor.ocado_best_before_monday",
"sensor.ocado_best_before_tuesday",
"sensor.ocado_best_before_wednesday",
"sensor.ocado_best_before_thursday",
"sensor.ocado_best_before_friday",
"sensor.ocado_best_before_saturday",
"sensor.ocado_best_before_sunday"
] %}

# This uses the time_date platform date sensor to avoid updating every minute with now().date()
{% set today = (states('sensor.date')|as_datetime).date() %}

{% set colours = ["#df0334", "#f16c28", "#f6bf26", "#33b679", "#039be5",
"#0047ab", "#8e24aa"] %}

{% set suffixes = {1: "st", 2: "nd", 3: "rd"} %}


{% set ns = namespace(dict_list = []) %}

{% for entity in ocado_bbds %}

{% set ns.dict_list = ns.dict_list + [{"entity_id": entity, "date":
state_attr(entity, "date"), "bbds": state_attr(entity, "bbds"), "icon":
state_attr(entity, "icon")}] %}

{% endfor %}


{% set sorted_list = ns.dict_list | sort(attribute="date") %}
{% set output = namespace(string="") %}

{% for i in range(sorted_list|length) %}
{% set entity = sorted_list[i] %}
{% if entity["bbds"] != [] %}
{% if entity["date"] >= today %}
{% set entity_id = entity["entity_id"] %}
{% set day = state_attr(entity_id,'date').strftime('%-d')|int(0) %}
{% set suffix = suffixes[day % 20] if (day % 20) in suffixes else 'th' %}
{% set day = day|string + suffix %}
{% set header = "## <font color= " + colours[i] + "> <ha-icon icon=" + entity["icon"] + "></ha-icon> " + entity["date"].strftime('%A') + " - " + day + "</font>" %}
{% set output.string = output.string + header + "\n" %}
{% for item in entity["bbds"] %}
{% set output.string = output.string + "- " + item + "\n" %}
{% endfor %}
{% set output.string = output.string + "---\n" %}
{% endif %}
{% endif %}
{% endfor %}
{{ output.string }}
card_mod:
style: |
ha-card {
--mdc-icon-size: 60px;
margin: 0px 0px 0px 0px;
border: none;
}
view_layout:
grid-area: hidden1
Binary file added docs/images/bbds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading